James McCool commited on
Commit
b9557f5
·
1 Parent(s): b3a8168

Add Prop Check feature to app.py for statistical analysis of player performance. Users can input a prop value and select a statistic (Kills, Deaths, Assists, CS) to calculate and display the probabilities of exceeding or falling below the specified prop value. This enhancement improves user interaction and provides deeper insights into player statistics during simulations.

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py CHANGED
@@ -705,6 +705,43 @@ if st.button("Run"):
705
  stat_data.style.format(precision=2).background_gradient(axis=0).background_gradient(cmap='RdYlGn'),
706
  use_container_width=True
707
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
708
 
709
  with tab2:
710
  st.subheader("Individual Game Data")
 
705
  stat_data.style.format(precision=2).background_gradient(axis=0).background_gradient(cmap='RdYlGn'),
706
  use_container_width=True
707
  )
708
+
709
+ st.subheader("Prop Check")
710
+ col1, col2 = st.columns([2, 8])
711
+ with col1:
712
+ prop_var = st.number_input("Enter Prop Value", min_value=0.0, max_value=100.0, value=4.5, step=0.5)
713
+ stat_choice = st.selectbox("Select Stat", ["Kills", "Deaths", "Assists", "CS"])
714
+ with col2:
715
+ # Filter data for selected stat
716
+ stat_data = overall_sim_df[overall_sim_df['Stat'] == stat_choice].copy()
717
+
718
+ # Calculate mean and standard deviation using percentiles
719
+ # Using the fact that in a normal distribution:
720
+ # 10th percentile is -1.28 SD from mean
721
+ # 90th percentile is 1.28 SD from mean
722
+ stat_data['mean'] = (stat_data['90%'] + stat_data['10%']) / 2
723
+ stat_data['std'] = (stat_data['90%'] - stat_data['10%']) / (2 * 1.28)
724
+
725
+ # Calculate probabilities
726
+ stat_data['over_prob'] = stat_data.apply(
727
+ lambda x: 1 - stats.norm.cdf(prop_var, x['mean'], x['std']), axis=1
728
+ )
729
+ stat_data['under_prob'] = stat_data.apply(
730
+ lambda x: stats.norm.cdf(prop_var, x['mean'], x['std']), axis=1
731
+ )
732
+
733
+ # Prepare display dataframe
734
+ display_df = stat_data[['Player', 'Position', 'over_prob', 'under_prob']].copy()
735
+ display_df['Over %'] = (display_df['over_prob'] * 100).round(1).astype(str) + '%'
736
+ display_df['Under %'] = (display_df['under_prob'] * 100).round(1).astype(str) + '%'
737
+
738
+ # Display results
739
+ st.dataframe(
740
+ display_df[['Player', 'Position', 'Over %', 'Under %']]
741
+ .set_index('Player')
742
+ .style.background_gradient(subset=['Over %', 'Under %'], cmap='RdYlGn'),
743
+ use_container_width=True
744
+ )
745
 
746
  with tab2:
747
  st.subheader("Individual Game Data")