MarcRyan commited on
Commit
b6bd467
·
verified ·
1 Parent(s): d03ff90

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +650 -19
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Btp
3
- emoji: 🏃
4
- colorFrom: yellow
5
- colorTo: indigo
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: btp
3
+ emoji: 🐳
4
+ colorFrom: red
5
+ colorTo: purple
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,650 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Team Performance Predictor</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/brain/0.6.3/brain.min.js"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
10
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
11
+ <style>
12
+ .neuron {
13
+ transition: all 0.3s ease;
14
+ }
15
+ .neuron:hover {
16
+ transform: scale(1.1);
17
+ }
18
+ .network-container {
19
+ perspective: 1000px;
20
+ }
21
+ .layer {
22
+ transform-style: preserve-3d;
23
+ }
24
+ .connection {
25
+ stroke-dasharray: 1000;
26
+ stroke-dashoffset: 1000;
27
+ animation: draw 1.5s forwards;
28
+ }
29
+ @keyframes draw {
30
+ to {
31
+ stroke-dashoffset: 0;
32
+ }
33
+ }
34
+ .progress-ring__circle {
35
+ transition: stroke-dashoffset 0.35s;
36
+ transform: rotate(-90deg);
37
+ transform-origin: 50% 50%;
38
+ }
39
+ .team-card:hover {
40
+ transform: translateY(-5px);
41
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
42
+ }
43
+ .team-card {
44
+ transition: all 0.3s ease;
45
+ }
46
+ </style>
47
+ </head>
48
+ <body class="bg-gray-50 min-h-screen">
49
+ <div class="container mx-auto px-4 py-8">
50
+ <header class="text-center mb-12">
51
+ <h1 class="text-4xl font-bold text-gray-800 mb-2">⚾ Baseball Team Performance Predictor</h1>
52
+ <p class="text-gray-600 max-w-2xl mx-auto">A neural network that predicts team loss probability based on key performance metrics</p>
53
+ </header>
54
+
55
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
56
+ <!-- Configuration Panel -->
57
+ <div class="bg-white rounded-xl shadow-md p-6">
58
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">Network Configuration</h2>
59
+ <div class="space-y-4">
60
+ <div>
61
+ <label class="block text-sm font-medium text-gray-700 mb-1">Hidden Layers</label>
62
+ <input type="range" id="hiddenLayersInput" min="1" max="5" value="3" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
63
+ <div class="flex justify-between text-xs text-gray-500">
64
+ <span>1</span>
65
+ <span>2</span>
66
+ <span>3</span>
67
+ <span>4</span>
68
+ <span>5</span>
69
+ </div>
70
+ </div>
71
+
72
+ <div>
73
+ <label class="block text-sm font-medium text-gray-700 mb-1">Neurons per Layer</label>
74
+ <input type="range" id="neuronsPerLayerInput" min="3" max="10" value="6" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
75
+ <div class="flex justify-between text-xs text-gray-500">
76
+ <span>3</span>
77
+ <span>4</span>
78
+ <span>5</span>
79
+ <span>6</span>
80
+ <span>7</span>
81
+ <span>8</span>
82
+ <span>9</span>
83
+ <span>10</span>
84
+ </div>
85
+ </div>
86
+
87
+ <div>
88
+ <label class="block text-sm font-medium text-gray-700 mb-1">Learning Rate</label>
89
+ <input type="range" id="learningRateInput" min="0.01" max="0.5" step="0.01" value="0.2" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
90
+ <div class="flex justify-between text-xs text-gray-500">
91
+ <span>0.01</span>
92
+ <span>0.25</span>
93
+ <span>0.5</span>
94
+ </div>
95
+ </div>
96
+
97
+ <div class="flex space-x-3 pt-2">
98
+ <button id="trainBtn" class="flex-1 bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg flex items-center justify-center">
99
+ <i class="fas fa-brain mr-2"></i> Train Network
100
+ </button>
101
+ <button id="resetBtn" class="flex-1 bg-gray-200 hover:bg-gray-300 text-gray-800 py-2 px-4 rounded-lg flex items-center justify-center">
102
+ <i class="fas fa-redo mr-2"></i> Reset
103
+ </button>
104
+ </div>
105
+ </div>
106
+
107
+ <div class="mt-6">
108
+ <h3 class="text-sm font-medium text-gray-700 mb-2">Training Status</h3>
109
+ <div id="trainingStatus" class="text-sm text-gray-600 bg-gray-100 p-3 rounded-lg">
110
+ Network not trained yet
111
+ </div>
112
+ </div>
113
+ </div>
114
+
115
+ <!-- Network Visualization -->
116
+ <div class="bg-white rounded-xl shadow-md p-6">
117
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">Network Architecture</h2>
118
+ <div id="networkVisualization" class="network-container h-64 flex justify-center items-center">
119
+ <svg id="networkSvg" width="100%" height="100%" viewBox="0 0 500 300"></svg>
120
+ </div>
121
+
122
+ <div class="mt-6">
123
+ <h3 class="text-sm font-medium text-gray-700 mb-2">Error Over Time</h3>
124
+ <div class="bg-gray-100 p-2 rounded-lg">
125
+ <canvas id="errorChart" height="150"></canvas>
126
+ </div>
127
+ </div>
128
+ </div>
129
+
130
+ <!-- Prediction Panel -->
131
+ <div class="bg-white rounded-xl shadow-md p-6">
132
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">Make a Prediction</h2>
133
+ <div class="space-y-3">
134
+ <div>
135
+ <label class="block text-sm font-medium text-gray-700 mb-1">Team ERA</label>
136
+ <input id="eraInput" type="number" step="0.01" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="4.50">
137
+ </div>
138
+ <div>
139
+ <label class="block text-sm font-medium text-gray-700 mb-1">Team Batting Average</label>
140
+ <input id="baInput" type="number" step="0.001" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="0.250">
141
+ </div>
142
+ <div>
143
+ <label class="block text-sm font-medium text-gray-700 mb-1">Home Runs</label>
144
+ <input id="hrInput" type="number" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="150">
145
+ </div>
146
+ <div>
147
+ <label class="block text-sm font-medium text-gray-700 mb-1">Fielding Errors</label>
148
+ <input id="errorsInput" type="number" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" placeholder="100">
149
+ </div>
150
+
151
+ <button id="predictBtn" class="w-full bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded-lg mt-4 flex items-center justify-center">
152
+ <i class="fas fa-calculator mr-2"></i> Predict Loss Probability
153
+ </button>
154
+
155
+ <div id="predictionResult" class="mt-4 p-4 rounded-lg bg-blue-50 hidden">
156
+ <h4 class="font-medium text-blue-800 mb-1">Prediction Result</h4>
157
+ <p id="predictionText" class="text-blue-600"></p>
158
+ <div class="mt-3 flex items-center">
159
+ <div class="w-12 h-12 mr-3">
160
+ <svg class="progress-ring" width="48" height="48">
161
+ <circle class="progress-ring__circle" stroke="#E5E7EB" stroke-width="4" fill="transparent" r="20" cx="24" cy="24"/>
162
+ <circle class="progress-ring__circle" stroke="#3B82F6" stroke-width="4" fill="transparent" r="20" cx="24" cy="24"/>
163
+ </svg>
164
+ </div>
165
+ <div class="text-2xl font-bold text-blue-600" id="predictionPercentage">0%</div>
166
+ </div>
167
+ </div>
168
+ </div>
169
+ </div>
170
+ </div>
171
+
172
+ <!-- Team Cards -->
173
+ <div class="mt-12">
174
+ <h2 class="text-2xl font-bold text-gray-800 mb-6">MLB Teams</h2>
175
+ <div id="teamPredictions" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6"></div>
176
+ </div>
177
+ </div>
178
+
179
+ <script>
180
+ document.addEventListener('DOMContentLoaded', function() {
181
+ // Configuration
182
+ const config = {
183
+ hiddenLayers: 3,
184
+ neuronsPerLayer: 6,
185
+ learningRate: 0.2,
186
+ iterations: 20000,
187
+ errorThresh: 0.005
188
+ };
189
+
190
+ // Sample baseball teams data
191
+ let baseballTeams = [
192
+ { name: "New York Yankees", logo: "🏆", era: 3.75, ba: 0.257, hr: 245, errors: 85 },
193
+ { name: "Los Angeles Dodgers", logo: "🔵", era: 3.42, ba: 0.263, hr: 235, errors: 78 },
194
+ { name: "Houston Astros", logo: "🌟", era: 3.68, ba: 0.261, hr: 221, errors: 92 },
195
+ { name: "Atlanta Braves", logo: "🔴", era: 3.89, ba: 0.255, hr: 239, errors: 87 },
196
+ { name: "Boston Red Sox", logo: "🧦", era: 4.12, ba: 0.249, hr: 198, errors: 105 },
197
+ { name: "Chicago Cubs", logo: "🐻", era: 4.05, ba: 0.242, hr: 187, errors: 112 },
198
+ { name: "San Francisco Giants", logo: "🌉", era: 3.95, ba: 0.247, hr: 176, errors: 98 },
199
+ { name: "St. Louis Cardinals", logo: "🐦", era: 3.78, ba: 0.254, hr: 203, errors: 89 }
200
+ ];
201
+
202
+ // Initialize network
203
+ let net = new brain.NeuralNetwork();
204
+ let errorChart;
205
+ let trainingData = generateTrainingData();
206
+
207
+ // DOM Elements
208
+ const hiddenLayersInput = document.getElementById('hiddenLayersInput');
209
+ const neuronsPerLayerInput = document.getElementById('neuronsPerLayerInput');
210
+ const learningRateInput = document.getElementById('learningRateInput');
211
+ const trainBtn = document.getElementById('trainBtn');
212
+ const resetBtn = document.getElementById('resetBtn');
213
+ const eraInput = document.getElementById('eraInput');
214
+ const baInput = document.getElementById('baInput');
215
+ const hrInput = document.getElementById('hrInput');
216
+ const errorsInput = document.getElementById('errorsInput');
217
+ const predictBtn = document.getElementById('predictBtn');
218
+ const predictionResult = document.getElementById('predictionResult');
219
+ const predictionText = document.getElementById('predictionText');
220
+ const predictionPercentage = document.getElementById('predictionPercentage');
221
+ const teamPredictions = document.getElementById('teamPredictions');
222
+ const trainingStatus = document.getElementById('trainingStatus');
223
+
224
+ // Initialize UI
225
+ initUI();
226
+ drawNetwork();
227
+ initChart();
228
+ renderTeamCards();
229
+
230
+ // Event Listeners
231
+ hiddenLayersInput.addEventListener('input', updateConfig);
232
+ neuronsPerLayerInput.addEventListener('input', updateConfig);
233
+ learningRateInput.addEventListener('input', updateConfig);
234
+ trainBtn.addEventListener('click', trainNetwork);
235
+ resetBtn.addEventListener('click', resetNetwork);
236
+ predictBtn.addEventListener('click', predictLossProbability);
237
+
238
+ // Functions
239
+ function generateTrainingData() {
240
+ // Generate synthetic training data based on realistic baseball stats
241
+ const data = [];
242
+
243
+ for (let i = 0; i < 100; i++) {
244
+ // Generate random but realistic baseball stats
245
+ const era = 2.5 + Math.random() * 3.5; // ERA between 2.5 and 6.0
246
+ const ba = 0.220 + Math.random() * 0.080; // BA between .220 and .300
247
+ const hr = 100 + Math.random() * 200; // HR between 100 and 300
248
+ const errors = 50 + Math.random() * 100; // Errors between 50 and 150
249
+
250
+ // Calculate a synthetic loss probability based on these stats
251
+ // Better stats (lower ERA, higher BA, more HR, fewer errors) should lead to lower loss probability
252
+ let lossProbability =
253
+ (era / 6.0) * 0.4 + // ERA contributes 40%
254
+ ((0.300 - ba) / 0.080) * 0.3 + // BA contributes 30%
255
+ ((300 - hr) / 200) * 0.2 + // HR contributes 20%
256
+ (errors / 150) * 0.1; // Errors contribute 10%
257
+
258
+ // Add some randomness
259
+ lossProbability += (Math.random() - 0.5) * 0.1;
260
+
261
+ // Ensure between 0 and 1
262
+ lossProbability = Math.max(0, Math.min(1, lossProbability));
263
+
264
+ data.push({
265
+ input: {
266
+ era: normalize(era, 2.5, 6.0),
267
+ ba: normalize(ba, 0.220, 0.300),
268
+ hr: normalize(hr, 100, 300),
269
+ errors: normalize(errors, 50, 150)
270
+ },
271
+ output: {
272
+ loss: lossProbability
273
+ }
274
+ });
275
+ }
276
+
277
+ return data;
278
+ }
279
+
280
+ function normalize(value, min, max) {
281
+ return (value - min) / (max - min);
282
+ }
283
+
284
+ function denormalize(value, min, max) {
285
+ return value * (max - min) + min;
286
+ }
287
+
288
+ function initUI() {
289
+ // Set initial values from config
290
+ hiddenLayersInput.value = config.hiddenLayers;
291
+ neuronsPerLayerInput.value = config.neuronsPerLayer;
292
+ learningRateInput.value = config.learningRate;
293
+
294
+ // Initialize prediction progress ring
295
+ const circle = document.querySelector('.progress-ring__circle:last-child');
296
+ const radius = circle.r.baseVal.value;
297
+ const circumference = radius * 2 * Math.PI;
298
+
299
+ circle.style.strokeDasharray = circumference;
300
+ circle.style.strokeDashoffset = circumference;
301
+ }
302
+
303
+ function updateConfig() {
304
+ config.hiddenLayers = parseInt(hiddenLayersInput.value);
305
+ config.neuronsPerLayer = parseInt(neuronsPerLayerInput.value);
306
+ config.learningRate = parseFloat(learningRateInput.value);
307
+
308
+ drawNetwork();
309
+ }
310
+
311
+ function resetNetwork() {
312
+ net = new brain.NeuralNetwork();
313
+ trainingStatus.textContent = "Network reset - not trained";
314
+ trainingStatus.className = "text-sm text-gray-600 bg-gray-100 p-3 rounded-lg";
315
+
316
+ // Reset chart
317
+ if (errorChart) {
318
+ errorChart.data.labels = [];
319
+ errorChart.data.datasets[0].data = [];
320
+ errorChart.update();
321
+ }
322
+
323
+ // Hide prediction result
324
+ predictionResult.classList.add('hidden');
325
+ }
326
+
327
+ function trainNetwork() {
328
+ trainBtn.disabled = true;
329
+ trainBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Training...';
330
+ trainingStatus.textContent = "Training in progress...";
331
+ trainingStatus.className = "text-sm text-blue-600 bg-blue-100 p-3 rounded-lg";
332
+
333
+ // Configure network
334
+ net = new brain.NeuralNetwork({
335
+ hiddenLayers: [Array(config.hiddenLayers).fill(config.neuronsPerLayer)].flat(),
336
+ learningRate: config.learningRate,
337
+ iterations: config.iterations,
338
+ errorThresh: config.errorThresh,
339
+ log: true,
340
+ logPeriod: 1000,
341
+ callback: function(info) {
342
+ updateTrainingStatus(info.iterations, info.error);
343
+ updateChart(info.iterations, info.error);
344
+ },
345
+ callbackPeriod: 1000
346
+ });
347
+
348
+ // Train in a timeout to allow UI to update
349
+ setTimeout(() => {
350
+ net.train(trainingData, (err, info) => {
351
+ trainBtn.disabled = false;
352
+ trainBtn.innerHTML = '<i class="fas fa-brain mr-2"></i> Train Network';
353
+
354
+ if (err) {
355
+ trainingStatus.textContent = "Training failed: " + err;
356
+ trainingStatus.className = "text-sm text-red-600 bg-red-100 p-3 rounded-lg";
357
+ } else {
358
+ trainingStatus.textContent = `Training complete! Final error: ${info.error.toFixed(6)} after ${info.iterations} iterations`;
359
+ trainingStatus.className = "text-sm text-green-600 bg-green-100 p-3 rounded-lg";
360
+ }
361
+
362
+ // Animate network connections
363
+ animateNetwork();
364
+ });
365
+ }, 100);
366
+ }
367
+
368
+ function updateTrainingStatus(iterations, error) {
369
+ trainingStatus.textContent = `Training... Iteration: ${iterations}, Error: ${error.toFixed(6)}`;
370
+ }
371
+
372
+ function initChart() {
373
+ const ctx = document.getElementById('errorChart').getContext('2d');
374
+ errorChart = new Chart(ctx, {
375
+ type: 'line',
376
+ data: {
377
+ labels: [],
378
+ datasets: [{
379
+ label: 'Training Error',
380
+ data: [],
381
+ borderColor: 'rgb(99, 102, 241)',
382
+ backgroundColor: 'rgba(99, 102, 241, 0.1)',
383
+ borderWidth: 2,
384
+ tension: 0.4,
385
+ fill: true
386
+ }]
387
+ },
388
+ options: {
389
+ responsive: true,
390
+ maintainAspectRatio: false,
391
+ scales: {
392
+ y: {
393
+ beginAtZero: true,
394
+ title: {
395
+ display: true,
396
+ text: 'Error'
397
+ }
398
+ },
399
+ x: {
400
+ title: {
401
+ display: true,
402
+ text: 'Iterations'
403
+ }
404
+ }
405
+ },
406
+ plugins: {
407
+ legend: {
408
+ display: false
409
+ },
410
+ tooltip: {
411
+ callbacks: {
412
+ label: function(context) {
413
+ return `Error: ${context.parsed.y.toFixed(6)}`;
414
+ }
415
+ }
416
+ }
417
+ }
418
+ }
419
+ });
420
+ }
421
+
422
+ function updateChart(iteration, error) {
423
+ errorChart.data.labels.push(iteration);
424
+ errorChart.data.datasets[0].data.push(error);
425
+ errorChart.update();
426
+ }
427
+
428
+ function drawNetwork() {
429
+ const svg = document.getElementById('networkSvg');
430
+ svg.innerHTML = '';
431
+
432
+ const width = 500;
433
+ const height = 300;
434
+ const layerCount = config.hiddenLayers + 2; // Input + hidden + output
435
+ const neuronRadius = 15;
436
+
437
+ // Draw layers
438
+ for (let layer = 0; layer < layerCount; layer++) {
439
+ const isInput = layer === 0;
440
+ const isOutput = layer === layerCount - 1;
441
+
442
+ let neuronCount;
443
+ if (isInput) neuronCount = 4; // 4 input features
444
+ else if (isOutput) neuronCount = 1; // 1 output (loss probability)
445
+ else neuronCount = config.neuronsPerLayer;
446
+
447
+ const layerX = 50 + (width - 100) * (layer / (layerCount - 1));
448
+
449
+ // Draw neurons
450
+ for (let n = 0; n < neuronCount; n++) {
451
+ const neuronY = height / 2 + (n - (neuronCount - 1) / 2) * 40;
452
+
453
+ // Neuron circle
454
+ const neuron = document.createElementNS("http://www.w3.org/2000/svg", "circle");
455
+ neuron.setAttribute("cx", layerX);
456
+ neuron.setAttribute("cy", neuronY);
457
+ neuron.setAttribute("r", neuronRadius);
458
+ neuron.setAttribute("class", "neuron");
459
+
460
+ if (isInput) {
461
+ neuron.setAttribute("fill", "#60A5FA"); // Blue for input
462
+ } else if (isOutput) {
463
+ neuron.setAttribute("fill", "#10B981"); // Green for output
464
+ } else {
465
+ neuron.setAttribute("fill", "#F59E0B"); // Yellow for hidden
466
+ }
467
+
468
+ svg.appendChild(neuron);
469
+
470
+ // Neuron label
471
+ if (isInput) {
472
+ const labels = ["ERA", "BA", "HR", "Errors"];
473
+ const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
474
+ text.setAttribute("x", layerX - 50);
475
+ text.setAttribute("y", neuronY + 5);
476
+ text.setAttribute("text-anchor", "end");
477
+ text.setAttribute("class", "text-xs font-medium fill-gray-700");
478
+ text.textContent = labels[n];
479
+ svg.appendChild(text);
480
+ } else if (isOutput) {
481
+ const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
482
+ text.setAttribute("x", layerX + 50);
483
+ text.setAttribute("y", neuronY + 5);
484
+ text.setAttribute("text-anchor", "start");
485
+ text.setAttribute("class", "text-xs font-medium fill-gray-700");
486
+ text.textContent = "Loss %";
487
+ svg.appendChild(text);
488
+ }
489
+ }
490
+ }
491
+ }
492
+
493
+ function animateNetwork() {
494
+ const svg = document.getElementById('networkSvg');
495
+ const connections = [];
496
+
497
+ const width = 500;
498
+ const height = 300;
499
+ const layerCount = config.hiddenLayers + 2;
500
+ const neuronRadius = 15;
501
+
502
+ // Create connections between layers
503
+ for (let layer = 0; layer < layerCount - 1; layer++) {
504
+ const isFirstLayer = layer === 0;
505
+ const isLastLayer = layer === layerCount - 2;
506
+
507
+ let fromNeuronCount;
508
+ if (isFirstLayer) fromNeuronCount = 4;
509
+ else fromNeuronCount = config.neuronsPerLayer;
510
+
511
+ let toNeuronCount;
512
+ if (isLastLayer) toNeuronCount = 1;
513
+ else toNeuronCount = config.neuronsPerLayer;
514
+
515
+ const fromLayerX = 50 + (width - 100) * (layer / (layerCount - 1));
516
+ const toLayerX = 50 + (width - 100) * ((layer + 1) / (layerCount - 1));
517
+
518
+ for (let from = 0; from < fromNeuronCount; from++) {
519
+ const fromY = height / 2 + (from - (fromNeuronCount - 1) / 2) * 40;
520
+
521
+ for (let to = 0; to < toNeuronCount; to++) {
522
+ const toY = height / 2 + (to - (toNeuronCount - 1) / 2) * 40;
523
+
524
+ const line = document.createElementNS("http://www.w3.org/2000/svg", "line");
525
+ line.setAttribute("x1", fromLayerX + neuronRadius);
526
+ line.setAttribute("y1", fromY);
527
+ line.setAttribute("x2", toLayerX - neuronRadius);
528
+ line.setAttribute("y2", toY);
529
+ line.setAttribute("stroke", "#9CA3AF");
530
+ line.setAttribute("stroke-width", "1");
531
+ line.setAttribute("class", "connection");
532
+ svg.appendChild(line);
533
+
534
+ connections.push(line);
535
+ }
536
+ }
537
+ }
538
+
539
+ // Animate connections with staggered delay
540
+ connections.forEach((conn, i) => {
541
+ setTimeout(() => {
542
+ conn.style.strokeDashoffset = "0";
543
+ }, i * 20);
544
+ });
545
+ }
546
+
547
+ function predictLossProbability() {
548
+ if (!net.trainOpts) {
549
+ predictionText.textContent = "Please train the network first";
550
+ predictionResult.classList.remove('hidden');
551
+ predictionResult.className = "mt-4 p-4 rounded-lg bg-yellow-50";
552
+ return;
553
+ }
554
+
555
+ // Get input values
556
+ const era = parseFloat(eraInput.value) || 4.50;
557
+ const ba = parseFloat(baInput.value) || 0.250;
558
+ const hr = parseInt(hrInput.value) || 150;
559
+ const errors = parseInt(errorsInput.value) || 100;
560
+
561
+ // Normalize inputs
562
+ const normalizedInput = {
563
+ era: normalize(era, 2.5, 6.0),
564
+ ba: normalize(ba, 0.220, 0.300),
565
+ hr: normalize(hr, 100, 300),
566
+ errors: normalize(errors, 50, 150)
567
+ };
568
+
569
+ // Make prediction
570
+ const output = net.run(normalizedInput);
571
+ const lossProbability = output.loss;
572
+ const percentage = Math.round(lossProbability * 100);
573
+
574
+ // Display result
575
+ predictionText.textContent = `Based on the team's stats (ERA: ${era.toFixed(2)}, BA: ${ba.toFixed(3)}, HR: ${hr}, Errors: ${errors}), the predicted loss probability is:`;
576
+ predictionPercentage.textContent = `${percentage}%`;
577
+
578
+ // Update progress ring
579
+ const circle = document.querySelector('.progress-ring__circle:last-child');
580
+ const radius = circle.r.baseVal.value;
581
+ const circumference = radius * 2 * Math.PI;
582
+ const offset = circumference - (percentage / 100) * circumference;
583
+
584
+ circle.style.strokeDashoffset = offset;
585
+
586
+ // Set color based on probability
587
+ if (percentage > 70) {
588
+ circle.style.stroke = "#EF4444"; // red
589
+ predictionPercentage.className = "text-2xl font-bold text-red-600";
590
+ } else if (percentage > 50) {
591
+ circle.style.stroke = "#F59E0B"; // orange
592
+ predictionPercentage.className = "text-2xl font-bold text-yellow-600";
593
+ } else {
594
+ circle.style.stroke = "#10B981"; // green
595
+ predictionPercentage.className = "text-2xl font-bold text-green-600";
596
+ }
597
+
598
+ predictionResult.classList.remove('hidden');
599
+ predictionResult.className = "mt-4 p-4 rounded-lg bg-blue-50";
600
+ }
601
+
602
+ function renderTeamCards() {
603
+ teamPredictions.innerHTML = '';
604
+
605
+ baseballTeams.forEach(team => {
606
+ const card = document.createElement('div');
607
+ card.className = 'bg-white rounded-lg shadow-md p-4 team-card hover:shadow-lg transition-all';
608
+ card.innerHTML = `
609
+ <div class="flex items-center mb-3">
610
+ <div class="text-2xl mr-3">${team.logo}</div>
611
+ <h3 class="font-semibold text-gray-800">${team.name}</h3>
612
+ </div>
613
+ <div class="grid grid-cols-2 gap-2 text-sm mb-3">
614
+ <div><span class="text-gray-500">ERA:</span> ${team.era.toFixed(2)}</div>
615
+ <div><span class="text-gray-500">BA:</span> ${team.ba.toFixed(3)}</div>
616
+ <div><span class="text-gray-500">HR:</span> ${team.hr}</div>
617
+ <div><span class="text-gray-500">Errors:</span> ${team.errors}</div>
618
+ </div>
619
+ <div class="flex items-center">
620
+ <button class="w-full bg-blue-100 hover:bg-blue-200 text-blue-800 py-2 px-3 rounded flex items-center justify-center predict-btn" data-team='${JSON.stringify(team)}'>
621
+ <i class="fas fa-calculator mr-2 text-xs"></i> Predict Performance
622
+ </button>
623
+ </div>
624
+ `;
625
+ teamPredictions.appendChild(card);
626
+ });
627
+
628
+ // Add event listeners to predict buttons
629
+ document.querySelectorAll('.predict-btn').forEach(btn => {
630
+ btn.addEventListener('click', function() {
631
+ const team = JSON.parse(this.getAttribute('data-team'));
632
+ eraInput.value = team.era;
633
+ baInput.value = team.ba;
634
+ hrInput.value = team.hr;
635
+ errorsInput.value = team.errors;
636
+
637
+ if (net.trainOpts) {
638
+ predictLossProbability();
639
+ } else {
640
+ predictionText.textContent = "Please train the network first";
641
+ predictionResult.classList.remove('hidden');
642
+ predictionResult.className = "mt-4 p-4 rounded-lg bg-yellow-50";
643
+ }
644
+ });
645
+ });
646
+ }
647
+ });
648
+ </script>
649
+ <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=MarcRyan/btp" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
650
+ </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fix this