Skip to main content

Predicting and Preventing Mental Health Symptoms Using Machine Learning

Page 1


International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056

Volume: 13 Issue: 03 | Mar 2026 www.irjet.net p-ISSN: 2395-0072

Predicting and Preventing Mental Health Symptoms Using Machine Learning

1 Assistant Professor, Department of CSE, Teegala Krishna Reddy Engineering College, Telangana, India 2,3,4,5 B.Tech Students, Department of Computer Science and Engineering, Teegala Krishna Reddy Engineering College, Telangana, India ***

Abstract - Mental health issues such as stress, anxiety, and depression have become increasingly common in modern society due to lifestyle changes, work pressure, and social challenges. Early identification of mental health symptoms is important to prevent severe psychological problems and improve overall well-being. Traditional methods fordetecting mental health conditions mainly rely on surveys, clinical interviews, and counseling sessions, which are often timeconsuming, costly, and dependent on human judgment. These limitations make it difficult to provide timely support for a large number of individuals. Thisresearchproposesamachine learning–based system for predicting and preventing mental health symptoms by analyzing lifestyle and behavioral data. The system collects user inputs such as age, sleep hours, stress level, work hours, exercise habits, social interaction level, screen time, and diet quality. The collected data is processed using data preprocessing techniques including cleaning, normalization, and encoding. Multiple machine learning algorithms such as Logistic Regression, Random Forest, and Support Vector Machine (SVM) are used to train prediction models that classify the mental health condition of a user into categories such as healthy, moderate stress,orhighstress. The developed system is implemented using Python, machine learning libraries, and a Flask-based web application interface, allowing users to easily input their data and receive predictions in real time. In addition to prediction, the system provides preventive recommendations such as maintaining proper sleep patterns, engaging in regularexercise,practicing mindfulness, and reducing excessive screentime.Visualization tools such as charts are also used to present the prediction results clearly. The proposed system helps in earlydetection of mental health risks, enabling individuals to take preventive actions before the condition becomes severe. Compared to traditional approaches, the system is faster, cost-effective, scalable, and capable of assisting users in maintaining better mental health and well-being.

Key Words: Machine Learning, Mental Health Prediction, Stress Detection, Preventive RecommendationSystem,LogisticRegression,Random Forest, Support Vector Machine (SVM), Data Preprocessing,FlaskWebApplication,HealthAnalytics.

1.INTRODUCTION

Mental health disorders such as stress, anxiety, and depressionhavebecomesignificantpublichealthconcerns worldwide,affectingmillionsofpeopleandimpactingtheir dailylife,productivity,andsocialrelationships.Accordingto reports by the World Health Organization, factors such as increasedworkload,lackofsleep,socialisolation,unhealthy lifestylehabits,andexcessivescreentimehavecontributed totherapidriseinmentalhealthissues.Earlydetectionand prevention of these symptoms are essential to improve individualwell-beingandreducelong-termsocietalimpact. However, traditional methods used for identifying mental health conditions, including psychological surveys, questionnaires,counselingsessions,andclinicalinterviews, have several limitations. These methods are often timeconsuming, expensive, and dependent on trained professionals,andmanyindividualsavoidseekinghelpdue to social stigma or lack of awareness, leading to delayed diagnosisandtreatment

Recentadvancementsinartificialintelligenceandmachine learninghaveprovidednewopportunitiestoaddressthese challengesbyenablingefficientanalysisoflargevolumesof dataandidentificationofhiddenpatterns.Machinelearning techniquessuchasLogisticRegression,RandomForest,and SupportVectorMachinesarewidelyusedinhealthcarefor disease prediction, diagnosis support, and patient monitoringduetotheirabilitytolearnfromhistoricaldata and make accurate predictions. In the context of mental health, these models can analyze behavioral and lifestyle factors such as sleep patterns, stress levels, work hours, exercisehabits,socialinteraction,anddietqualitytoclassify individualsintocategoriessuchashealthy,moderatestress, or high stress. This predictive capability supports early detection and helps individuals take preventive actions beforetheconditionbecomessevere.

The objective of this research is to develop a machine learning–based system that predicts and prevents mental health symptoms using user lifestyle and behavioral data. Thesystemcollectsinputthroughawebinterface,processes the data using preprocessing techniques, and applies machine learning algorithms to determine mental health status. Additionally, it provides preventive recommendationssuchasimprovingsleephabits,practicing mindfulness,maintaininga balanceddiet,and engaging in

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056

Volume: 13 Issue: 03 | Mar 2026 www.irjet.net p-ISSN: 2395-0072

regularphysicalactivity.Thisapproachaimstoofferafaster, cost-effective,andaccessiblesolutionforsupportingmental healthawarenessandearlyintervention.

2. PROPOSED SYSTEM

The proposed system is designed to predict and prevent mentalhealthsymptomsusingmachinelearningtechniques byanalyzinguserlifestyleandbehavioralfactorssuchasage, sleephours,stresslevel,workhours,exercisehabits,social interactionlevel,screentime,anddietquality.Basedonthis data, machine learning models are trained to identify patternsandclassifytheuser’smentalhealthconditioninto categoriessuchashealthy,moderatestress,orhighstress. Theprimaryobjectiveofthesystemisearlydetectionand prevention of mental health issues, enabling users to take timely action through preventive suggestions such as maintaining a healthy routine, improving sleep patterns, practicing mindfulness, and engaging in regular physical activity. The system is implemented as a web-based application using Flask, which provides an interactive interfaceforuserstoinputtheirdetailsandreceivereal-time prediction results along with graphical visualizations for betterunderstanding.

The system architecture consists of two main layers: the WebApplicationLayerandtheMachineLearningLayer.In theWebApplicationLayer,usersinteractwiththesystem throughauser-friendlyinterfacethatcollectslifestyleand behavioral data, which is then stored in the database for further processing. This layer includes the User Interface, Data Collection Module, and Preventive Recommendation Module. The Machine Learning Layer is responsible for processingandanalyzingthedata,wherethecollectedinput isfirstcleanedandpreparedusingtheDataPreprocessing Modulebyhandlingmissing values,normalizingdata,and converting categorical values into numerical format. The processeddataisthenusedintheModelTrainingModule, where algorithms such as Logistic Regression, Random Forest, and Support Vector Machine are applied to learn patternsandrelationshipswithinthedataset.Aftertraining, theModelEvaluationModuleassessestheperformanceof each algorithm using metrics such as accuracy, precision, and recall, and selects the best performing model. The PredictionModulethenusesthistrainedmodeltoanalyze newuserinputsandgeneratepredictionresults.Finally,the results are sent back to the web application, where the systemdisplaysthepredictedmentalhealthconditionand providespersonalizedpreventiverecommendationssuchas improvingsleephabits,engaginginexercise,reducingscreen time, and adopting a healthier lifestyle, thereby helping usersmanagestressandmaintainbettermentalwell-being.

3. IMPLEMENTATION DETAILS

The proposed system is implemented using Python along withmachinelearningandwebdevelopmentlibraries,andit is developed as a web-based application using the Flask framework. This allows users to interact with the system

throughabrowserinterfaceandreceivereal-timeprediction results. The system operates on a local server where user inputdataisprocessedandanalyzedefficiently.Thedataset used in the system consists of various lifestyle and behavioralfactorssuchasage,sleephours,stresslevel,work hours,exercisehabits,socialinteractionlevel,screentime, anddietquality,whicharecollectedthroughauser-friendly webinterface.Beforeapplyingmachinelearningalgorithms, thedataundergoespreprocessingstepsincludinghandling missing values, removing duplicate entries, normalizing numerical values,andencodingcategorical data toensure bettermodelperformance.

Multiple machine learning algorithms such as Logistic Regression, Random Forest, and Support Vector Machine (SVM)areimplementedusingtheScikit-learnlibrarytotrain the prediction model. These algorithms analyze the relationshipbetweenuserlifestylefactorsandmentalhealth conditionstoclassifyusersintocategoriessuchasHealthy, ModerateStress,orHighStress.Theperformanceofthese models is evaluated, and the best-performing model is selected for prediction. The web application interface is designed using HTML, CSS, and Bootstrap, providing a simpleandresponsiveuserexperience.Whenausersubmits theirdata,theFlaskbackendprocessestheinputandsends ittothetrainedmodel,whichgeneratesthepredictionresult and displays it on the webpage along with preventive suggestions.Additionally,thesystemincludesvisualization features such as pie charts to represent the probability distributionofmentalhealthconditions,makingtheresults easiertounderstand.

Table 1: Key Machine Learning Algorithms Used Algorithm Purpose

LogisticRegression Predicts probability of mental healthcondition

RandomForest Improves accuracy using multiple decisiontrees

SupportVectorMachine (SVM) Classifiescomplexpatternsindata

4. RESULTS AND PERFORMANCE ANALYSIS

4.1 Prediction Results of the System

The proposed machine learning system was tested using various input values representing different lifestyle and behavioral factors such as sleep hours, stress level, work hours, exercise habits, social interaction, screen time, and diet quality. The system successfully processed the user inputdataandpredictedthementalhealthconditionbased onthetrainedmachinelearningmodels.

The prediction results classify the user’s mental health conditionintocategoriessuchasHealthy,ModerateStress, and High Stress. The system provides the result instantly

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056

Volume: 13 Issue: 03 | Mar 2026 www.irjet.net p-ISSN: 2395-0072

after the user submits the input form through the web interface.Thisdemonstratesthattheproposedsystemcan effectively analyze lifestyle patterns and provide early identificationofpotentialmentalhealthsymptoms.

The results show that the system is capable of analyzing user-provideddataandgeneratingpredictionsinrealtime. Thesimpleandinteractivewebinterfacemakesthesystem easy to use and accessible to users without technical knowledge.

4.2 Visualization of Mental Health Prediction

Toimproveuserunderstanding,thesystemalsogenerates graphical representations of the prediction results. Visualization techniques such as pie charts are used to display the probability distribution of different mental healthconditions. Thishelpsusersclearlyunderstandthe predictionoutputandthelikelihoodofeachmentalhealth category.

The pie chart visualization represents the predicted probabilitiesfordifferentmentalhealthconditions,allowing users to easily interpret the results and understand their mental health status. The graphical output improves the overallusabilityofthesystemandallowsuserstoquickly interpret the results without needing detailed technical knowledge.

4.3 Performance Evaluation of Machine Learning Models

Theperformanceofdifferentmachinelearningalgorithms such as Logistic Regression, Random Forest, and Support VectorMachine(SVM)wasevaluatedusingthedataset.The models were trained using the prepared dataset after preprocessing and were tested to measure their classificationperformance.

Evaluation metrics such as accuracy, precision, and recall were considered for analyzing the model performance. Amongtheimplementedmodels,ensemble-basedmethods like Random Forest generally provided higher prediction accuracyduetotheirabilitytohandlecomplexpatternsin thedataset.

Table 4: Performance Comparison of Machine Learning Models

Model Accuracy (%)

LogisticRegression 85%

SupportVectorMachine88%

RandomForest 92%

TheresultsshowthattheRandomForestalgorithmachieved thehighestaccuracy,makingitthemostsuitablemodelfor predictingmentalhealthsymptomsinthissystem.

Fig - 1: User Input Interface and Mental Health Prediction Result
Fig - 2: Pie Chart Visualization of Mental Health Prediction

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056

Volume: 13 Issue: 03 | Mar 2026 www.irjet.net p-ISSN: 2395-0072

5. CONCLUSIONS

Mentalhealthissuessuchasstress,anxiety,anddepression arebecomingincreasinglycommonduetomodernlifestyle pressures and social challenges. Early detection of these symptoms is essential to prevent serious psychological problemsandimproveoverallwell-being.Traditionalmental healthassessmentmethodsoftenrelyonsurveysandclinical evaluations,whichcanbetime-consuming,expensive,and limitedinaccessibility.Inthisresearch,amachinelearning–basedsystemforpredictingandpreventingmentalhealth symptomswasdeveloped.Thesystemanalyzesuserlifestyle andbehavioralfactorssuchassleeppatterns,stresslevels, workhours,exercisehabits,socialinteraction,screentime, and diet quality. Machine learning algorithms including Logistic Regression, Random Forest, and Support Vector Machine(SVM)wereimplementedtoclassifymentalhealth conditions. The system was integrated into a Flask-based web application, allowing users to easily enter their information and receive prediction results instantly. In additiontopredictingmentalhealthstatus,thesystemalso provides preventive recommendations such as improving sleep habits, practicing mindfulness, engaging in physical activity, and maintaining a balanced lifestyle. The results demonstrate that the proposed system can effectively predict mental health conditions and provide useful preventiveguidance.Comparedtotraditional approaches, the system offers advantages such as faster prediction, improved accessibility, cost-effectiveness, and early detection of mental health risks. Overall, the proposed machinelearning-basedsolutionhighlightsthepotentialof artificialintelligenceinsupportingmentalhealthawareness andprevention.Thesystemcanserveasasupportivetoolto helpindividualsmonitortheirmental well-beingand take proactivestepstowardmaintainingahealthylifestyle.

6. FUTURE WORK

Althoughtheproposedsystemsuccessfullypredictsmental healthsymptomsusingmachinelearningtechniques,there are several opportunities for further improvement and expansion.Futureworkcanfocusonenhancingthesystem’s accuracy,scalability,andreal-worldapplicability.

One possible improvement is the use of larger and more diverse datasets collected from different populations and environments.Thiswillhelpthemachinelearningmodels learn more complex patterns and improve prediction accuracy. Incorporating real-time data from wearable devices such as smartwatches or fitness trackers can also provide more reliable information about sleep patterns, physicalactivity,andheartrate.Anotherareaoffuturework istheintegrationofadvanceddeeplearningtechniquessuch asneuralnetworksandnaturallanguageprocessing(NLP). Thesetechniquescananalyzetextdatafromuserfeedback, socialmediaposts,orpersonaljournalstodetectemotional patterns and provide more accurate mental health predictions.Thesystemcanalsobeexpandedbydeveloping amobileapplicationthatallowsuserstoeasilymonitortheir

mental health anytime and anywhere. A mobile-based system can provide notifications, reminders, and personalized recommendations to encourage healthy lifestylehabits.Additionally,futureversionsofthesystem canincludedirectintegrationwithhealthcareprofessionals or counseling services, allowing users to connect with mental health experts if the system detects a high risk of mentalhealthproblems.Thiswouldmakethesystemmore usefulasasupportivehealthcaretool.

REFERENCES

[1]T.DavenportandR.Kalakota,“Thepotentialforartificial intelligenceinhealthcare,”FutureHealthcareJournal,vol.6, no.2,pp.94–98,2019.

[2]S.Shatte,D.Hutchinson,andS.Teague,“Machinelearning in mental health: A scoping review of methods and applications,” Psychological Medicine, vol. 49, no. 9, pp. 1426–1448,2019.

[3] J. B. Allen, R. Chambers, and G. Knight, “Mindfulnessbasedpsychotherapies:Areviewofconceptualfoundations, empiricalevidenceandpracticalconsiderations,”Australian &NewZealandJournalofPsychiatry,vol.40,no.4,pp.285–294,2018.

[4] C. C. Aggarwal, Machine Learning for Healthcare Applications.Springer,2020.

[5]I.Goodfellow,Y.Bengio,andA.Courville,DeepLearning MITPress,2016.

[6] P. Pedregosa et al., “Scikit-learn: Machine Learning in Python,”JournalofMachineLearningResearch,vol.12,pp. 2825–2830,2011.

[7] F. Chollet, Deep Learning with Python. Manning Publications,2018.

[8]A.Géron,Hands-OnMachineLearningwithScikit-Learn, Keras,andTensorFlow.O’ReillyMedia,2019.

Turn static files into dynamic content formats.

Create a flipbook