DreamStream-1 commited on
Commit
efd527a
·
verified ·
1 Parent(s): 50edc65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -17
app.py CHANGED
@@ -60,24 +60,24 @@ def load_data():
60
  except FileNotFoundError:
61
  raise RuntimeError("Data files not found. Please ensure `Training.csv` and `Testing.csv` are uploaded correctly.")
62
 
63
- # Encode diseases
64
  disease_dict = {
65
  'Fungal infection': 0, 'Allergy': 1, 'GERD': 2, 'Chronic cholestasis': 3, 'Drug Reaction': 4,
66
- 'Peptic ulcer diseae': 5, 'AIDS': 6, 'Diabetes ': 7, 'Gastroenteritis': 8, 'Bronchial Asthma': 9,
67
  'Hypertension ': 10, 'Migraine': 11, 'Cervical spondylosis': 12, 'Paralysis (brain hemorrhage)': 13,
68
- 'Jaundice': 14, 'Malaria': 15, 'Chicken pox': 16, 'Dengue': 17, 'Typhoid': 18, 'hepatitis A': 19,
69
  'Hepatitis B': 20, 'Hepatitis C': 21, 'Hepatitis D': 22, 'Hepatitis E': 23, 'Alcoholic hepatitis': 24,
70
- 'Tuberculosis': 25, 'Common Cold': 26, 'Pneumonia': 27, 'Dimorphic hemmorhoids(piles)': 28,
71
  'Heart attack': 29, 'Varicose veins': 30, 'Hypothyroidism': 31, 'Hyperthyroidism': 32,
72
- 'Hypoglycemia': 33, 'Osteoarthritist': 34, 'Arthritis': 35,
73
- '(vertigo) Paroymsal Positional Vertigo': 36, 'Acne': 37, 'Urinary tract infection': 38,
74
  'Psoriasis': 39, 'Impetigo': 40
75
  }
76
 
77
  # Replace prognosis values with numerical categories
78
  df.replace({'prognosis': disease_dict}, inplace=True)
79
 
80
- # Check unique values in prognosis for debugging
81
  print("Unique values in prognosis after mapping:", df['prognosis'].unique())
82
 
83
  # Ensure prognosis is purely numerical after mapping
@@ -91,8 +91,10 @@ def load_data():
91
  # Similar process for the testing data
92
  tr.replace({'prognosis': disease_dict}, inplace=True)
93
 
94
- # Ensure it is also numerical
95
- if tr['prognosis'].dtype == 'object':
 
 
96
  raise ValueError(f"Testing data prognosis contains unmapped values: {tr['prognosis'].unique()}")
97
 
98
  tr['prognosis'] = tr['prognosis'].astype(int) # Convert to integer if necessary
@@ -109,7 +111,7 @@ y_test = tr['prognosis']
109
 
110
  # Encode the target variable with LabelEncoder if still in string format
111
  le = LabelEncoder()
112
- y_encoded = le.fit_transform(y) # Needs to be string labels, assuming df['prognosis'] has no numerical labels
113
 
114
  def train_models():
115
  models = {
@@ -233,7 +235,6 @@ def get_health_professionals_and_map(location, query):
233
  popup=f"{place['name']}"
234
  ).add_to(map_)
235
  return professionals, map_._repr_html_()
236
-
237
  return [], "" # Return empty list if no professionals found
238
  except Exception as e:
239
  return [], "" # Return empty list on exception
@@ -293,12 +294,6 @@ textarea:focus, input:focus {
293
  outline: none;
294
  }
295
 
296
- textarea:hover, input:hover {
297
- background: transparent;
298
- color: black;
299
- border: 2px solid orange;
300
- }
301
-
302
  .df-container {
303
  background: white;
304
  color: black;
 
60
  except FileNotFoundError:
61
  raise RuntimeError("Data files not found. Please ensure `Training.csv` and `Testing.csv` are uploaded correctly.")
62
 
63
+ # Encode diseases in a dictionary
64
  disease_dict = {
65
  'Fungal infection': 0, 'Allergy': 1, 'GERD': 2, 'Chronic cholestasis': 3, 'Drug Reaction': 4,
66
+ 'Peptic ulcer disease': 5, 'AIDS': 6, 'Diabetes ': 7, 'Gastroenteritis': 8, 'Bronchial Asthma': 9,
67
  'Hypertension ': 10, 'Migraine': 11, 'Cervical spondylosis': 12, 'Paralysis (brain hemorrhage)': 13,
68
+ 'Jaundice': 14, 'Malaria': 15, 'Chicken pox': 16, 'Dengue': 17, 'Typhoid': 18, 'Hepatitis A': 19,
69
  'Hepatitis B': 20, 'Hepatitis C': 21, 'Hepatitis D': 22, 'Hepatitis E': 23, 'Alcoholic hepatitis': 24,
70
+ 'Tuberculosis': 25, 'Common Cold': 26, 'Pneumonia': 27, 'Dimorphic hemorrhoids(piles)': 28,
71
  'Heart attack': 29, 'Varicose veins': 30, 'Hypothyroidism': 31, 'Hyperthyroidism': 32,
72
+ 'Hypoglycemia': 33, 'Osteoarthritis': 34, 'Arthritis': 35,
73
+ '(vertigo) Paroxysmal Positional Vertigo': 36, 'Acne': 37, 'Urinary tract infection': 38,
74
  'Psoriasis': 39, 'Impetigo': 40
75
  }
76
 
77
  # Replace prognosis values with numerical categories
78
  df.replace({'prognosis': disease_dict}, inplace=True)
79
 
80
+ # Print unique values for debugging
81
  print("Unique values in prognosis after mapping:", df['prognosis'].unique())
82
 
83
  # Ensure prognosis is purely numerical after mapping
 
91
  # Similar process for the testing data
92
  tr.replace({'prognosis': disease_dict}, inplace=True)
93
 
94
+ # Print unique values for testing data
95
+ print("Unique values in prognosis for testing data after mapping:", tr['prognosis'].unique())
96
+
97
+ if tr['prognosis'].dtype == 'object': # Check for unmapped entries
98
  raise ValueError(f"Testing data prognosis contains unmapped values: {tr['prognosis'].unique()}")
99
 
100
  tr['prognosis'] = tr['prognosis'].astype(int) # Convert to integer if necessary
 
111
 
112
  # Encode the target variable with LabelEncoder if still in string format
113
  le = LabelEncoder()
114
+ y_encoded = le.fit_transform(y) # Encode string labels into integers
115
 
116
  def train_models():
117
  models = {
 
235
  popup=f"{place['name']}"
236
  ).add_to(map_)
237
  return professionals, map_._repr_html_()
 
238
  return [], "" # Return empty list if no professionals found
239
  except Exception as e:
240
  return [], "" # Return empty list on exception
 
294
  outline: none;
295
  }
296
 
 
 
 
 
 
 
297
  .df-container {
298
  background: white;
299
  color: black;