demonmittenhands commited on
Commit
edda0ff
1 Parent(s): 4d75887

gradio stuff

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -36,7 +36,14 @@ scheduler = CommitScheduler(
36
  # Define the predict function which will take features, convert to dataframe and make predictions using the saved model
37
  # the functions runs when 'Submit' is clicked or when a API request is made
38
  def predict(age, bmi, children, sex, smoker, region):
39
-
 
 
 
 
 
 
 
40
  input = {
41
  "age": age,
42
  "bmi": bmi,
@@ -47,7 +54,7 @@ def predict(age, bmi, children, sex, smoker, region):
47
  }
48
 
49
  input_df = pd.DataFrame([input])
50
- prediction = insurance_model.predict(input_df).to_list()
51
 
52
  # While the prediction is made, log both the inputs and outputs to a log file
53
  # While writing to the log file, ensure that the commit scheduler is locked to avoid parallel
@@ -77,8 +84,8 @@ def predict(age, bmi, children, sex, smoker, region):
77
  age_input = gr.Number(label="Age")
78
  bmi_input = gr.Number(label="BMI")
79
  children_input = gr.Slider(minimum=0.0, maximum=15.0, step=1.0, label="Children")
80
- sex_input = gr.Dropdown(['male', 'female'], label="sex")
81
- smoker_input = gr.Checkbox(['no', 'yes'], label="smoker")
82
  region_input = gr.Dropdown(['southwest', 'southeast', 'northwest', 'northeast'], label="region")
83
  output = gr.Label(label="Insurance Price")
84
 
@@ -97,4 +104,5 @@ demo = gr.Interface(
97
  # Launch with a load balancer
98
  # these two lines were in the file already
99
  demo.queue()
 
100
  demo.launch(share=False)
 
36
  # Define the predict function which will take features, convert to dataframe and make predictions using the saved model
37
  # the functions runs when 'Submit' is clicked or when a API request is made
38
  def predict(age, bmi, children, sex, smoker, region):
39
+ # input2 = {
40
+ # "age": 10,
41
+ # "bmi": 30,
42
+ # "children": 6,
43
+ # "sex": 'female',
44
+ # "smoker": 'yes',
45
+ # "region": 'northwest'
46
+ # }
47
  input = {
48
  "age": age,
49
  "bmi": bmi,
 
54
  }
55
 
56
  input_df = pd.DataFrame([input])
57
+ prediction = insurance_model.predict(input_df)
58
 
59
  # While the prediction is made, log both the inputs and outputs to a log file
60
  # While writing to the log file, ensure that the commit scheduler is locked to avoid parallel
 
84
  age_input = gr.Number(label="Age")
85
  bmi_input = gr.Number(label="BMI")
86
  children_input = gr.Slider(minimum=0.0, maximum=15.0, step=1.0, label="Children")
87
+ sex_input = gr.Radio(['male', 'female'], label="sex")
88
+ smoker_input = gr.Radio(choices=['yes', 'no'], label="smoker")
89
  region_input = gr.Dropdown(['southwest', 'southeast', 'northwest', 'northeast'], label="region")
90
  output = gr.Label(label="Insurance Price")
91
 
 
104
  # Launch with a load balancer
105
  # these two lines were in the file already
106
  demo.queue()
107
+ # demo.launch(share=True, debug=True)
108
  demo.launch(share=False)