Syntrex commited on
Commit
fbe3e2d
·
verified ·
1 Parent(s): 9e56c6f

Update models/live_fair_simulator_v3.py

Browse files
Files changed (1) hide show
  1. models/live_fair_simulator_v3.py +49 -0
models/live_fair_simulator_v3.py CHANGED
@@ -178,6 +178,55 @@ def build_upcoming_simulated_rows(
178
  ),
179
  )
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  sim = simulate_upcoming_hitter(
182
  game_row=game_row,
183
  batter_row=batter_features,
 
178
  ),
179
  )
180
 
181
+ # HR-specific pulled-contact-shape overlay
182
+ pre_pull_hr_prob_base = batter_baseline.get("hr_prob_base")
183
+
184
+ pulled_barrel_rate = batter_features.get("pulled_barrel_rate")
185
+ pulled_hard_air_rate = batter_features.get("pulled_hard_air_rate")
186
+ pull_air_rate = batter_features.get("pull_air_rate")
187
+
188
+ if pulled_barrel_rate is not None:
189
+ try:
190
+ pulled_barrel_rate = float(pulled_barrel_rate)
191
+ batter_baseline["hr_prob_base"] = min(
192
+ 0.30,
193
+ max(
194
+ 0.005,
195
+ float(batter_baseline.get("hr_prob_base", 0.03) or 0.03)
196
+ + max(-0.01, min(0.045, (pulled_barrel_rate - 0.020) * 1.50)),
197
+ ),
198
+ )
199
+ except Exception:
200
+ pass
201
+
202
+ elif pulled_hard_air_rate is not None:
203
+ try:
204
+ pulled_hard_air_rate = float(pulled_hard_air_rate)
205
+ batter_baseline["hr_prob_base"] = min(
206
+ 0.30,
207
+ max(
208
+ 0.005,
209
+ float(batter_baseline.get("hr_prob_base", 0.03) or 0.03)
210
+ + max(-0.008, min(0.030, (pulled_hard_air_rate - 0.040) * 0.55)),
211
+ ),
212
+ )
213
+ except Exception:
214
+ pass
215
+
216
+ elif pull_air_rate is not None:
217
+ try:
218
+ pull_air_rate = float(pull_air_rate)
219
+ batter_baseline["hr_prob_base"] = min(
220
+ 0.30,
221
+ max(
222
+ 0.005,
223
+ float(batter_baseline.get("hr_prob_base", 0.03) or 0.03)
224
+ + max(-0.006, min(0.020, (pull_air_rate - 0.10) * 0.18)),
225
+ ),
226
+ )
227
+ except Exception:
228
+ pass
229
+
230
  sim = simulate_upcoming_hitter(
231
  game_row=game_row,
232
  batter_row=batter_features,