mmrech commited on
Commit
5009675
·
verified ·
1 Parent(s): 061f182

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -19
app.py CHANGED
@@ -4,6 +4,18 @@ import joblib
4
  # Load the trained model
5
  model = joblib.load('trained_random_forest_pipeline.joblib')
6
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  iface = gr.Interface(
8
  fn=predict,
9
  inputs=[
@@ -44,24 +56,5 @@ iface = gr.Interface(
44
  outputs="text"
45
  )
46
 
47
-
48
-
49
-
50
- def predict(age, sex, race, etiology, hepatorenal_syndrome, omeprazole, spironolactone, furosemide, propanolol, dialysis, portal_vein_thrombosis,
51
- ascites, hepatocellular_carcinoma, albumin, total_bilirubin, direct_bilirubin, inr, creatinine, platelets, ast, alt, hemoglobin,
52
- hematocrit, leukocytes, sodium, potassium, varices, red_wale_marks, rupture_point, active_bleeding, therapy, terlipressin_dose, rebleeding):
53
- # Convert input data to the format expected by the model, e.g., a list or a DataFrame
54
- input_data = [age, sex, race, etiology, hepatorenal_syndrome, omeprazole, spironolactone, furosemide, propanolol, dialysis, portal_vein_thrombosis,
55
- ascites, hepatocellular_carcinoma, albumin, total_bilirubin, direct_bilirubin, inr, creatinine, platelets, ast, alt, hemoglobin,
56
- hematocrit, leukocytes, sodium, potassium, varices, red_wale_marks, rupture_point, active_bleeding, therapy, terlipressin_dose, rebleeding]
57
- # Assuming the model expects a single sample reshaped as a 2D array
58
- prediction = model.predict([input_data])
59
- return str(prediction[0]) # Convert prediction to string if necessary
60
-
61
-
62
-
63
-
64
-
65
-
66
  if __name__ == "__main__":
67
  iface.launch()
 
4
  # Load the trained model
5
  model = joblib.load('trained_random_forest_pipeline.joblib')
6
 
7
+ def predict(age, sex, race, etiology, hepatorenal_syndrome, omeprazole, spironolactone, furosemide, propanolol, dialysis, portal_vein_thrombosis,
8
+ ascites, hepatocellular_carcinoma, albumin, total_bilirubin, direct_bilirubin, inr, creatinine, platelets, ast, alt, hemoglobin,
9
+ hematocrit, leukocytes, sodium, potassium, varices, red_wale_marks, rupture_point, active_bleeding, therapy, terlipressin_dose, rebleeding):
10
+ # Convert input data to the format expected by the model, e.g., a list or a DataFrame
11
+ input_data = [age, sex, race, etiology, hepatorenal_syndrome, omeprazole, spironolactone, furosemide, propanolol, dialysis, portal_vein_thrombosis,
12
+ ascites, hepatocellular_carcinoma, albumin, total_bilirubin, direct_bilirubin, inr, creatinine, platelets, ast, alt, hemoglobin,
13
+ hematocrit, leukocytes, sodium, potassium, varices, red_wale_marks, rupture_point, active_bleeding, therapy, terlipressin_dose, rebleeding]
14
+ # Assuming the model expects a single sample reshaped as a 2D array
15
+ prediction = model.predict([input_data])
16
+ return str(prediction[0]) # Convert prediction to string if necessary
17
+
18
+
19
  iface = gr.Interface(
20
  fn=predict,
21
  inputs=[
 
56
  outputs="text"
57
  )
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  if __name__ == "__main__":
60
  iface.launch()