Journal of Artificial Intelligence and Metaheuristics

A Metaheuristic-Optimized Deep Learning Framework for Accurate Classification of Obsessive–Compulsive Disorder Using Clinical Data Based on the Ninja Optimization Algorithm

Safaa Zaman, El-Sayed M. El-Kenawy
Volume 11, Issue 1, pp. 32–36 (2026)
DOI: https://doi.org/10.54216/JAIM.110103
Online: https://americaspg.com/journal/28/article/4261

Abstract

The growing prevalence and clinical complexity of Obsessive–Compulsive Disorder (OCD) motivate the need for reliable, data-driven decision-support systems capable of improving diagnostic accuracy and robustness beyond traditional assessment methods. In this study, we propose an optimized deep learning framework that integrates a Deep Learning framework distilled by Gradient Boosting Decision Trees (DeepGBM) with a novel metaheuristic optimizer, the Ninja Optimization Algorithm (NiOA), to enhance OCD-related classification using structured demographic and clinical data. The main contribution of this work lies in the design of a unified optimization pipeline in which NiOA is employed for automated hyperparameter tuning of DeepGBM, and in the comprehensive comparison of this approach against baseline deep learning models and alternative metaheuristic optimizers, including Multiverse Optimization (MVO), Bat Algorithm (BA), and Particle Swarm Optimization (PSO). Experimental evaluation demonstrates that, at the baseline stage, DeepGBM outperforms Artificial Neural Networks (ANN), Convolutional Neural Networks (CNN), and Bidirectional Long Short-Term Memory networks (BiLSTM), achieving an accuracy of 0.8970 and an F-score of 0.8935. Following optimization, the proposed NiOA+DeepGBM framework achieves substantial performance gains, reaching an accuracy of 0.9779, sensitivity of 0.9763, specificity of 0.9793, and an F-score of 0.9770, consistently surpassing MVO+DeepGBM, BA+DeepGBM, and PSO+DeepGBM across all evaluation metrics. These results confirm the superior capability of NiOA in navigating complex hyperparameter spaces and enhancing both predictive accuracy and generalization. The implications of this work are significant for intelligent mental health assessment, as the proposed NiOA-optimized DeepGBM model offers a robust, clinically relevant decision-support tool that can assist clinicians in improving diagnostic reliability, reducing uncertainty, and supporting the development of scalable, AI-driven mental healthcare systems.

Keywords: Obsessive–Compulsive Disorder; DeepGBM; Ninja Optimization Algorithm; Metaheuristic Optimization; Clinical Decision Support Systems

1. INTRODUCTION

chine learning and deep learning, provides promising opportunities for improving clinical decision-making in OCD assessment.

Mental health disorders constitute a major global health concern, exerting profound and long-lasting effects on individuals, healthcare systems, and societies. Within this landscape, Obsessive–Compulsive Disorder (OCD) is particularly challenging because of its chronic nature, symptom variability, and frequent comorbidity with other mental health disorders. The integration of data-driven methodologies, especially ma-

OCD is characterized by persistent intrusive thoughts (obsessions) and repetitive behaviours or mental acts (compulsions) performed to reduce distress. The disorder often follows a chronic course, with symptoms fluctuating in severity over time, and is frequently associated with functional impairment, reduced quality of life, and elevated risk of depression and anxiety. From a societal perspective, OCD imposes a substantial economic burden through healthcare use, productivity loss, and long-term disability.

Accurate and timely diagnosis remains difficult in clinical practice. Traditional approaches rely heavily on clinical interviews and standardized rating scales, which are valuable but subjective and dependent on clinician expertise. Predictive modelling can augment conventional assessment by systematically analysing patient data and supporting evidence-based decision-making.

This paper develops a unified framework in which DeepGBM is optimized using NiOA. The key contributions are: (i) a clinical-data-driven OCD classification pipeline; (ii) automated hyperparameter tuning using NiOA; (iii) comparison with ANN, CNN, BiLSTM, and DeepGBM baselines; and (iv) comparison with MVO, BA, and PSO optimized variants under the same evaluation protocol.

2. LITERATURE REVIEW

Research on OCD increasingly uses machine learning and deep learning to address limitations of conventional clinical assessment. Neuroimaging-based models have demonstrated the potential of structural MRI, functional MRI, resting-state connectivity, and EEG-derived biomarkers for identifying OCD-related patterns. Other studies have used demographic, behavioural, and symptom-level data to predict severity, remission, comorbid depression, and long-term clinical course.

Deep learning architectures are attractive because they can model nonlinear interactions among heterogeneous predictors. ANN, CNN, recurrent models, and hybrid architectures have been applied to psychiatric prediction tasks; however, these models are often sensitive to hyperparameter settings and may suffer from overfitting when data are limited. Ensemble and gradient-boosting approaches provide strong tabular-data performance, while model distillation strategies can combine representation learning with decision-tree interpretability and robustness.

Metaheuristic optimization algorithms are increasingly used for feature selection and hyperparameter tuning. Populationbased algorithms such as PSO, MVO, BA, and NiOA are useful when objective functions are nonlinear, multimodal, and not analytically differentiable. Their role is particularly important in clinical decision-support systems, where robust generalization is more important than merely minimizing training error.

3. METHODOLOGY

The proposed methodology combines structured clinical data preprocessing, baseline deep learning classification, Deep-GBM modelling, and metaheuristic optimization. The framework is designed to classify OCD-related clinical records while improving generalization through automated hyperparameter search.

3.1 Problem Formulation

Let X ∈Rm×n denote a clinical dataset containing m patient records and n demographic or clinical attributes, and let y ∈ {0,1}m denote the target class labels. The task is to learn a classifier f : X →y (1) that maximizes predictive performance on unseen patient records while maintaining robustness across sensitivity, specificity, and predictive-value metrics.

3.2 DeepGBM Classification Model

DeepGBM combines deep representation learning with Gradient Boosting Decision Trees. The deep component maps each input vector xi into a latent representation:

hi = φ(Wxi +b), (2) where φ(·) is a nonlinear activation function, W is a weight matrix, and b is a bias vector. The gradient boosting component then learns an additive model:

M ∑ m=1

η fm(x), (3)

FM(x) = where M is the number of trees, fm is the mth weak learner, and η is the learning rate.

3.3 Ninja Optimization Algorithm

NiOA is used as the main hyperparameter optimization strategy. Each candidate solution represents a set of DeepGBM hyperparameters, including learning rate, number of estimators, tree depth, regularization terms, and neural representation parameters. The optimization objective is formulated as z∗= argmax

�  z∈ΩF , (4)

DeepGBM(z) where Ωis the search space and F is the validation performance criterion.

3.4 NiOA Pseudocode

The NiOA procedure used in the study can be summarized as follows.

1. Initialize the population size N, maximum iterations T, candidate positions, control parameters, mutation parameter, velocity factor, and best solution Bs.

2. Set the iteration counter t = 0.

3. Evaluate the fitness of all candidate hyperparameter vectors using validation performance.

4. Update candidate positions through exploration and exploitation operators.

5. Apply mutation and stagnation-control mechanisms to avoid premature convergence.

6. Update the best solution whenever a candidate improves the objective value.

7. Repeat until t = T, then return the best DeepGBM hyperparameter vector.

4. EXPERIMENTAL SETUP

The experimental design evaluates baseline deep learning models and optimized DeepGBM variants on OCD-related structured clinical data. The compared baseline models are ANN, CNN, BiLSTM, and DeepGBM. The optimized models combine DeepGBM with NiOA, MVO, BA, and PSO. All models are evaluated using accuracy, sensitivity, specificity, positive predictive value, negative predictive value, and Fscore. Figures 1–3 present the principal exploratory data visualizations reported before model evaluation.

Figure 1. Distribution of patients with and without clinical diagnoses of anxiety and depression.
Figure 1. Distribution of patients with and without clinical diagnoses of anxiety and depression.
Figure 2. Scatter plot illustrating the relationship between symptom duration and Y-BOCS total score.
Figure 2. Scatter plot illustrating the relationship between symptom duration and Y-BOCS total score.
Figure 3. Histogram illustrating the age distribution of patients included in the study.
Figure 3. Histogram illustrating the age distribution of patients included in the study.

4.1 Evaluation Metrics

Table 1. gives the formal metric definitions used throughout the experimental analysis.

5. RESULTS AND DISCUSSION

This section presents the baseline and optimized classification results. The baseline stage establishes the relative strength of DeepGBM, while the optimization stage evaluates the impact of metaheuristic tuning.

5.1 Baseline Deep Learning Results

DeepGBM achieves the strongest baseline results, with accuracy of 0.8970 and F-score of 0.8935. BiLSTM ranks second, followed by CNN and ANN. Table 2 summarizes

Table 1. Classification evaluation metrics and mathematical definitions.
Table 1. Classification evaluation metrics and mathematical definitions.

Accuracy TP+TN TP+TN +FP+FN Sensitivity (TPR) TP TP+FN Specificity (TNR) TN TN +FP PPV TP TP+FP NPV TN TN +FN F-Score 2TP 2TP+FP+FN the reported baseline results, while Figures 4–6 visualize the same baseline comparisons.

Table 2. Baseline performance of deep learning models before optimization.
Table 2. Baseline performance of deep learning models before optimization.

Model Accuracy Sensitivity Specificity PPV NPV F-Score DeepGBM 0.897009967 0.890410959 0.903225806 0.896551724 0.897435897 0.893470790 BiLSTM 0.885135135 0.875000000 0.894736842 0.887323944 0.883116883 0.881118881 CNN 0.872727273 0.861111111 0.883720930 0.873239437 0.872093023 0.867132867 ANN 0.859060403 0.849315068 0.868279570 0.861111111 0.857142857 0.855172414

Figure 4. Heatmap visualization of performance metrics for four classification models: DeepGBM, BiLSTM, CNN, and ANN.
Figure 4. Heatmap visualization of performance metrics for four classification models: DeepGBM, BiLSTM, CNN, and ANN.

5.2 Optimized DeepGBM Results

After hyperparameter optimization, NiOA+DeepGBM obtains the highest performance across all metrics. It achieves an accuracy of 0.977851463, sensitivity of 0.976301736, specificity of 0.979294908, PPV of 0.977737665, NPV of 0.977957156, and F-score of 0.977019173. These values demonstrate that NiOA improves both positive-class detection and negative-class discrimination. Table 3 reports the optimized scores.

Table 3. Performance comparison of optimized DeepGBM models using different metaheuristic algorithms.
Table 3. Performance comparison of optimized DeepGBM models using different metaheuristic algorithms.

Model Accuracy Sensitivity Specificity PPV NPV F-Score NiOA + DeepGBM 0.977851463 0.976301736 0.979294908 0.977737665 0.977957156 0.977019173 MVO + DeepGBM 0.967023521 0.962031811 0.971223021 0.968859649 0.965812000 0.965433403 BA + DeepGBM 0.953961973 0.949275362 0.958762887 0.955056180 0.953846154 0.952156057 PSO + DeepGBM 0.944259568 0.938405797 0.950354610 0.944525547 0.944444444 0.941455697

After hyperparameter optimization, Figures 7–9 provide the corresponding visual comparison for the DeepGBM variants optimized by NiOA, MVO, BA, and PSO.

Figure 8. Correlation heatmap of optimized classification performance metrics with hierarchical clustering.
Figure 8. Correlation heatmap of optimized classification performance metrics with hierarchical clustering.
Figure 5. Pairplot visualization of baseline classification performance metrics, including accuracy, sensitivity, specificity, PPV, NPV, and F-score.
Figure 5. Pairplot visualization of baseline classification performance metrics, including accuracy, sensitivity, specificity, PPV, NPV, and F-score.
Figure 9. Pairwise kernel density estimation plot of optimized model performance metrics.
Figure 9. Pairwise kernel density estimation plot of optimized model performance metrics.
Figure 6. Kernel density estimation plots comparing the distributions of baseline classification performance metrics.
Figure 6. Kernel density estimation plots comparing the distributions of baseline classification performance metrics.

The improvement produced by NiOA is clinically meaningful. In psychiatric applications, false negatives may delay treatment and false positives may lead to unnecessary interventions. The simultaneous improvement in sensitivity and specificity therefore indicates that the optimized model is better balanced than baseline and alternative optimized variants. The results also suggest that NiOA provides a stronger exploration–exploitation balance in the complex hyperparameter landscape of DeepGBM.

Figure 7. Bar chart comparison of classification performance metrics for four hybrid DeepGBM models.
Figure 7. Bar chart comparison of classification performance metrics for four hybrid DeepGBM models.

6. CONCLUSION

This paper presents a metaheuristic-optimized deep learning framework for OCD classification using structured clinical data. The proposed NiOA+DeepGBM model substantially improves over baseline deep learning models and alternative optimized variants. Baseline DeepGBM achieves an accuracy of 0.8970 and F-score of 0.8935, while NiOA-optimized DeepGBM reaches 0.9779 accuracy and 0.9770 F-score. Sensitivity and specificity also improve to 0.9763 and 0.9793, respectively.

The findings indicate that integrating NiOA with DeepGBM provides an effective, robust, and clinically relevant decisionsupport model. Future work should evaluate the framework on larger multi-centre datasets, include multimodal sources such as neuroimaging and electronic health records, and investigate deployment constraints for real-time mental healthcare applications.

References

[1] World Health Organization, World Mental Health Report: Transforming Mental Health for All. Geneva, Switzerland: WHO, 2022.

[2] B. Stahnke, “A systematic review of misdiagnosis in those with obsessive-compulsive disorder,” Journal of Affective Disorders Reports, vol. 6, p. 100231, 2021.

[3] F.-F. Huang et al., “Functional and structural MRI based obsessive-compulsive disorder diagnosis using machine learning methods,” BMC Psychiatry, vol. 23, no. 1, p. 792, 2023.

[4] B. A. Zaboski and L. Bednarek, “Precision psychiatry for obsessive-compulsive disorder: Clinical applications of deep learning architectures,” Journal of Clinical Medicine, vol. 14, no. 7, p. 2442, 2025.

[5] B. A. Zaboski, A. Wilens, J. P. McNamara, and G. N. Muller, “Predicting OCD severity from religiosity and personality: A machine learning and neural network approach,” Journal of Mood & Anxiety Disorders, vol. 8, p. 100089, 2024.

[6] M. Grassi et al., “Prediction of illness remission in patients with obsessive-compulsive disorder with supervised machine learning,” Journal of Affective Disorders, vol. 296, pp. 117–125, 2022.

[7] C. Segalas et al., “Cognitive and clinical predictors of a long-term course in obsessive compulsive disorder: A machine learning approach in a prospective cohort study,” Journal of Affective Disorders, vol. 350, pp. 648– 655, 2024.

[8] W. B. Bruin et al., “The functional connectome in obsessive-compulsive disorder: Resting-state megaanalysis and machine learning classification for theENIGMA-OCD consortium,” Molecular Psychiatry, vol. 28, no. 10, pp. 4307–4319, 2023.

[9] S. Hinduja et al., “Multimodal prediction of obsessivecompulsive disorder and comorbid depression severity and energy delivered by deep brain electrodes,” IEEE Transactions on Affective Computing, vol. 15, no. 4, pp. 2025–2041, 2024.

[10] Z. Zhao et al., “Exploring potential resting-state EEG biomarkers of obsessive-compulsive disorder based on explainable machine learning analysis,” BMC Psychiatry, vol. 25, no. 1, p. 1164, 2025.