kppham commited on
Commit
1b00095
·
verified ·
1 Parent(s): 5f90789

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  import pandas as pd
3
  import joblib
4
- loaded_best_pipeline = joblib.load('my_first_pipeline.pkl')
5
 
6
 
7
 
@@ -10,12 +10,15 @@ def predict_quality(fixed_acidity = None, volatile_acidity = None, citric_acid =
10
  if 0 in model_input:
11
  return_message = "Error: Invalid Input \n Please Input: \n"
12
  model_input_name = ['fixed_acidity', 'volatile_acidity', 'citric_acid', 'residual_sugar', 'chlorides', 'free_sulfur_dioxide', 'total_sulfur_dioxide', 'density', 'pH', 'sulphates', 'alcohol']
 
13
  for i in range(len(model_input)):
14
  if model_input[i] == 0:
15
  return_message = return_message + " " + model_input_name[i]
16
  return return_message
17
  else:
18
- prediction = predict_model(loaded_best_pipeline, data = pd.DataFrame([model_input], columns = white_wine.columns[:-1]))
 
 
19
  return_message = "Predicted Quality: " + str(prediction['prediction_label'][0]) + "\nConfidence: " + str(prediction['prediction_score'][0])
20
  return return_message
21
 
 
1
  import gradio as gr
2
  import pandas as pd
3
  import joblib
4
+ model = joblib.load('rf_model.pkl')
5
 
6
 
7
 
 
10
  if 0 in model_input:
11
  return_message = "Error: Invalid Input \n Please Input: \n"
12
  model_input_name = ['fixed_acidity', 'volatile_acidity', 'citric_acid', 'residual_sugar', 'chlorides', 'free_sulfur_dioxide', 'total_sulfur_dioxide', 'density', 'pH', 'sulphates', 'alcohol']
13
+
14
  for i in range(len(model_input)):
15
  if model_input[i] == 0:
16
  return_message = return_message + " " + model_input_name[i]
17
  return return_message
18
  else:
19
+ data = pd.DataFrame([[ fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides, free_sulfur_dioxide, total_sulfur_dioxide, density, pH, sulphates, alcohol
20
+ ]], columns=model_input_name)
21
+ prediction = model.predict(data)[0]
22
  return_message = "Predicted Quality: " + str(prediction['prediction_label'][0]) + "\nConfidence: " + str(prediction['prediction_score'][0])
23
  return return_message
24