adi-123 commited on
Commit
47d4f39
·
verified ·
1 Parent(s): 7e403b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -37,22 +37,27 @@ with st.form("prediction_form"):
37
  submitted = st.form_submit_button("Predict")
38
 
39
  if submitted:
40
- # Organize the user inputs into a DataFrame that matches the training data
41
- input_df = pd.DataFrame([[gp, min, pts, fgm, fga, fg_percent, threep_made, threepa,
42
- threep_percent, ftm, fta, ft_percent, oreb, dreb, reb,
43
- ast, stl, blk, tov]],
44
- columns=['GP', 'MIN', 'PTS', 'FGM', 'FGA', 'FG%', '3P Made',
45
- '3PA', '3P%', 'FTM', 'FTA', 'FT%', 'OREB', 'DREB',
46
- 'REB', 'AST', 'STL', 'BLK', 'TOV'])
47
-
48
- # Ensure the input DataFrame structure matches the model's expected format
49
- # (You might need to adjust this part based on how the model was trained)
50
-
51
- # Predict using the loaded model
 
 
 
 
52
  prediction = model.predict(input_df)[0]
53
 
54
- # Output the prediction
55
  if prediction == 1:
56
  st.success('The rookie is likely to have a successful career spanning at least 5 years!')
57
  else:
58
- st.error('The rookie might not have a very successful career lasting at least 5 years.')
 
 
 
37
  submitted = st.form_submit_button("Predict")
38
 
39
  if submitted:
40
+ # Assuming the rest of the code remains the same for collecting inputs
41
+
42
+ # Create the DataFrame without considering the index as a feature
43
+ input_df = pd.DataFrame([[
44
+ gp, min, pts, fgm, fga, fg_percent, threep_made, threepa, threep_percent,
45
+ ftm, fta, ft_percent, oreb, dreb, reb, ast, stl, blk, tov
46
+ ]], columns=[
47
+ 'GP', 'MIN', 'PTS', 'FGM', 'FGA', 'FG%', '3P Made', '3PA', '3P%',
48
+ 'FTM', 'FTA', 'FT%', 'OREB', 'DREB', 'REB', 'AST', 'STL', 'BLK', 'TOV'
49
+ ])
50
+
51
+ # Ensure there's no unexpected index that could be interpreted as a feature
52
+ input_df.reset_index(drop=True, inplace=True)
53
+
54
+ # Attempt prediction
55
+ try:
56
  prediction = model.predict(input_df)[0]
57
 
 
58
  if prediction == 1:
59
  st.success('The rookie is likely to have a successful career spanning at least 5 years!')
60
  else:
61
+ st.error('The rookie might not have a very successful career lasting at least 5 years.')
62
+ except ValueError as e:
63
+ st.error(f'Error making prediction: {e}')