Interpretable Machine Learning Framework for Predicting Treatment Resistance in Psychiatric Disorders Using Synthetic Pharmacogenomic and Clinical Data ()
1. Introduction
Treatment-resistant psychiatric disorders, such as major depressive disorder and bipolar disorder, represent a major burden for patients and healthcare systems alike [1]-[3]. These cases often fail to respond to multiple lines of standard pharmacological interventions, resulting in prolonged suffering, increased hospitalization rates, and higher healthcare costs [4]-[6]. Identifying patients at risk of treatment resistance early in the clinical pathway remains a critical challenge in psychiatry [7]-[10]. Recent advances in pharmacogenomics and Machine Learning (ML) have created promising avenues for personalized medicine, offering the ability to predict individual treatment response based on molecular and clinical profiles [11]-[13]. However, building such predictive models requires access to large, high-quality datasets that combine gene expression data, treatment outcomes, and diverse clinical features [14] [15]. In real-world settings, such multimodal datasets are often fragmented, limited in size, and burdened with missing or biased information [16] [17]. These constraints significantly limit the generalizability, robustness, and explainability of many ML-based healthcare solutions [18]-[20]. To address these limitations, this study proposes a novel and fully synthetic dataset that simulates realistic pharmacogenomic and clinical interactions observed in psychiatric populations. The dataset is used to train and evaluate a range of supervised machine learning classifiers—Random Forest, Gradient Boosting, and Calibrated Support Vector Machine—within a structured pipeline that includes preprocessing, feature selection, model evaluation, and interpretability. Techniques such as permutation importance and LIME (Local Interpretable Model-Agnostic Explanations) are used to enhance transparency, while individualized clinical reports demonstrate the model’s utility in real-world decision-making contexts [21]-[23]. By combining synthetic data generation, model performance evaluation, and patient-level interpretability, this study aims to validate a scalable framework for predicting treatment resistance in psychiatry. The overarching goal is to bridge the gap between algorithmic performance and clinical relevance, contributing to the future of explainable, AI-powered precision psychiatry.
2. Literature Review
2.1. Understanding Treatment Resistance in Psychiatry
Treatment resistance is a persistent and challenging issue in the clinical management of psychiatric disorders [24]-[26]. A significant portion of patients fail to respond adequately to standard pharmacological treatments, even after multiple therapeutic attempts [27] [28]. This lack of response is influenced by a complex interplay of genetic, biological, and psychosocial factors that vary widely across individuals. Traditional diagnostic approaches and treatment guidelines are often unable to accommodate this variability, resulting in suboptimal outcomes for many patients [29]-[31]. This has led to increasing interest in predictive models that can anticipate treatment resistance before clinical failure occurs.
2.2. Role of Genetic and Clinical Predictors
Both genetic markers and clinical features hold considerable potential in forecasting treatment outcomes [32] [33]. Specific genetic variations are known to influence drug metabolism, neurochemical pathways, and receptor sensitivity. At the same time, clinical variables such as age at onset, illness duration, number of prior episodes, comorbidities, and early treatment response indicators offer valuable insights into the trajectory of psychiatric disorders. When used in isolation, these features may have limited predictive power; however, when combined, they form a robust foundation for personalized predictions [34] [35]. This convergence of genetic and clinical signals is increasingly recognized as essential for precision psychiatry.
2.3. The Emergence of Machine Learning in Psychiatry
Machine learning has rapidly become a transformative tool in mental health research, enabling the development of predictive models that can uncover hidden patterns within complex, high-dimensional data [36] [37]. Models such as Random Forests, Support Vector Machines, and Gradient Boosting classifiers are particularly well-suited to the integration of heterogeneous data sources. These models can learn intricate, nonlinear relationships between features and outcomes, making them ideal candidates for forecasting treatment resistance. However, the adoption of machine learning in psychiatry remains limited by concerns related to model transparency, interpretability, and clinical applicability.
2.4. The Need for Explainable AI in Clinical Decision-Making
As machine learning models begin to inform clinical decisions, the need for interpretability becomes critical. Clinicians must understand not only what a model predicts but why it arrives at a particular conclusion. Explainable AI techniques such as feature importance rankings, local instance explanations, and intuitive visualizations serve to bridge this gap [38] [39]. By translating model outputs into human-understandable reasoning, these tools foster trust and accountability in real-world applications. In psychiatry, where decisions have long-term consequences and ethical weight, transparent AI is not a luxury but a necessity.
2.5. Synthetic Data as a Catalyst for Innovation
The availability of high-quality, labelled clinical data often poses a major limitation to the development of reliable machine learning models [40] [41]. Privacy concerns, data access restrictions, and small sample sizes can hinder model training and evaluation. In response, synthetic data generation has emerged as a powerful alternative. By simulating realistic patient cohorts with configurable clinical and genetic features, researchers can design controlled experiments, test model robustness, and explore feature interactions without ethical or logistical constraints. Importantly, synthetic data allows for the introduction of biologically meaningful signal patterns, enhancing the relevance of downstream analyses [42] [43].
2.6. Toward a Unified and Interpretable Framework
Despite progress in machine learning applications and synthetic data modelling, a fully integrated approach—combining biologically grounded synthetic data, predictive modelling, explainability, and clinical reporting—remains underdeveloped. Many existing studies focus on isolated components: model performance, gene associations, or feature selection [44]-[47]. There is a clear need for end-to-end frameworks that not only predict treatment outcomes but also provide interpretable, actionable feedback tailored to individual patients.
This research addresses that need by building a comprehensive pipeline that begins with realistic synthetic data and culminates in individual clinical insights. By aligning interpretability with predictive power, the proposed framework aims to advance the use of AI in psychiatric care and contribute meaningfully to the field of precision mental health.
3. Methodology
This section outlines the complete machine learning pipeline for predicting treatment resistance using synthetically simulated pharmacogenomic and clinical data. The process is divided into eight interconnected stages, visualized in Figure 1 below, which maps the sequential logic and integration points across data generation, modelling, evaluation, and explainability.
3.1. Synthetic Data Generation
To overcome limitations of real-world patient data availability, we generated a synthetic dataset comprising 2000 samples, each with 50 gene expression features and 15 clinical variables. Gene features were initialized using standard normal distributions. To inject domain-relevant signals:
GENE_1 was amplified in lithium responders.
GENE_6 was suppressed in valproate-sensitive individuals.
GENE_10 was boosted in lamotrigine responders.
Figure 1. Pipeline roadmap for treatment resistance prediction.
These controlled distortions simulate biological variability aligned with known pharmacogenetic interactions.
3.2. Clinical Feature Simulation
The clinical component includes demographics (e.g., age, BMI), illness characteristics (e.g., depression/mania episodes, age of onset), comorbidities (e.g., anxiety, substance use), and baseline severity scores (MADRS, YMRS). Notably:
Treatment response scores for lithium, valproate, and lamotrigine were modelled using beta distributions to generate bimodal separability between responders and non-responders.
A binary rapid cycling indicator was calculated from cumulative episode history using a probability threshold.
3.3. Target Definition: Treatment Resistance
The binary target variable Treatment Resistant was constructed using a weighted probabilistic function. Factors increasing the resistance probability included:
Low response scores to any of the three mood stabilizers.
Genetic risk signals in GENE_1, GENE_6, or GENE_10.
The presence of rapid cycling.
The output of this function was then sampled using a Bernoulli distribution, resulting in a resistance prevalence of ~46.5%.
3.4. Data Preprocessing
Features were visually inspected through distribution plots. Genes with extremely low variance were identified for removal; in this case, none met the exclusion threshold. The dataset was split into training (80%) and test (20%) sets using stratified sampling to preserve label balance. In addition to the 80/20 stratified split, stratified 5-fold cross-validation was conducted for robust performance estimation. This ensured balanced label distribution across folds and reduced variance in metric reporting.
3.5. Model Training
Three classification models were trained:
Random Forest: 300 trees, depth of 10, class_weight = balanced.
Gradient Boosting: 200 estimators, learning rate 0.05, depth of 7.
Calibrated SVM: RBF kernel with probability calibration (sigmoid) and data standardization via StandardScaler.
Training was conducted on the stratified training set. Each model was evaluated independently on the held-out test set. Hyperparameters for each model were selected via randomized grid search within a 5-fold cross-validation setup on the training set. The optimal values—such as 300 estimators and depth = 10 for Random Forest—were chosen based on ROC-AUC performance stability.
3.6. Evaluation Metrics
Model performance was quantified using:
Visual diagnostics included:
Confusion matrices to reveal class-wise error patterns.
ROC curves to inspect sensitivity-specificity trade-offs.
Yellow brick-generated classification heatmaps.
All performance metrics were averaged across the 5 validation folds, with final model testing conducted on the holdout 20% set. This two-level evaluation ensured both internal consistency and fair generalization assessment.
3.7. Explainability: Feature & Local Importance
To ensure interpretability:
Permutation Importance (n = 10 repeats) ranked top contributors based on model score degradation.
Standard Feature Importances were extracted from tree-based models for visual comparison.
LIME (Local Interpretable Model-agnostic Explanations) was used to explain specific test samples. LIME decomposes model predictions into a weighted sum of interpretable features, which is useful for clinical transparency.
3.8. Clinical Report Generator
A custom reporting tool was implemented for individual-level explainability, producing:
Prediction and confidence score.
Visual summaries of top 10 features and gene markers.
Treatment response bars.
Clinical flagging for actionable features (e.g., low lithium response + GENE_1 signal).
A set of human-readable clinical recommendations.
This report simulates the usability of the model as a clinical decision support system.
4. Results and Visualization
This section presents the outcomes of the machine learning framework applied to the synthetically generated dataset. It encompasses visual distribution analysis, model performance metrics, feature importance evaluation, and interpretability-based clinical insights. The five figures included illustrate critical components of the pipeline: gene distributions, classifier performance, and interpretability metrics.
4.1. Feature Distribution Analysis
The distribution of the first 15 gene expression features is presented in Figure 2. Most features approximate Gaussian curves, yet a few exhibit distinctly non-normal or multimodal patterns. Notably:
Figure 2. Distribution histograms for the first 15 gene features, revealing Gaussian, skewed, and multimodal patterns.
GENE_1 displays a skewed bimodal distribution, reflecting the artificial signal injection for lithium response simulation.
GENE_6 and GENE_11 also show skewness and peaks that correspond to treatment-related transformations in the data generation stage.
Such patterns confirm that the synthetic data generation effectively introduces biological heterogeneity representative of real pharmacogenomic data.
4.2. Model Performance Evaluation
Model accuracy and diagnostic metrics were evaluated across Random Forest, Gradient Boosting, and Calibrated SVM classifiers [48] [49]. Random Forest was selected for initial visualization due to its interpretability and robust performance [50] [51].
The confusion matrix for the Random Forest classifier is shown in Figure 3, indicating a balanced prediction capability:
The ROC curve is presented in Figure 4, reflecting the model’s ability to discriminate between classes across thresholds. An area under the curve (AUC) of 0.80 confirms strong discriminative performance.
Additionally, a detailed classification report heatmap is illustrated in Figure 5. It reveals:
F1-score of 0.699 for the resistant class (label 1).
F1-score of 0.747 for the responsive class (label 0).
Balanced overall precision and recall across both categories.
Figure 3. Confusion matrix for Random Forest classifier showing model accuracy across treatment classes.
Figure 4. ROC curve for Random Forest showing an AUC of 0.80.
Figure 5. Classification report heatmap displaying per-class precision, recall, and F1-score for the Random Forest classifier.
4.3. Summary of Classifier Metrics
Model |
AUC |
F1 Score |
Balanced Accuracy |
Random Forest |
0.80 |
0.699 |
0.72 |
Gradient Boosting |
0.80 |
0.708 |
0.72 |
Calibrated SVM |
0.75 |
0.626 |
0.66 |
These results confirm that both tree-based ensemble models outperformed SVM, offering stronger generalization to unseen patient samples.
4.4. Feature Importance Analysis: Permutation Scores
(Random Forest)
A permutation importance analysis was conducted to interpret the underlying drivers of the Random Forest classifier. This method assesses the decrease in model performance when the values of a given feature are randomly permuted, thereby estimating the true dependency of the model on that feature. As shown in Figure 6, the most influential features include both genetic markers and clinical indicators. Specifically:
GENE_1 shows the highest importance with a substantial gap compared to all other features.
GENE_6, Rapid_Cycling, and treatment response scores such as Valproate_ Response and Lithium_Response also rank among the most impactful.
Clinical attributes like Age_Onset, Lamotrigine_Response, and BMI add moderate but meaningful contributions.
The results indicate that treatment resistance prediction is strongly driven by a blend of molecular and phenotypic factors. The boxplots represent the distribution of importance values across multiple permutation runs, capturing both the central tendency and variance of each feature’s influence. Features with narrow interquartile ranges and high mean importance, such as GENE_1, are considered the most stable and reliable predictors.
Figure 6. Permutation importance (Top 15 Features)—Random Forest Model. Box plots display the change in prediction accuracy when each feature is permuted. The most important features include GENE_1, GENE_6, Rapid_Cycling, and core treatment response scores. Higher values and tighter confidence intervals denote stronger and more stable feature influence.
4.5. Feature Importance Analysis: Tree-Based Scores
(Random Forest)
In addition to permutation-based evaluation, we extracted the built-in feature importance scores from the Random Forest model, based on the frequency and quality of feature splits in the decision trees.
As shown in Figure 7, the feature importance ranking largely overlaps with the permutation results. The most critical features remain:
GENE_1 (most decisive contributor).
GENE_6, Rapid_Cycling, and Lithium_Response.
Clinical markers such as Valproate_Response, Lamotrigine_Response, and Age_Onset.
This consistency across analytical methods strengthens confidence in the model’s biological grounding and highlights that both genetic and treatment-derived clinical features contribute significantly to model behavior.
Figure 7. Random forest feature importance (Top 15).
The bar chart in Figure 7 illustrates feature importance scores calculated from decision node contributions. Results align closely with permutation rankings, confirming the dominant role of GENE_1 and mood stabilizer response indicators.
4.6. Performance Evaluation: Gradient Boosting Classifier
To benchmark Random Forest against another ensemble method, we trained and evaluated a Gradient Boosting Classifier. The confusion matrix, shown in Figure 8, reveals a well-balanced classification outcome:
152 responsive and 136 resistant patients were correctly identified.
112 instances were misclassified, like the Random Forest model.
The matrix shows true positive and negative rates across treatment response classes. The model maintains consistent classification across both categories. The model’s ROC curve, presented in Figure 9, demonstrates strong discriminatory capacity, achieving an AUC of 0.80, nearly identical to that of Random Forest.
The model achieves an AUC of 0.80, indicating a high sensitivity and specificity trade-off across thresholds.
The classification report in Figure 10 confirms that the model performs comparably across both classes:
Gradient Boosting shows consistent metrics across classes, slightly improving on resistant class recall compared to Random Forest.
Figure 8. Confusion matrix—gradient boosting model.
Figure 9. ROC curve—gradient boosting classifier.
Figure 10. Classification metrics heatmap—gradient boosting.
4.7. Feature Importance Analysis: Permutation and Built-in Scores
(Gradient Boosting)
As with Random Forest, we examined both permutation importance and built-in feature scores for the Gradient Boosting model.
Figure 11. Permutation importance—gradient boosting (Top 15 Features).
Figure 11 displays the permutation-based results. Like prior findings, GENE_1, GENE_6, Rapid_Cycling, and the three drug response scores dominate the ranking. New entries, such as Illness_Duration, GENE_32, and GENE_24, suggest the Gradient Boosting model captures subtle temporal and genomic effects.
This plot highlights features that most affect model performance when permuted. Both genetic and temporal clinical variables were influential.
Figure 12 shows the standard Gradient Boosting feature importance scores. These reinforce previous findings, again led by GENE_1, GENE_6, and mood stabilizer response indicators.
Figure 12. Gradient boosting feature importance scores.
Top features remain consistent, with strong emphasis on GENE_1, GENE_6, Rapid_Cycling, and medication response metrics.
4.8. Calibrated SVM Performance and Local Explainability
To complement ensemble-based classifiers, a Calibrated Support Vector Machine (SVM) model was introduced [52]-[54]. The SVM was paired with Platt scaling to enable probabilistic outputs, which are essential for ROC curve evaluation and explainability integration such as LIME.
The confusion matrix in Figure 13 shows that the model correctly identified 150 responsive and 114 resistant patients. However, it also produced 64 false positives and 72 false negatives—more errors compared to the Random Forest and Gradient Boosting models.
Figure 13. Confusion matrix—calibrated SVM.
Figure 14. ROC Curve—Calibrated SVM.
The model shows slightly reduced performance in classifying treatment-resistant individuals, reflecting its linear margin limitations in high-dimensional biomedical data. The ROC curve shown in Figure 14 presents an AUC of 0.75, which, while acceptable, is noticeably lower than the AUC of 0.80 observed in tree-based models. The curve shape indicates moderate discrimination capacity, especially in mid-sensitivity ranges.
The AUC value of 0.75 indicates fair classification capability but suggests that the SVM model underperforms when distinguishing resistant vs. responsive cases in complex feature space.
The performance metrics in Figure 15 confirm this trend:
F1-score for resistant class: 0.626.
F1-score for responsive class: 0.688.
Overall accuracy: 66%.
Balanced accuracy: 65.69%.
Figure 15. Classification report – calibrated SVM.
Lower recall and F1-score in the resistant group confirm limited generalization power compared to ensemble methods. However, the calibrated output makes the model usable in probabilistic frameworks. To explore model decisions at the patient level, LIME (Local Interpretable Model-Agnostic Explanations) was used [55] [56]. Figure 16 presents a bar chart of feature contributions for patient #0, who was classified as treatment responsive by the Random Forest model with approximately 80% confidence.
The chart in Figure 16 shows how individual features contributed to reducing (red) or increasing (green) the likelihood of treatment resistance. Key variables include Rapid_Cycling, GENE_1, GENE_6, and Lithium_Response.
Insights from LIME:
Decreased resistance risk:
Rapid_Cycling ≤ 0.0
GENE_1 ≤ −0.70, GENE_6 > 0.66
High scores in Lithium_Response and Valproate_Response
Mild risk contributors:
GENE_11 > 0.64
Low BMI, presence of GENE_23, and elevated Illness_Duration
Figure 16. LIME explanation for sample 0.
These interpretations provide personalized transparency, reinforcing the clinical plausibility of the model and increasing its trustworthiness in psychiatric decision support.
4.9. Individual-Level Clinical Report and Actionable Insights
To translate predictive results into clinically actionable intelligence, we generated a full visual and interpretive report for patient 0, predicted by the Random Forest classifier to be treatment responsive. This integrated visualization, presented in Figure 17, combines feature-level insights, genetic expression data, treatment response estimations, and model-derived clinical recommendations. For interpretive clarity, we describe its five subpanels as Figures 17(a)-(e).
The Random Forest classifier predicted this patient to be treatment responsive, with a resistance probability of 19.80%, significantly below the clinical threshold. The prediction was correct, aligning with the true label. This affirms the model’s interpretability and real-world applicability in patient stratification.
Figure 17(a)—Top Predictive Featuresl: This subpanel displays the top 10 features by global importance score derived from the Random Forest model. It highlights GENE_1, GENE_6, and Rapid_Cycling as the most influential predictors. Notably, pharmacological response markers—Lithium_Response, Valproate_Response, and Lamotrigine_Response—also appear prominently, emphasizing the model’s balanced use of genetic and clinical features.
Figure 17. Clinical interpretation report for patient 0. (a) Top predictive features ranked by global importance. (b) Patient-level values for Top 10 features. (c) Predicted treatment response scores with resistance threshold. (d) Top genetic marker expression levels. (e) Model-based clinical recommendations.
Figure 17(b)—Patient Feature Values: This bar chart shows the actual values of patient 0 for the same top 10 features. The high values in GENE_6 and GENE_10 align with treatment responsiveness, while GENE_1’s low expression contributes negatively to resistance risk. The clinical indicator Rapid_Cycling is zero, a protective factor. This subpanel supports direct interpretability of the input vector that drove the model’s decision.
Figure 17(c)—Treatment Response Scores: This plot illustrates predicted scores for three core mood stabilizers: Lithium (0.86), Valproate (0.77), and Lamotrigine (0.77). All values lie well above the resistance threshold (0.3), represented by a red dashed line. This provides a strong therapeutic signal indicating that all three medications are likely to be effective in this individual case.
Figure 17(d)—Genetic Marker Expression: The genetic panel focuses on the expression levels of the top 5 genes. GENE_3 and GENE_4 show high expression and are typically correlated with positive outcomes. Conversely, GENE_1 and GENE_5 are under-expressed, both of which were associated with treatment resistance in broader model training. This provides a molecular justification for the model’s response prediction.
Figure 17(e)—Clinical Recommendations: Based on model inference and feature analysis, four clear, model-backed interventions were proposed:
1) Begin standard mood stabilizer regimen prioritizing lithium and lamotrigine.
2) Monitor early treatment progress to validate predicted efficacy.
3) Plan for maintenance phase due to promising response indicators.
4) Schedule structured psychiatric follow-ups to ensure continued adherence and outcome tracking.
This personalized set of recommendations demonstrates how machine learning can go beyond risk scores to directly support clinical decisions in psychiatric practice.
5. Discussion
This study demonstrates the feasibility and effectiveness of using interpretable machine learning models trained on synthetically generated, biologically informed datasets to predict treatment resistance in psychiatric conditions. The integration of pharmacogenomic and clinical features in a simulated but realistic data environment allowed us to capture key patterns observed in real-world psychiatric populations while overcoming common limitations such as missing values, small sample sizes, and privacy restrictions. Our results revealed that ensemble-based models—particularly Random Forest and Gradient Boosting—outperformed the Calibrated SVM in both overall classification performance and robustness across evaluation metrics. The Random Forest classifier achieved a balanced accuracy of 0.72 and an AUC of 0.80, indicating a strong ability to generalize across both treatment-resistant and responsive patient profiles. These findings highlight the suitability of tree-based models in high-dimensional biomedical settings, where variable interactions and non-linear relationships are common. The identification of key predictors such as GENE_1, GENE_6, Rapid_Cycling, and Lithium_Response across both traditional and permutation-based importance metrics reinforces the biological credibility of the synthetic dataset. These features are consistent with known pharmacogenomic and clinical determinants of mood stabilizer efficacy, lending face validity to the simulation approach. Moreover, the LIME explanations provided highly granular insights into individual predictions, effectively bridging the gap between model output and clinical reasoning. Such interpretability tools are critical for building clinician trust and facilitating the integration of AI systems into psychiatric decision-making workflows [57]-[59]. Importantly, the individualized clinical report developed in this study goes beyond abstract model metrics to demonstrate how machine learning predictions can be translated into patient-specific recommendations. This form of output is crucial for real-world applicability, particularly in complex domains like psychiatry where diagnostic ambiguity and treatment heterogeneity are common [60]-[62]. Nevertheless, while synthetic data provides a controlled environment for model development, future research must validate these findings using real-world patient cohorts. Incorporating longitudinal data, such as treatment timelines and symptom evolution, could further improve model precision and provide deeper insight into temporal treatment dynamics. Additionally, extending the framework to include multimodal inputs—such as neuroimaging, electronic health records, or wearable data—may enhance generalizability and clinical relevance. This work presents a replicable, interpretable, and clinically grounded machine learning framework for precision psychiatry, setting the stage for future translational AI research in mental health care.
6. Conclusion
This study presents a fully integrated, explainable machine learning framework for predicting treatment resistance in psychiatric disorders using a synthetically generated, multimodal dataset. By simulating realistic interactions between genetic markers, clinical variables, and pharmacological response indicators, we addressed a fundamental limitation in psychiatric AI research—the lack of large, high-quality, and privacy-compliant datasets [63] [64]. The proposed synthetic pipeline serves as a testbed for developing and validating predictive models that are both statistically rigorous and clinically interpretable. Among the models tested, Random Forest and Gradient Boosting consistently achieved strong performance, with ROC-AUC values reaching 0.80 and balanced accuracies exceeding 0.72. These results highlight the potential of ensemble learning to handle complex, non-linear relationships inherent in psychiatric data. Additionally, feature importance and LIME-based explanations ensured that the model’s decisions were transparent, reinforcing trust and enabling real-time clinical interpretation [65] [66]. The inclusion of a comprehensive, individualized clinical report further demonstrates how machine learning outputs can be translated into actionable insights at the patient level. This bridges the gap between data science and frontline psychiatry, facilitating personalized treatment planning informed by biological and clinical indicators [67] [68]. In conclusion, our framework offers a reproducible and interpretable approach to AI-driven precision psychiatry. It serves as a foundation for future research that incorporates real patient data, longitudinal trajectories, and multimodal signals to advance the clinical application of machine learning in mental health care.
Conflicts of Interest
The authors declare no conflicts of interest.