waritkan commited on
Commit
df20c8a
·
verified ·
1 Parent(s): 9207891

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -13
app.py CHANGED
@@ -5,18 +5,63 @@ import numpy as np
5
 
6
  # Load the model and unique brand values
7
  model = joblib.load('model.joblib')
8
- unique_values = joblib.load('unique_values.joblib')
9
- brand_values = unique_values['Brand']
10
 
11
  # Define the prediction function
12
- def predict(brand, screen_size, resolution_width, resolution_height):
13
  # Convert inputs to appropriate types
14
- screen_size = float(screen_size)
15
- resolution_width = int(resolution_width)
16
- resolution_height = int(resolution_height)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  # Prepare the input array for prediction
19
- input_data = pd.DataFrame({'Brand' : brand,'screen size': screen_size, "resolution width": resolution_width,'resolution height': resolution_height})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  # Perform the prediction
22
  prediction = model.predict(input_data)
@@ -27,14 +72,35 @@ def predict(brand, screen_size, resolution_width, resolution_height):
27
  interface = gr.Interface(
28
  fn=predict,
29
  inputs=[
30
- gr.Dropdown(choices=brand_values, label="Brand"),
31
- gr.Textbox(label="Screen Size"),
32
- gr.Textbox(label="Resolution (Width)"),
33
- gr.Textbox(label="Resolution (Height)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  ],
35
  outputs="text",
36
- title="Monitor Predictor",
37
- description="Enter the brand, screen size, and resolution to predict the target value."
38
  )
39
 
40
  # Launch the app
 
5
 
6
  # Load the model and unique brand values
7
  model = joblib.load('model.joblib')
8
+ college_values = joblib.load('unique_values.joblib')
9
+ conf_values = joblib.load('conf_values.joblib')
10
 
11
  # Define the prediction function
12
+ def predict(college,conf,year_drafted,qb_num_picked,rd_picked,num_picked,coach_tenure,height,weight,drafted_team_winpr,drafted_team_ppg_rk,conf_str,p_cmp,p_att,cmp_pct,p_yds,p_ypa,p_adj_ypa,ints,rate,r_att,r_yds,r_avg,r_tds):
13
  # Convert inputs to appropriate types
14
+ year_drafted = int(year_drafted)
15
+ qb_num_picked = int(qb_num_picked)
16
+ rd_picked = int(rd_picked)
17
+ coach_tenure = int(coach_tenure)
18
+ weight = int(weight)
19
+ height = int(height)
20
+ drafted_team_winpr = float(drafted_team_winpr)
21
+ drafted_team_ppg_rk = int(drafted_team_ppg_rk)
22
+ conf_str = float(conf_str)
23
+ p_cmp = int(p_cmp)
24
+ p_att = int(p_att)
25
+ cmp_pct = float(cmp_pct)
26
+ p_yds = int(p_yds)
27
+ p_ypa = float(p_ypa)
28
+ p_adj_ypa = float(p_adj_ypa)
29
+ p_td = int(p_td)
30
+ ints = int(ints)
31
+ rate = float(rate)
32
+ r_att = int(r_att)
33
+ r_yds = int(r_yds)
34
+ r_avg = float(r_avg)
35
+ r_tds = int(r_tds)
36
 
37
  # Prepare the input array for prediction
38
+ input_data = pd.DataFrame({
39
+ 'college': college,
40
+ 'conf': conf,
41
+ 'year_drafted': year_drafted,
42
+ 'qb_num_picked': qb_num_picked,
43
+ 'rd_picked': rd_picked,
44
+ 'num_picked': num_picked,
45
+ 'coach_tenure': coach_tenure,
46
+ 'height': height,
47
+ 'weight': weight,
48
+ 'drafted_team_winpr': drafted_team_winpr,
49
+ 'drafted_team_ppg_rk': drafted_team_ppg_rk,
50
+ 'conf_str': conf_str,
51
+ 'p_cmp': p_cmp,
52
+ 'p_att': p_att,
53
+ 'cmp_pct': cmp_pct,
54
+ 'p_yds': p_yd],
55
+ 'p_ypa': p_ypa,
56
+ 'p_adj_ypa': p_adj_ypa,
57
+ 'p_td': p_td,
58
+ 'ints': ints,
59
+ 'rate': rate,
60
+ 'r_att': r_att,
61
+ 'r_yds': r_yds,
62
+ 'r_avg': r_avg,
63
+ 'r_tds': r_tds
64
+ })
65
 
66
  # Perform the prediction
67
  prediction = model.predict(input_data)
 
72
  interface = gr.Interface(
73
  fn=predict,
74
  inputs=[
75
+ gr.Dropdown(choices=college_values, label="College"),
76
+ gr.Dropdown(choices=conf_values, label="Conference"),
77
+ gr.Textbox(label="Year Drafted"),
78
+ gr.Textbox(label="QB Number Picked"),
79
+ gr.Textbox(label="Round Picked"),
80
+ gr.Textbox(label="Number Picked"),
81
+ gr.Textbox(label="Coach Tenure"),
82
+ gr.Textbox(label="Height (inches)"),
83
+ gr.Textbox(label="Weight (pounds)"),
84
+ gr.Textbox(label="Drafted Team Win %"),
85
+ gr.Textbox(label="Drafted Team PPG Rank"),
86
+ gr.Textbox(label="Conference Strength"),
87
+ gr.Textbox(label="Pass Completions"),
88
+ gr.Textbox(label="Pass Attempts"),
89
+ gr.Textbox(label="Completion Percentage"),
90
+ gr.Textbox(label="Pass Yards"),
91
+ gr.Textbox(label="Pass Yards per Attempt"),
92
+ gr.Textbox(label="Adjusted Yards per Attempt"),
93
+ gr.Textbox(label="Pass Touchdowns"),
94
+ gr.Textbox(label="Interceptions"),
95
+ gr.Textbox(label="Passer Rating"),
96
+ gr.Textbox(label="Rush Attempts"),
97
+ gr.Textbox(label="Rush Yards"),
98
+ gr.Textbox(label="Rush Average"),
99
+ gr.Textbox(label="Rush Touchdowns")
100
  ],
101
  outputs="text",
102
+ title="passing to touchdown Predictor",
103
+ description="Enter all you see."
104
  )
105
 
106
  # Launch the app