Add 2 files
Browse files- README.md +7 -5
- index.html +467 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: advanced-baseball-game-prediction
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: red
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,467 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Baseball Game Prediction Model</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
.gradient-bg {
|
11 |
+
background: linear-gradient(135deg, #1a2a6c 0%, #b21f1f 50%, #fdbb2d 100%);
|
12 |
+
}
|
13 |
+
.parameter-card:hover {
|
14 |
+
transform: translateY(-5px);
|
15 |
+
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
|
16 |
+
}
|
17 |
+
.result-gauge {
|
18 |
+
background: linear-gradient(90deg, #e53e3e 0%, #f6e05e 50%, #48bb78 100%);
|
19 |
+
height: 20px;
|
20 |
+
border-radius: 10px;
|
21 |
+
}
|
22 |
+
.formula-box {
|
23 |
+
background-color: rgba(255, 255, 255, 0.1);
|
24 |
+
backdrop-filter: blur(10px);
|
25 |
+
border-radius: 0.5rem;
|
26 |
+
}
|
27 |
+
.tooltip {
|
28 |
+
position: relative;
|
29 |
+
display: inline-block;
|
30 |
+
}
|
31 |
+
.tooltip .tooltiptext {
|
32 |
+
visibility: hidden;
|
33 |
+
width: 300px;
|
34 |
+
background-color: #333;
|
35 |
+
color: #fff;
|
36 |
+
text-align: center;
|
37 |
+
border-radius: 6px;
|
38 |
+
padding: 10px;
|
39 |
+
position: absolute;
|
40 |
+
z-index: 1;
|
41 |
+
bottom: 125%;
|
42 |
+
left: 50%;
|
43 |
+
transform: translateX(-50%);
|
44 |
+
opacity: 0;
|
45 |
+
transition: opacity 0.3s;
|
46 |
+
font-size: 0.9rem;
|
47 |
+
}
|
48 |
+
.tooltip:hover .tooltiptext {
|
49 |
+
visibility: visible;
|
50 |
+
opacity: 1;
|
51 |
+
}
|
52 |
+
</style>
|
53 |
+
</head>
|
54 |
+
<body class="min-h-screen gradient-bg text-white">
|
55 |
+
<div class="container mx-auto px-4 py-8">
|
56 |
+
<!-- Header -->
|
57 |
+
<header class="text-center mb-12">
|
58 |
+
<h1 class="text-4xl md:text-5xl font-bold mb-4">Advanced Baseball Game Prediction Model</h1>
|
59 |
+
<p class="text-xl text-gray-200 max-w-3xl mx-auto">
|
60 |
+
A sophisticated logistic regression model that calculates win probabilities based on multiple performance metrics
|
61 |
+
</p>
|
62 |
+
</header>
|
63 |
+
|
64 |
+
<!-- Main Content -->
|
65 |
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
66 |
+
<!-- Input Section -->
|
67 |
+
<div class="lg:col-span-2 bg-white/10 backdrop-blur-md rounded-xl p-6 shadow-xl">
|
68 |
+
<h2 class="text-2xl font-bold mb-6 flex items-center">
|
69 |
+
<i class="fas fa-calculator mr-3"></i> Game Parameters
|
70 |
+
</h2>
|
71 |
+
|
72 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
73 |
+
<!-- Team Performance -->
|
74 |
+
<div class="parameter-card bg-gray-800/50 p-4 rounded-lg transition-all duration-300">
|
75 |
+
<div class="flex justify-between items-center mb-2">
|
76 |
+
<h3 class="font-semibold">Team Performance (TP)</h3>
|
77 |
+
<div class="tooltip">
|
78 |
+
<i class="fas fa-info-circle text-blue-300"></i>
|
79 |
+
<span class="tooltiptext">
|
80 |
+
Weighted average of win percentage: TP = 0.7 × (Last 10 Games Win %) + 0.3 × (Season Win %)
|
81 |
+
</span>
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
<div class="flex items-center space-x-4">
|
85 |
+
<div class="w-1/2">
|
86 |
+
<label class="block text-sm mb-1">Home Team</label>
|
87 |
+
<input type="number" id="home-tp" class="w-full bg-gray-700 rounded px-3 py-2" step="0.01" min="0" max="1" value="0.65">
|
88 |
+
</div>
|
89 |
+
<div class="w-1/2">
|
90 |
+
<label class="block text-sm mb-1">Away Team</label>
|
91 |
+
<input type="number" id="away-tp" class="w-full bg-gray-700 rounded px-3 py-2" step="0.01" min="0" max="1" value="0.50">
|
92 |
+
</div>
|
93 |
+
</div>
|
94 |
+
</div>
|
95 |
+
|
96 |
+
<!-- Starting Pitcher Strength -->
|
97 |
+
<div class="parameter-card bg-gray-800/50 p-4 rounded-lg transition-all duration-300">
|
98 |
+
<div class="flex justify-between items-center mb-2">
|
99 |
+
<h3 class="font-semibold">Starting Pitcher (SPS)</h3>
|
100 |
+
<div class="tooltip">
|
101 |
+
<i class="fas fa-info-circle text-blue-300"></i>
|
102 |
+
<span class="tooltiptext">
|
103 |
+
SPS = (League Avg. ERA / Pitcher ERA) × (League Avg. WHIP / Pitcher WHIP)
|
104 |
+
</span>
|
105 |
+
</div>
|
106 |
+
</div>
|
107 |
+
<div class="flex items-center space-x-4">
|
108 |
+
<div class="w-1/2">
|
109 |
+
<label class="block text-sm mb-1">Home Team</label>
|
110 |
+
<input type="number" id="home-sps" class="w-full bg-gray-700 rounded px-3 py-2" step="0.1" min="0" value="1.2">
|
111 |
+
</div>
|
112 |
+
<div class="w-1/2">
|
113 |
+
<label class="block text-sm mb-1">Away Team</label>
|
114 |
+
<input type="number" id="away-sps" class="w-full bg-gray-700 rounded px-3 py-2" step="0.1" min="0" value="0.9">
|
115 |
+
</div>
|
116 |
+
</div>
|
117 |
+
</div>
|
118 |
+
|
119 |
+
<!-- Bullpen Strength -->
|
120 |
+
<div class="parameter-card bg-gray-800/50 p-4 rounded-lg transition-all duration-300">
|
121 |
+
<div class="flex justify-between items-center mb-2">
|
122 |
+
<h3 class="font-semibold">Bullpen Strength (BS)</h3>
|
123 |
+
<div class="tooltip">
|
124 |
+
<i class="fas fa-info-circle text-blue-300"></i>
|
125 |
+
<span class="tooltiptext">
|
126 |
+
Bullpen ERA and WHIP compared to league average (similar to SPS calculation)
|
127 |
+
</span>
|
128 |
+
</div>
|
129 |
+
</div>
|
130 |
+
<div class="flex items-center space-x-4">
|
131 |
+
<div class="w-1/2">
|
132 |
+
<label class="block text-sm mb-1">Home Team</label>
|
133 |
+
<input type="number" id="home-bs" class="w-full bg-gray-700 rounded px-3 py-2" step="0.1" min="0" value="1.1">
|
134 |
+
</div>
|
135 |
+
<div class="w-1/2">
|
136 |
+
<label class="block text-sm mb-1">Away Team</label>
|
137 |
+
<input type="number" id="away-bs" class="w-full bg-gray-700 rounded px-3 py-2" step="0.1" min="0" value="0.95">
|
138 |
+
</div>
|
139 |
+
</div>
|
140 |
+
</div>
|
141 |
+
|
142 |
+
<!-- Batting Strength -->
|
143 |
+
<div class="parameter-card bg-gray-800/50 p-4 rounded-lg transition-all duration-300">
|
144 |
+
<div class="flex justify-between items-center mb-2">
|
145 |
+
<h3 class="font-semibold">Batting Strength (BAT)</h3>
|
146 |
+
<div class="tooltip">
|
147 |
+
<i class="fas fa-info-circle text-blue-300"></i>
|
148 |
+
<span class="tooltiptext">
|
149 |
+
BAT = 0.5 × OPS + 0.3 × wOBA + 0.2 × Runs/Game
|
150 |
+
</span>
|
151 |
+
</div>
|
152 |
+
</div>
|
153 |
+
<div class="flex items-center space-x-4">
|
154 |
+
<div class="w-1/2">
|
155 |
+
<label class="block text-sm mb-1">Home Team</label>
|
156 |
+
<input type="number" id="home-bat" class="w-full bg-gray-700 rounded px-3 py-2" step="0.01" min="0" value="0.85">
|
157 |
+
</div>
|
158 |
+
<div class="w-1/2">
|
159 |
+
<label class="block text-sm mb-1">Away Team</label>
|
160 |
+
<input type="number" id="away-bat" class="w-full bg-gray-700 rounded px-3 py-2" step="0.01" min="0" value="0.78">
|
161 |
+
</div>
|
162 |
+
</div>
|
163 |
+
</div>
|
164 |
+
|
165 |
+
<!-- Other Parameters -->
|
166 |
+
<div class="parameter-card bg-gray-800/50 p-4 rounded-lg transition-all duration-300">
|
167 |
+
<div class="flex justify-between items-center mb-2">
|
168 |
+
<h3 class="font-semibold">Injury Impact (INJ)</h3>
|
169 |
+
<div class="tooltip">
|
170 |
+
<i class="fas fa-info-circle text-blue-300"></i>
|
171 |
+
<span class="tooltiptext">
|
172 |
+
INJ = Total WAR of Injured Players / Team's Total WAR
|
173 |
+
</span>
|
174 |
+
</div>
|
175 |
+
</div>
|
176 |
+
<div class="flex items-center space-x-4">
|
177 |
+
<div class="w-1/2">
|
178 |
+
<label class="block text-sm mb-1">Home Team</label>
|
179 |
+
<input type="number" id="home-inj" class="w-full bg-gray-700 rounded px-3 py-2" step="0.01" min="0" max="1" value="0.05">
|
180 |
+
</div>
|
181 |
+
<div class="w-1/2">
|
182 |
+
<label class="block text-sm mb-1">Away Team</label>
|
183 |
+
<input type="number" id="away-inj" class="w-full bg-gray-700 rounded px-3 py-2" step="0.01" min="0" max="1" value="0.10">
|
184 |
+
</div>
|
185 |
+
</div>
|
186 |
+
</div>
|
187 |
+
|
188 |
+
<div class="parameter-card bg-gray-800/50 p-4 rounded-lg transition-all duration-300">
|
189 |
+
<div class="flex justify-between items-center mb-2">
|
190 |
+
<h3 class="font-semibold">Head-to-Head (H2H)</h3>
|
191 |
+
<div class="tooltip">
|
192 |
+
<i class="fas fa-info-circle text-blue-300"></i>
|
193 |
+
<span class="tooltiptext">
|
194 |
+
Home team's win percentage against the opponent in the last 5 meetings
|
195 |
+
</span>
|
196 |
+
</div>
|
197 |
+
</div>
|
198 |
+
<input type="number" id="h2h" class="w-full bg-gray-700 rounded px-3 py-2" step="0.01" min="0" max="1" value="0.60">
|
199 |
+
</div>
|
200 |
+
|
201 |
+
<div class="parameter-card bg-gray-800/50 p-4 rounded-lg transition-all duration-300">
|
202 |
+
<div class="flex justify-between items-center mb-2">
|
203 |
+
<h3 class="font-semibold">Weather Factor (WTH)</h3>
|
204 |
+
<div class="tooltip">
|
205 |
+
<i class="fas fa-info-circle text-blue-300"></i>
|
206 |
+
<span class="tooltiptext">
|
207 |
+
1.0 for neutral, 0.9 for rain (pitcher-friendly), 1.1 for strong wind (hitter-friendly)
|
208 |
+
</span>
|
209 |
+
</div>
|
210 |
+
</div>
|
211 |
+
<select id="weather" class="w-full bg-gray-700 rounded px-3 py-2">
|
212 |
+
<option value="1.0">Neutral Conditions</option>
|
213 |
+
<option value="0.9">Rain (Pitcher-friendly)</option>
|
214 |
+
<option value="1.1">Strong Wind (Hitter-friendly)</option>
|
215 |
+
</select>
|
216 |
+
</div>
|
217 |
+
|
218 |
+
<div class="parameter-card bg-gray-800/50 p-4 rounded-lg transition-all duration-300">
|
219 |
+
<div class="flex justify-between items-center mb-2">
|
220 |
+
<h3 class="font-semibold">Home Field Advantage</h3>
|
221 |
+
<div class="tooltip">
|
222 |
+
<i class="fas fa-info-circle text-blue-300"></i>
|
223 |
+
<span class="tooltiptext">
|
224 |
+
Binary parameter: 1 for home team, 0 for away. Coefficient typically ~0.24 (54% win probability)
|
225 |
+
</span>
|
226 |
+
</div>
|
227 |
+
</div>
|
228 |
+
<div class="flex items-center">
|
229 |
+
<input type="checkbox" id="hfa" class="mr-2" checked>
|
230 |
+
<label>Home Field Advantage Active</label>
|
231 |
+
</div>
|
232 |
+
</div>
|
233 |
+
</div>
|
234 |
+
|
235 |
+
<div class="mt-8">
|
236 |
+
<button id="calculate-btn" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300 flex items-center justify-center">
|
237 |
+
<i class="fas fa-chart-line mr-2"></i> Calculate Win Probability
|
238 |
+
</button>
|
239 |
+
</div>
|
240 |
+
</div>
|
241 |
+
|
242 |
+
<!-- Results Section -->
|
243 |
+
<div class="bg-white/10 backdrop-blur-md rounded-xl p-6 shadow-xl">
|
244 |
+
<h2 class="text-2xl font-bold mb-6 flex items-center">
|
245 |
+
<i class="fas fa-chart-pie mr-3"></i> Prediction Results
|
246 |
+
</h2>
|
247 |
+
|
248 |
+
<div id="results-container" class="text-center">
|
249 |
+
<div class="mb-8">
|
250 |
+
<h3 class="text-xl font-semibold mb-4">Win Probability</h3>
|
251 |
+
<div class="flex justify-between items-center mb-2">
|
252 |
+
<span id="home-team" class="font-medium">Home Team</span>
|
253 |
+
<span id="away-team" class="font-medium">Away Team</span>
|
254 |
+
</div>
|
255 |
+
<div class="result-gauge mb-2">
|
256 |
+
<div id="probability-gauge" class="h-full rounded-lg" style="width: 50%;"></div>
|
257 |
+
</div>
|
258 |
+
<div class="flex justify-between">
|
259 |
+
<span id="home-percent" class="text-xl font-bold">50%</span>
|
260 |
+
<span id="away-percent" class="text-xl font-bold">50%</span>
|
261 |
+
</div>
|
262 |
+
</div>
|
263 |
+
|
264 |
+
<div class="mb-8">
|
265 |
+
<h3 class="text-xl font-semibold mb-4">Key Factors</h3>
|
266 |
+
<div class="space-y-3">
|
267 |
+
<div class="flex justify-between">
|
268 |
+
<span>Team Performance</span>
|
269 |
+
<span id="tp-impact" class="font-medium">+0.15</span>
|
270 |
+
</div>
|
271 |
+
<div class="flex justify-between">
|
272 |
+
<span>Starting Pitcher</span>
|
273 |
+
<span id="sps-impact" class="font-medium">+0.80</span>
|
274 |
+
</div>
|
275 |
+
<div class="flex justify-between">
|
276 |
+
<span>Batting Strength</span>
|
277 |
+
<span id="bat-impact" class="font-medium">+0.07</span>
|
278 |
+
</div>
|
279 |
+
<div class="flex justify-between">
|
280 |
+
<span>Injury Impact</span>
|
281 |
+
<span id="inj-impact" class="font-medium">-0.05</span>
|
282 |
+
</div>
|
283 |
+
<div class="flex justify-between">
|
284 |
+
<span>Home Field Advantage</span>
|
285 |
+
<span id="hfa-impact" class="font-medium">+0.24</span>
|
286 |
+
</div>
|
287 |
+
</div>
|
288 |
+
</div>
|
289 |
+
|
290 |
+
<div class="formula-box p-4 mb-6">
|
291 |
+
<h3 class="text-lg font-semibold mb-2">Probability Formula</h3>
|
292 |
+
<div class="text-sm bg-gray-800/50 p-3 rounded">
|
293 |
+
<p class="mb-1">P(Home Win) = 1 / (1 + e<sup>-z</sup>)</p>
|
294 |
+
<p>Where z = β₀ + Σ(βᵢ × Xᵢ)</p>
|
295 |
+
</div>
|
296 |
+
</div>
|
297 |
+
|
298 |
+
<div class="bg-yellow-500/20 border border-yellow-500/50 rounded-lg p-4">
|
299 |
+
<h3 class="font-semibold mb-2 flex items-center">
|
300 |
+
<i class="fas fa-lightbulb mr-2"></i> Model Interpretation
|
301 |
+
</h3>
|
302 |
+
<p class="text-sm">
|
303 |
+
Probabilities above 70% indicate strong favorites, while 55-60% suggests a slight edge.
|
304 |
+
Values between 45-55% represent essentially even matchups.
|
305 |
+
</p>
|
306 |
+
</div>
|
307 |
+
</div>
|
308 |
+
</div>
|
309 |
+
</div>
|
310 |
+
|
311 |
+
<!-- Formula Explanation -->
|
312 |
+
<div class="mt-12 bg-gray-800/50 rounded-xl p-6 backdrop-blur-md">
|
313 |
+
<h2 class="text-2xl font-bold mb-4 flex items-center">
|
314 |
+
<i class="fas fa-square-root-alt mr-3"></i> Model Details
|
315 |
+
</h2>
|
316 |
+
|
317 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
318 |
+
<div>
|
319 |
+
<h3 class="text-xl font-semibold mb-3">Logistic Regression Formula</h3>
|
320 |
+
<div class="bg-black/30 p-4 rounded-lg mb-4">
|
321 |
+
<p class="text-center text-lg font-mono">
|
322 |
+
P(Home Win) = 1 / (1 + e<sup>-(β₀ + ΣβᵢXᵢ)</sup>)
|
323 |
+
</p>
|
324 |
+
</div>
|
325 |
+
<p class="mb-3">
|
326 |
+
This logistic function converts the weighted sum of input parameters into a probability between 0 and 1.
|
327 |
+
</p>
|
328 |
+
<p>
|
329 |
+
Each parameter (Xᵢ) represents the difference between home and away team metrics, except for binary factors like home field advantage.
|
330 |
+
</p>
|
331 |
+
</div>
|
332 |
+
|
333 |
+
<div>
|
334 |
+
<h3 class="text-xl font-semibold mb-3">Parameter Weights (β coefficients)</h3>
|
335 |
+
<div class="bg-gray-700/50 rounded-lg p-4">
|
336 |
+
<div class="space-y-2">
|
337 |
+
<div class="flex justify-between">
|
338 |
+
<span>Intercept (β₀)</span>
|
339 |
+
<span class="font-mono">0.50</span>
|
340 |
+
</div>
|
341 |
+
<div class="flex justify-between">
|
342 |
+
<span>Team Performance (β₁)</span>
|
343 |
+
<span class="font-mono">2.00</span>
|
344 |
+
</div>
|
345 |
+
<div class="flex justify-between">
|
346 |
+
<span>Starting Pitcher (β₂)</span>
|
347 |
+
<span class="font-mono">1.20</span>
|
348 |
+
</div>
|
349 |
+
<div class="flex justify-between">
|
350 |
+
<span>Batting Strength (β₃)</span>
|
351 |
+
<span class="font-mono">1.50</span>
|
352 |
+
</div>
|
353 |
+
<div class="flex justify-between">
|
354 |
+
<span>Bullpen Strength (β₄)</span>
|
355 |
+
<span class="font-mono">0.80</span>
|
356 |
+
</div>
|
357 |
+
<div class="flex justify-between">
|
358 |
+
<span>Home Field (β₅)</span>
|
359 |
+
<span class="font-mono">0.24</span>
|
360 |
+
</div>
|
361 |
+
<div class="flex justify-between">
|
362 |
+
<span>Injury Impact (β₆)</span>
|
363 |
+
<span class="font-mono">-0.50</span>
|
364 |
+
</div>
|
365 |
+
</div>
|
366 |
+
</div>
|
367 |
+
</div>
|
368 |
+
</div>
|
369 |
+
</div>
|
370 |
+
|
371 |
+
<!-- Example Calculation -->
|
372 |
+
<div class="mt-8 bg-blue-900/20 rounded-xl p-6 backdrop-blur-md border border-blue-500/30">
|
373 |
+
<h2 class="text-2xl font-bold mb-4 flex items-center">
|
374 |
+
<i class="fas fa-list-ol mr-3"></i> Example Calculation
|
375 |
+
</h2>
|
376 |
+
<div class="space-y-4">
|
377 |
+
<p>
|
378 |
+
Given differences: TP = +0.15, SPS = +0.8, HFA = 1, INJ = -0.1
|
379 |
+
</p>
|
380 |
+
<div class="bg-gray-800/50 p-4 rounded-lg">
|
381 |
+
<p class="font-mono mb-2">
|
382 |
+
z = 0.5 + (2.0 × 0.15) + (1.2 × 0.8) + (0.24 × 1) + (-0.5 × -0.1)
|
383 |
+
</p>
|
384 |
+
<p class="font-mono">
|
385 |
+
z = 0.5 + 0.3 + 0.96 + 0.24 + 0.05 = 2.05
|
386 |
+
</p>
|
387 |
+
</div>
|
388 |
+
<div class="bg-gray-800/50 p-4 rounded-lg">
|
389 |
+
<p class="font-mono">
|
390 |
+
P(Home Win) = 1 / (1 + e<sup>-2.05</sup>) ≈ 88.6%
|
391 |
+
</p>
|
392 |
+
</div>
|
393 |
+
</div>
|
394 |
+
</div>
|
395 |
+
</div>
|
396 |
+
|
397 |
+
<script>
|
398 |
+
document.getElementById('calculate-btn').addEventListener('click', calculateProbability);
|
399 |
+
|
400 |
+
function calculateProbability() {
|
401 |
+
// Get input values
|
402 |
+
const homeTP = parseFloat(document.getElementById('home-tp').value) || 0;
|
403 |
+
const awayTP = parseFloat(document.getElementById('away-tp').value) || 0;
|
404 |
+
const homeSPS = parseFloat(document.getElementById('home-sps').value) || 0;
|
405 |
+
const awaySPS = parseFloat(document.getElementById('away-sps').value) || 0;
|
406 |
+
const homeBS = parseFloat(document.getElementById('home-bs').value) || 0;
|
407 |
+
const awayBS = parseFloat(document.getElementById('away-bs').value) || 0;
|
408 |
+
const homeBAT = parseFloat(document.getElementById('home-bat').value) || 0;
|
409 |
+
const awayBAT = parseFloat(document.getElementById('away-bat').value) || 0;
|
410 |
+
const homeINJ = parseFloat(document.getElementById('home-inj').value) || 0;
|
411 |
+
const awayINJ = parseFloat(document.getElementById('away-inj').value) || 0;
|
412 |
+
const h2h = parseFloat(document.getElementById('h2h').value) || 0;
|
413 |
+
const weather = parseFloat(document.getElementById('weather').value) || 1.0;
|
414 |
+
const hfa = document.getElementById('hfa').checked ? 1 : 0;
|
415 |
+
|
416 |
+
// Calculate differences (X_i values)
|
417 |
+
const tpDiff = homeTP - awayTP;
|
418 |
+
const spsDiff = homeSPS - awaySPS;
|
419 |
+
const bsDiff = homeBS - awayBS;
|
420 |
+
const batDiff = homeBAT - awayBAT;
|
421 |
+
const injDiff = awayINJ - homeINJ; // More injuries is bad, so we reverse the difference
|
422 |
+
|
423 |
+
// Coefficients (β values)
|
424 |
+
const beta0 = 0.50; // Intercept
|
425 |
+
const betaTP = 2.00;
|
426 |
+
const betaSPS = 1.20;
|
427 |
+
const betaBS = 0.80;
|
428 |
+
const betaBAT = 1.50;
|
429 |
+
const betaHFA = 0.24;
|
430 |
+
const betaINJ = -0.50;
|
431 |
+
const betaH2H = 0.60;
|
432 |
+
const betaWTH = 0.30;
|
433 |
+
|
434 |
+
// Calculate weighted sum (z)
|
435 |
+
let z = beta0;
|
436 |
+
z += betaTP * tpDiff;
|
437 |
+
z += betaSPS * spsDiff;
|
438 |
+
z += betaBS * bsDiff;
|
439 |
+
z += betaBAT * batDiff;
|
440 |
+
z += betaHFA * hfa;
|
441 |
+
z += betaINJ * injDiff;
|
442 |
+
z += betaH2H * (h2h - 0.5); // Center around 0.5
|
443 |
+
z += betaWTH * (weather - 1.0); // Center around 1.0
|
444 |
+
|
445 |
+
// Calculate probability using logistic function
|
446 |
+
const probability = 1 / (1 + Math.exp(-z));
|
447 |
+
const homePercent = (probability * 100).toFixed(1);
|
448 |
+
const awayPercent = (100 - probability * 100).toFixed(1);
|
449 |
+
|
450 |
+
// Update UI
|
451 |
+
document.getElementById('home-percent').textContent = `${homePercent}%`;
|
452 |
+
document.getElementById('away-percent').textContent = `${awayPercent}%`;
|
453 |
+
document.getElementById('probability-gauge').style.width = `${homePercent}%`;
|
454 |
+
|
455 |
+
// Update impact factors
|
456 |
+
document.getElementById('tp-impact').textContent = (betaTP * tpDiff).toFixed(2);
|
457 |
+
document.getElementById('sps-impact').textContent = (betaSPS * spsDiff).toFixed(2);
|
458 |
+
document.getElementById('bat-impact').textContent = (betaBAT * batDiff).toFixed(2);
|
459 |
+
document.getElementById('inj-impact').textContent = (betaINJ * injDiff).toFixed(2);
|
460 |
+
document.getElementById('hfa-impact').textContent = hfa ? betaHFA.toFixed(2) : "0.00";
|
461 |
+
}
|
462 |
+
|
463 |
+
// Initialize with default calculation
|
464 |
+
calculateProbability();
|
465 |
+
</script>
|
466 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=LMLK/advanced-baseball-game-prediction" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
467 |
+
</html>
|