Page 129 - FULL REPORT 30012024
P. 129

Figure 4.51 Prediction function codes in flask application

                                  This  function  precisely  converts  user  inputs  into  a  format  that  can  be

                                  understood  by  a  machine.  Subsequently,  the  encoded  variables  are
                                  consolidated  into  a  well-organized  data  frame  that  conforms  to  the

                                  specifications of the prediction model. When the function is executed, it
                                  employs a pre-trained machine learning model to calculate the likelihood

                                  of a stroke occurrence. This likelihood is then converted into a percentage

                                  to indicate the user's risk of having a stroke.


                                  Once the ‘predict_stroke_risk’ function is used to calculate the stroke risks,
                                  it  takes  into  account  several  health  and  lifestyle  parameters  including

                                  gender,  age,  hypertension,  heart  disease,  BMI,  smoking  status,  marital

                                  status,  work  type,  and  residence  type.  The  resulting  risk  score  is  then
                                  classified as "low," "moderate," or "high." The category is determined by

                                  the  numerical  value  of  the  stroke  risk  score.  Based  on  the  risk
                                  categorization,  the  user's  BMI  is  assigned  to  one  of  four  categories:

                                  "underweight,"  "normal  weight,"  "overweight,"  or  "obesity."  The

                                  categorization is established based on conventional BMI thresholds.


                                                               112
   124   125   126   127   128   129   130   131   132   133   134