BACKGROUND AND OBJECTIVES: The focus of this study is on the importance of reliable and precise forecasting of acute oral toxicity to bolster chemical safety and advance sustainable development goals, particularly sustainable development goals-۳ (good health and well-being), sustainable development goals-۶ (clean water and sanitation), and sustainable development goals-۱۲ (responsible consumption and production). Traditional toxicity assessments are often time-consuming and costly, necessitating the exploration of more efficient approaches. The focus of this study is to establish the most efficient method for constructing reliable and precise models for toxicity prediction.METHODS: The random forests were evaluated, a robust ensemble method, for predicting acute oral toxicity using a comprehensive dataset from National Toxicology Program/Interagency Center for the Evaluation of Alternative Toxicological Methods and Environmental Protection Agency/National Center for Competency Testing, which presented significant class imbalance, ۸ percent very toxic ۹۲ percent not very toxic. To address this imbalance, strategies such as cost-sensitive learning and data resampling techniques, including both under sampling and oversampling, were utilized. A diverse set of two-dimensional molecular descriptors generated via rational discovery kit were used as input features, and model preprocessing involved normalization, validation, and feature selection. Hyper-parameter tuning was conducted using Bayesian optimization and cross-validation, while the performance of random forests was evaluated in comparison to gradient boosting, extreme gradient boosting, artificial neural networks, and the generalized linear model.FINDINGS: The random forests models, particularly those utilizing under sampling and cost-sensitive learning, demonstrated superior performance, achieving sensitivity of ۰.۸۱, Specificity of ۰.۸۵, accuracy of ۰.۸۵, and an area under the receiver operating characteristic curve of ۰.۸۹ on an independent test set. An examination of feature importance has shown that the primary molecular descriptors are those related to the Van der waals surface area and molecular quantum numbers. A surrogate decision tree developed from random forests predictions reached an area under the curve of ۰.۹۲۹.CONCLUSION: Random forest models effectively predicted acute oral toxicity, particularly when addressing class imbalance through cost-sensitive learning and resampling. leveraging explainable artificial intelligence techniques, including permutation feature importance, surrogate decision tree analysis and local interpretable model-agnostic explanations, this study identified key molecular descriptors driving toxicity. This advancement improves model interpretability and represents a significant step toward enhancing chemical safety while supporting sustainable development goals.