shubham680 commited on
Commit
d5164c7
·
verified ·
1 Parent(s): d2259a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -21
app.py CHANGED
@@ -71,7 +71,7 @@ with open("ohe_drain.pkl", "rb") as f:
71
  ohe_drain = pickle.load(f)
72
 
73
  with open("ohe_stage.pkl", "rb") as f:
74
- ohe_drain = pickle.load(f)
75
 
76
  with open("le.pkl", "rb") as f:
77
  le = pickle.load(f)
@@ -79,15 +79,23 @@ with open("le.pkl", "rb") as f:
79
  with open("knn.pkl", "rb") as f:
80
  knn = pickle.load(f)
81
 
82
- stage_encoded = ohe.transform([[stage_fear]])[0][0] # gender encoded using one hot encoding
83
- drain_encoded = ohe.transform([[drained]])[0][0]
84
 
85
 
86
  numeric_features = np.array([[time_spent, social_event, going_outside, friends, post_frequency]])
87
- scaled_features = rs.transform(numeric_features)
 
 
88
 
89
 
90
- final_input = np.concatenate(([gender_encoded], scaled_features[0])).reshape(1, -1)
 
 
 
 
 
 
91
 
92
 
93
  #input_data = np.array([[gender_encoded, age, urea, cr, HbA1c, chol, tg, hdl, ldl, vldl, bmi]])
@@ -96,19 +104,18 @@ final_input = np.concatenate(([gender_encoded], scaled_features[0])).reshape(1,
96
 
97
 
98
  prediction_labels = {
99
- 0: "Non-Diabetic",
100
- 1: "Diabetic",
101
- 2: "Pre-Diabetic"
102
  }
103
 
104
- # if st.button("Predict"):
105
- # prediction = knn.predict(final_input)[0]
106
- # result_label = prediction_labels.get(prediction, "Unknown")
107
- # st.success(f"Predicted Result: {result_label}")
108
- # if result_label == "Pre-Diabetic":
109
- # st.warning("You are in the pre-diabetic range. It's advisable to consult a healthcare professional for further evaluation.")
110
- # elif result_label == "Diabetic":
111
- # st.error("You are classified as diabetic. Please seek medical advice for appropriate management.")
112
 
113
 
114
 
@@ -126,11 +133,11 @@ if st.button("Predict"):
126
  unsafe_allow_html=True
127
  )
128
 
129
- # Message based on result
130
- if result_label == "Pre-Diabetic":
131
- st.warning("You are in the pre-diabetic range. It's advisable to consult a healthcare professional for further evaluation.")
132
- elif result_label == "Diabetic":
133
- st.error("You are classified as diabetic. Please seek medical advice for appropriate management.")
134
 
135
 
136
 
 
71
  ohe_drain = pickle.load(f)
72
 
73
  with open("ohe_stage.pkl", "rb") as f:
74
+ ohe_stage = pickle.load(f)
75
 
76
  with open("le.pkl", "rb") as f:
77
  le = pickle.load(f)
 
79
  with open("knn.pkl", "rb") as f:
80
  knn = pickle.load(f)
81
 
82
+ stage_encoded = ohe_stage.transform([[stage_fear]])[0] # gender encoded using one hot encoding
83
+ drain_encoded = ohe_drain.transform([[drained]])[0]
84
 
85
 
86
  numeric_features = np.array([[time_spent, social_event, going_outside, friends, post_frequency]])
87
+ scaled_features = rs.transform(numeric_features)[0]
88
+
89
+ st.write("Scaled Features:", scaled_features)
90
 
91
 
92
+ final_input = np.concatenate((
93
+ scaled_features[:1],
94
+ stage_encoded,
95
+ scaled_features[1:3],
96
+ drain_encoded,
97
+ scaled_features[3:]
98
+ )).reshape(1, -1)
99
 
100
 
101
  #input_data = np.array([[gender_encoded, age, urea, cr, HbA1c, chol, tg, hdl, ldl, vldl, bmi]])
 
104
 
105
 
106
  prediction_labels = {
107
+ 0: "Extrovert",
108
+ 1: "Introvert"
 
109
  }
110
 
111
+ if st.button("Predict"):
112
+ prediction = knn.predict(final_input)[0]
113
+ result_label = prediction_labels.get(prediction, "Unknown")
114
+ # st.success(f"Predicted Personality: {result_label}")
115
+ # if result_label == "Pre-Diabetic":
116
+ # st.warning("You are in the pre-diabetic range. It's advisable to consult a healthcare professional for further evaluation.")
117
+ # elif result_label == "Diabetic":
118
+ # st.error("You are classified as diabetic. Please seek medical advice for appropriate management.")
119
 
120
 
121
 
 
133
  unsafe_allow_html=True
134
  )
135
 
136
+ # # Message based on result
137
+ # if result_label == "Pre-Diabetic":
138
+ # st.warning("You are in the pre-diabetic range. It's advisable to consult a healthcare professional for further evaluation.")
139
+ # elif result_label == "Diabetic":
140
+ # st.error("You are classified as diabetic. Please seek medical advice for appropriate management.")
141
 
142
 
143