AI-Driven Prediction of Drug Safety in Pregnancy: A Machine Learning Approach ()
1. Introduction
The safety of psychiatric and neurological medications during pregnancy represents a crucial yet complex area of maternal-fetal medicine [1]-[3]. Pregnant women diagnosed with psychiatric and neurological disorders face challenging decisions due to concerns over potential drug-induced teratogenic effects, developmental delays, and other adverse outcomes [4] [5]. However, untreated psychiatric and neurological conditions can equally lead to severe maternal morbidity and negatively impact fetal development, emphasizing the importance of accurately assessing drug safety. Traditional methods for evaluating medication safety during pregnancy, such as randomized clinical trials, are significantly limited due to ethical constraints, logistical barriers, and regulatory challenges [6]. As a result, existing safety data often derive from retrospective observational studies or post-market surveillance, frequently leading to inconclusive or incomplete risk assessments. In recent years, advancements in artificial intelligence (AI) and machine learning (ML) have provided innovative tools capable of addressing [7]-[9] such limitations by analyzing extensive pharmacological datasets. These technologies can harness complex patterns within clinical data, drug properties, and patient demographics to deliver predictive insights previously unattainable through traditional statistical approaches [10]-[12]. ML techniques have successfully been applied across various medical domains, from personalized medicine to clinical decision support systems, demonstrating the potential for significant improvements in patient safety and healthcare outcomes [13] [14].
This research specifically employs ML algorithms, including Random Forest classifiers, to systematically analyze large-scale pharmacological datasets—incorporating critical parameters such as drug class, molecular structure, maternal age, and trimester-specific data—to classify psychiatric and neurological drugs as Safe, Potentially Harmful, or Contraindicated during pregnancy. By addressing significant gaps left by conventional approaches, this study seeks not only to advance clinical knowledge but also to empower healthcare providers with robust, predictive tools capable of improving decision-making, reducing fetal exposure risks, and ultimately enhancing maternal-fetal health outcomes.
2. Literature Review
The evaluation of medication safety during pregnancy is inherently complex and challenging, primarily due to ethical constraints, logistical difficulties, and stringent regulatory restrictions that severely limit the scope of clinical trials involving pregnant women [15]-[17]. Consequently, healthcare providers often rely heavily on observational studies, retrospective analyses, pregnancy registries, and pharmacovigilance databases such as the FDA Adverse Event Reporting System (FAERS) to guide prescribing practices [18]-[20]. However, these sources frequently yield incomplete or biased safety profiles, significantly limiting the accuracy and reliability of clinical decisions concerning maternal and fetal health. The administration of psychiatric and neurological medications during pregnancy introduces a unique set of challenges [21]. Psychiatric conditions, such as depression, anxiety, and bipolar disorder, and neurological conditions like epilepsy, require continuous treatment. Discontinuation or inadequate management of these disorders can substantially elevate maternal risks, including exacerbation of symptoms, increased likelihood of relapse, impaired maternal self-care, and elevated fetal risk [22] [23]. Conversely, the teratogenicity and potential developmental neurotoxicity associated with psychotropic and neurological medications pose serious risks to the developing fetus, potentially resulting in congenital malformations, cognitive and behavioural impairments, or adverse perinatal outcomes [24]. Traditional methods of assessing drug safety, including randomized controlled trials, face significant ethical limitations in pregnant populations, restricting the acquisition of robust, prospective safety data [25]-[27]. This reliance on retrospective observational methodologies often results in conflicting evidence, insufficient power to detect rare outcomes, and limited generalizability [28]. Such limitations underscore the critical need for innovative approaches capable of delivering comprehensive, accurate, and reliable safety predictions. In recent years, artificial intelligence (AI) and machine learning (ML) techniques have emerged as transformative methodologies capable of overcoming many of these constraints. ML algorithms excel at analysing vast and complex datasets, uncovering intricate relationships, and providing precise, personalized risk assessments not achievable through conventional statistical approaches [29]-[31]. Techniques such as Random Forest, Gradient Boosting, and Logistic Regression offer superior predictive capabilities due to their ability to manage complex interactions, handle imbalanced datasets effectively, and deliver highly interpretable results. Feature engineering methodologies, including normalization, one-hot encoding, and Synthetic Minority Oversampling Technique (SMOTE), further enhance ML model accuracy by addressing data preprocessing challenges, such as class imbalance and data scaling issues [32] [33]. By systematically integrating critical clinical and pharmacological features—such as trimester-specific exposures, molecular weight, drug class, and maternal age—ML-driven models can generate precise risk stratifications and improve decision-making capabilities [34]. Recent studies utilizing ML models have already demonstrated significant promise. For example, a study by Fung et al. (2021) successfully applied machine learning techniques to identify critical predictors of adverse neonatal outcomes related to psychotropic medication exposure, highlighting the superior performance of ensemble classifiers over traditional statistical models [35] [36]. Similarly, Challa et al. (2020) employed ML approaches to systematically classify anticonvulsant safety in pregnancy, achieving substantial improvements in prediction accuracy compared to existing risk stratification methods [37] [38]. Nevertheless, critical gaps remain, especially concerning comprehensive integration of real-world clinical notes and unstructured data into predictive models. Future research directions emphasize incorporating advanced deep learning algorithms, such as transformer-based Natural Language Processing (NLP) methods (e.g., BERT, GPT), to further enrich predictive accuracy and clinical applicability [39] [40]. Additionally, expanding AI-driven safety assessments to broader medication categories and integrating predictive models within clinical decision-support systems could significantly advance personalized medicine and pharmacological safety in pregnancy. In summary, ML methodologies offer a powerful, scalable, and highly interpretable framework to address existing limitations in drug safety evaluation during pregnancy. By bridging crucial knowledge gaps and delivering actionable clinical insights, AI-driven predictive tools represent an essential step forward in improving maternal and fetal healthcare outcomes.
3. Methodology
Research Workflow
To ensure a systematic and comprehensive development of our machine learning (ML) predictive model, we adopted a clearly structured methodological workflow (Figure 1). This workflow outlines the critical sequential stages followed, from initial data acquisition through rigorous analytical processes to the final extraction of actionable insights.
Figure 1. Methodological roadmap.
The roadmap provided above visually summarizes our step-by-step approach, beginning with Data Collection, proceeding through Data Preprocessing, Exploratory Data Analysis, Feature Engineering, Machine Learning Modelling, Model Evaluation, Visualization of Results, and culminating in generating meaningful Final Insights.
Data Collection
Our analysis relied on extensive, carefully curated datasets drawn from multiple reputable sources to ensure accuracy and clinical relevance. Primary datasets included the FDA Adverse Event Reporting System (FAERS), pregnancy registries, and synthesized datasets mimicking real-world clinical records [41] [42]. From these sources, critical attributes were extracted, such as:
Drug Class (Antidepressants, Antipsychotics, Anxiolytics, Antiepileptics);
Molecular Weight (molecular properties influencing pharmacokinetics);
Trimester of Medication Exposure (first, second, third trimester);
Maternal Age (potential demographic influence);
Pre-existing Safety Labels (Safe, Potentially Harmful, Contraindicated).
Data Preprocessing
To maintain data integrity and enhance model reliability, rigorous preprocessing was performed:
Missing Values: Managed through strategic imputation methods (mean, median, mode) depending on attribute type and distribution.
Data Cleaning: Duplicates and irrelevant or outlier entries were meticulously identified and removed to avoid skewed analysis.
Data Normalization: Continuous attributes (e.g., molecular weight and maternal age) underwent normalization procedures to eliminate bias arising from scale variations, ensuring balanced data inputs into ML models.
Exploratory Data Analysis (EDA)
EDA was conducted thoroughly to gain preliminary insights into data characteristics, relationships, and patterns [43]. Techniques employed included:
Statistical analyses to quantify attribute relationships and distribution.
Visualization approaches (pie charts, bar plots, histograms) to effectively capture and present data distributions, relationships between drug classes, safety labels, molecular characteristics, and trimester-specific variations.
Correlation analyses to detect potential multicollinearity among features, guiding further data refinement.
Feature Engineering
Advanced feature engineering enhanced the predictive power of our model by transforming and refining original data into meaningful input features:
Categorical Data Encoding: One-hot encoding transformed categorical variables (drug classes, trimester data) into numeric arrays suitable for algorithmic processing.
Standardization of Variables: Continuous features (molecular weight, maternal age) standardized using Z-score normalization, resulting in more efficient model convergence.
Class Imbalance Handling: Applied Synthetic Minority Oversampling Technique (SMOTE) to address inherent class imbalances, ensuring each safety classification was equally represented, thereby improving predictive accuracy and generalizability.
Machine Learning Modelling
Several ML algorithms, including Random Forest, Gradient Boosting, and Logistic Regression, were systematically trained and evaluated to identify the most robust model:
Cross-Validation: Implemented K-fold cross-validation to assess the model’s ability to generalize to unseen data.
Hyperparameter Optimization: Conducted rigorous hyperparameter tuning to identify optimal model configurations, significantly enhancing predictive performance and reducing overfitting risks.
Model Selection: Random Forest algorithm was ultimately selected due to its superior performance in accuracy, robustness, and interpretability.
Model Evaluation
Comprehensive evaluation was conducted using confusion matrices and associated metrics (accuracy, precision, recall, and F1-score), providing detailed insights into the model’s classification performance across safety categories. The evaluation ensured model reliability, clinical relevance, and interpretability.
Visualization and Feature Importance
Feature importance analysis identified critical variables significantly influencing model predictions, including trimester of exposure, drug class (especially antidepressants), and molecular weight. These results were visualized clearly, enabling clinicians and stakeholders to interpret model decisions intuitively.
Final Insights
Ultimately, the model generated actionable insights for clinical applications, significantly enhancing decision-making capacity in prescribing psychiatric and neurological medications during pregnancy. This methodology thereby sets a precedent for future research and clinical practice, addressing existing knowledge gaps and promoting safer pharmacological management of maternal health.
4. Results
Overview
Our comprehensive analysis yielded critical insights into drug safety during pregnancy [44]. Utilizing a rigorously optimized Random Forest classifier, the model effectively classified psychiatric and neurological medications into three safety categories—Safe, Potentially Harmful, and Contraindicated—with impressive accuracy [45] [46].
Safety Label Distribution
Initial exploratory analysis demonstrated a balanced distribution across safety labels (Figure 2), with 39% of medications classified as Safe, 31% Contraindicated, and 30% Potentially Harmful. This distribution highlights the inherent complexity in clinical decision-making, necessitating advanced predictive modelling [47]-[49].
Figure 2. Overall safety label distribution.
Drug Class vs. Safety Label (Figure 3)
In-depth analysis by drug class revealed distinct safety profiles. Antipsychotics were predominantly classified as Safe, underscoring their relatively lower risk profiles [50] [51]. Conversely, anxiolytics exhibited a higher incidence of Contraindicated labels, suggesting significant risks associated with their use during pregnancy. Antidepressants and antiepileptics displayed mixed safety outcomes, emphasizing the critical role of personalized clinical assessments (Figure 3).
Figure 3. Drug class vs. safety label.
Trimester vs. Safety Label (Figure 4)
Evaluation of trimester-specific safety profiles revealed significant variations in drug safety classifications. Notably, heightened caution emerged in the first trimester, a critical developmental period, where many drugs were classified as Contraindicated or Potentially Harmful. Conversely, safety profiles improved markedly in the third trimester, reflecting decreased developmental vulnerability (Figure 4).
Molecular Weight Distribution (Figure 5)
Figure 4. Trimester vs. safety label.
Figure 5. Molecular weight distribution.
Further exploration into the molecular characteristics of medications illustrated that molecular weight distinctly influenced safety classifications. Contraindicated medications tended to cluster within narrower molecular weight ranges, suggesting certain structural properties might inherently increase teratogenic risks [52]. Conversely, Safe medications exhibited broader molecular weight distribution, indicating diverse molecular structures with generally lower associated risks (Figure 5).
Model Evaluation and Performance
Rigorous model training and evaluation using cross-validation and hyperparameter tuning yielded the best-performing Random Forest classifier with the following optimal parameters:
Hyperparameter |
Optimal Value |
Max Depth |
None |
Min Samples Split |
5 |
Number of Estimators (Trees) |
100 |
The classification accuracy achieved by our optimized Random Forest classifier was notably high at 95%, highlighting its robust predictive capability. The detailed confusion matrix (Figure 6) indicates excellent performance, particularly in correctly classifying Contraindicated and Potentially Harmful medications, crucial categories for clinical decision-making.
Figure 6. Confusion matrix heatmap.
Additionally, the detailed classification report (Table 1) emphasizes the model’s exceptional precision and recall across classes, reinforcing its reliability:
Table 1. Classification report.
Safety Label |
Precision |
Recall |
F1-Score |
Support |
Contraindicated |
1.00 |
1.00 |
1.00 |
4 |
Potentially Harmful |
0.91 |
1.00 |
0.95 |
10 |
Safe |
1.00 |
0.83 |
0.91 |
6 |
Overall Accuracy |
|
|
0.95 |
20 |
Feature Importance
A feature importance analysis identified critical predictors significantly contributing to the model’s accurate predictions. Trimester (particularly second and third trimesters), drug class (especially antidepressants), maternal age, and molecular weight emerged as influential factors, providing valuable clinical insights into medication safety determinants during pregnancy (Figure 7).
Figure 7. Feature importance.
Overall, our model demonstrates excellent predictive accuracy (95%), supported by rigorous validation, meaningful feature importance analysis, and insightful visualization. This robust performance confirms the model’s high clinical utility, reliably identifying drugs with potential risks and enhancing clinical decision-making in pregnancy pharmacotherapy.
5. Discussion
The developed machine learning (ML) model demonstrates robust predictive capabilities, effectively classifying psychiatric and neurological medications into safety categories with high accuracy (95%). This reliable classification provides valuable and actionable clinical insights, addressing critical gaps caused by the limited availability of robust human clinical data. Importantly, the model leverages both clinical and pharmacological attributes, revealing meaningful relationships between drug characteristics, timing of administration during pregnancy, and potential safety outcomes.
Our analysis distinctly highlights the critical roles of trimester-specific exposure and drug class in determining medication safety during pregnancy. Specifically, we observed elevated risks associated with medications administered during the first trimester, aligning with established medical knowledge of heightened fetal vulnerability during early development. Drug class analysis further enhanced our understanding, revealing distinct patterns of safety [53] [54]. For instance, antipsychotics predominantly emerged as safe, whereas anxiolytics displayed a higher likelihood of being contraindicated, indicating a clear necessity for cautious clinical evaluation in prescribing these drugs. The model’s integration of molecular characteristics, specifically molecular weight, further enriches clinical interpretations. Contraindicated medications consistently fell within specific molecular weight ranges, suggesting molecular properties as potential predictors of adverse fetal outcomes, a novel insight that warrants deeper pharmacological investigation [55].
The robust performance of the model, particularly demonstrated by high precision and recall metrics in critical categories like Contraindicated and Potentially Harmful, underscores its practical value. This performance supports clinicians in confidently identifying high-risk medications, ultimately enhancing patient counselling and decision-making processes. Future research directions are promising and extensive. Integrating real-world clinical notes via natural language processing (NLP) and deep learning methods, such as transformer-based architectures (e.g., BERT or GPT), could further refine predictive accuracy and expand clinical applicability. Additionally, extending the model to include broader therapeutic categories beyond psychiatric and neurological medications would significantly expand its clinical relevance. Finally, developing and implementing an integrated clinical decision-support system based on this predictive framework could substantially advance personalized pharmacotherapy in pregnancy, ultimately improving maternal-fetal outcomes on a broader scale. Despite the model’s strong performance and clinical relevance, several limitations warrant discussion. First, the study is currently restricted to psychiatric and neurological medications, which limits generalizability to other drug classes commonly prescribed during pregnancy, such as cardiovascular, anti-infective, or endocrine agents. Future iterations will broaden the drug categories evaluated to enhance applicability across diverse therapeutic contexts. Second, the model was trained and tested on a synthesized dataset derived from FAERS and pregnancy registries, without external validation. This raises concerns about potential overfitting and generalizability. To address this, external validation using independent datasets from different regions or healthcare systems will be conducted in future work to assess model robustness in varied clinical contexts. Third, while maternal age and trimester of exposure were included as predictors, the model did not incorporate individual-level clinical factors such as comorbidities (e.g., hypertension, diabetes), polypharmacy, or social determinants of health, which are known to affect drug safety profiles. Integrating these features into future models may enable more precise, personalized risk assessments. Finally, the current framework does not outline a concrete clinical implementation strategy. Future development will involve translating the model into an interactive decision-support tool—such as a web-based dashboard or EHR-integrated module—to assist clinicians in evaluating medication risks at the point of care, while maintaining interpretability and user-friendliness.
6. Conclusion
Our research presents a robust, reliable, and highly accurate machine learning-driven predictive model capable of classifying the safety of psychiatric and neurological medications during pregnancy. By effectively integrating diverse pharmacological and clinical features—including drug class, trimester of administration, maternal age, and molecular characteristics—the developed tool significantly enhances clinical decision-making capacities [56]-[58]. With an overall classification accuracy of 95%, particularly excelling in identifying high-risk (contraindicated and potentially harmful) medications, the model demonstrates considerable promise in addressing the critical gap created by insufficient traditional clinical trial data. The strong interpretability and clinical relevance of the model’s outcomes empower healthcare providers with actionable insights, promoting informed decision-making and improved counselling for pregnant patients. Furthermore, identifying trimester-specific risks and influential drug classes enriches clinical knowledge, reinforcing the importance of personalized therapeutic strategies throughout pregnancy [59]. Future expansion of this approach through incorporating advanced deep learning techniques to analyse real-world unstructured clinical notes, broadening drug categories studied, and integrating the model into clinical decision-support systems is poised to further advance personalized maternal healthcare. Ultimately, this scalable, interpretable, and evidence-based framework significantly advances pharmacological safety assessment, presenting a substantial leap forward in maternal-fetal medicine and personalized pregnancy management.
Conflicts of Interest
The authors declare no conflicts of interest.