milotix commited on
Commit
f5b11a7
·
verified ·
1 Parent(s): d4e2ad8

Sync app files

Browse files
Files changed (1) hide show
  1. drug_app.py +7 -3
drug_app.py CHANGED
@@ -1,4 +1,5 @@
1
  import gradio as gr
 
2
  import skops.io as sio
3
 
4
  # Get the list of ALL types found in the file
@@ -26,15 +27,18 @@ def predict_drug(age, sex, blood_pressure, cholesterol, na_to_k_ratio):
26
  Returns:
27
  str: Predicted drug label
28
  """
29
- features = [age, sex, blood_pressure, cholesterol, na_to_k_ratio]
 
 
 
30
  try:
31
- probabilities = pipe.predict_proba([features])[0]
32
  return {
33
  str(label): float(prob)
34
  for label, prob in zip(pipe.classes_, probabilities)
35
  }
36
  except Exception:
37
- predicted_drug = pipe.predict([features])[0]
38
  return str(predicted_drug)
39
 
40
 
 
1
  import gradio as gr
2
+ import numpy as np
3
  import skops.io as sio
4
 
5
  # Get the list of ALL types found in the file
 
27
  Returns:
28
  str: Predicted drug label
29
  """
30
+ features = np.array(
31
+ [[age, sex, blood_pressure, cholesterol, na_to_k_ratio]],
32
+ dtype=object,
33
+ )
34
  try:
35
+ probabilities = pipe.predict_proba(features)[0]
36
  return {
37
  str(label): float(prob)
38
  for label, prob in zip(pipe.classes_, probabilities)
39
  }
40
  except Exception:
41
+ predicted_drug = pipe.predict(features)[0]
42
  return str(predicted_drug)
43
 
44