eaglelandsonce commited on
Commit
aef29cd
·
verified ·
1 Parent(s): 24e146a

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +220 -18
index.html CHANGED
@@ -1,19 +1,221 @@
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
+ <title>Algorithm Fact or Fiction</title>
6
+ <link rel="preconnect" href="https://fonts.gstatic.com" />
7
+ <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;600&display=swap" rel="stylesheet">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
9
+ <style>
10
+ * { margin: 0; padding: 0; box-sizing: border-box; }
11
+ :root {
12
+ --bg1:#c9e8ff; --bg2:#fde2ff; --ink:#222; --ink-sub:#555;
13
+ --brand:#2563eb; --brand-2:#22c55e; --good:#16a34a; --bad:#dc2626;
14
+ --card:#ffffffcc;
15
+ }
16
+ body {
17
+ font-family: 'Poppins', sans-serif;
18
+ background: radial-gradient(1200px 600px at 20% 0%, var(--bg1), transparent 60%),
19
+ radial-gradient(1200px 600px at 80% 0%, var(--bg2), transparent 60%),
20
+ #f6f7fb;
21
+ min-height: 100vh;
22
+ display: flex;
23
+ flex-direction: column;
24
+ align-items: center;
25
+ justify-content: flex-start;
26
+ padding: 2rem 1rem;
27
+ color: var(--ink);
28
+ }
29
+ h1 { text-align: center; margin-bottom: .25rem; font-weight: 600; font-size: 2.2rem; }
30
+ #subtitle { text-align:center; margin-bottom:1rem; color: var(--ink-sub); }
31
+ #source-link { text-align: center; margin-bottom: 1.25rem; font-size: .95rem; }
32
+ #source-link a { color: var(--ink); text-decoration: underline; }
33
+ #game-container {
34
+ background: var(--card);
35
+ width: 100%; max-width: 820px;
36
+ padding: 2rem; border-radius: 16px;
37
+ box-shadow: 0 10px 24px rgba(0,0,0,.15);
38
+ display: flex; flex-direction: column; align-items: center;
39
+ }
40
+ .progress-container {
41
+ width: 100%; background:#ececec; border-radius: 999px; overflow: hidden; margin-bottom: 1rem;
42
+ }
43
+ .progress-bar { height: 14px; width:0%; background: linear-gradient(90deg,var(--brand),var(--brand-2)); transition: width .3s ease; }
44
+ #statement {
45
+ font-size: 1.25rem; line-height: 1.5; text-align: center; color: #333;
46
+ min-height: 84px; margin: .75rem 0 1rem;
47
+ }
48
+ .btn-group { display:flex; gap:.75rem; flex-wrap:wrap; justify-content:center; margin: .25rem 0 1rem; }
49
+ button {
50
+ padding: .75rem 1.25rem; border: none; border-radius: 999px; cursor: pointer;
51
+ background: var(--brand); color: #fff; font-weight: 600; letter-spacing:.2px;
52
+ transition: transform .15s ease, box-shadow .15s ease, background .2s ease;
53
+ }
54
+ button.secondary { background:#111827; }
55
+ button:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0,0,0,.15); }
56
+ #result {
57
+ margin-top: .5rem; padding: .75rem 1rem; border-radius: 10px; font-weight: 700; text-align: center; display:none;
58
+ }
59
+ #result.correct { display:block; background:#dcfce7; color:#14532d; }
60
+ #result.incorrect { display:block; background:#fee2e2; color:#7f1d1d; }
61
+ #explanation {
62
+ margin-top: .75rem; padding: 1rem; background:#f9fafb; color:#374151; border-radius:12px; display:none;
63
+ }
64
+ #score { margin-top: .75rem; font-weight: 700; }
65
+ #controls { display:flex; gap:.5rem; margin-top:.5rem; }
66
+ #controls button { background:#0f766e; }
67
+ #restart-btn { background:#6b21a8; }
68
+ </style>
69
+ </head>
70
+ <body>
71
+ <h1>Algorithm Fact or Fiction</h1>
72
+ <div id="subtitle">Test your knowledge of machine learning algorithms</div>
73
+ <div id="source-link">
74
+ Source: <a href="https://www.linkedin.com/pulse/practical-guide-five-core-machine-learning-algorithms-michael-lively-ntlfe/" target="_blank" rel="noopener">
75
+ Practical Guide to Five Core Machine Learning Algorithms (LinkedIn)
76
+ </a>
77
+ </div>
78
+
79
+ <div id="game-container">
80
+ <div class="progress-container"><div class="progress-bar" id="progress-bar"></div></div>
81
+ <div id="statement">Loading statement...</div>
82
+
83
+ <div class="btn-group">
84
+ <button onclick="guess(true)">Fact</button>
85
+ <button class="secondary" onclick="guess(false)">Fiction</button>
86
+ </div>
87
+
88
+ <div id="result"></div>
89
+ <div id="explanation"></div>
90
+
91
+ <div id="controls">
92
+ <button id="next-btn" style="display:none;" onclick="nextStatement()">Next</button>
93
+ <button id="restart-btn" style="display:none;" onclick="startGame()">Restart</button>
94
+ </div>
95
+
96
+ <div id="score"></div>
97
+ </div>
98
+
99
+ <script>
100
+ // Conceptual ML questions from the LinkedIn article
101
+ const statements = [
102
+ {
103
+ text: "Decision Trees are always resistant to overfitting without pruning.",
104
+ isFact: false,
105
+ explanation: "Fiction. Decision Trees can overfit easily unless pruning or depth limits are applied."
106
+ },
107
+ {
108
+ text: "K-Nearest Neighbors requires no training phase because it stores the dataset and compares during prediction.",
109
+ isFact: true,
110
+ explanation: "Fact. KNN is a 'lazy learner' and makes predictions by comparing to stored neighbors."
111
+ },
112
+ {
113
+ text: "Random Forest reduces overfitting by averaging the predictions of multiple Decision Trees.",
114
+ isFact: true,
115
+ explanation: "Fact. Random Forest ensembles many trees to stabilize results and generalize better."
116
+ },
117
+ {
118
+ text: "Support Vector Machines always perform best with large datasets, regardless of tuning.",
119
+ isFact: false,
120
+ explanation: "Fiction. SVMs can be computationally expensive with large datasets and require careful tuning."
121
+ },
122
+ {
123
+ text: "Logistic Regression can only be used for binary classification tasks.",
124
+ isFact: false,
125
+ explanation: "Fiction. While logistic regression is commonly binary, it can be extended to multiclass via one-vs-rest or softmax."
126
+ },
127
+ {
128
+ text: "The 'max_depth' hyperparameter in Decision Trees controls how complex the model can become.",
129
+ isFact: true,
130
+ explanation: "Fact. Restricting max_depth prevents trees from growing too complex and overfitting."
131
+ },
132
+ {
133
+ text: "KNN is highly sensitive to irrelevant or unscaled features.",
134
+ isFact: true,
135
+ explanation: "Fact. Because KNN depends on distances, scaling and feature selection are crucial."
136
+ },
137
+ {
138
+ text: "Random Forest models are always faster to train than a single Decision Tree.",
139
+ isFact: false,
140
+ explanation: "Fiction. Training many trees is slower than training a single tree, though performance may be better."
141
+ },
142
+ {
143
+ text: "The 'kernel' parameter in SVM determines how data is mapped into higher-dimensional space.",
144
+ isFact: true,
145
+ explanation: "Fact. Choosing the right kernel (linear, RBF, polynomial) is key to SVM performance."
146
+ },
147
+ {
148
+ text: "Logistic Regression uses a sigmoid function to map predictions to probabilities.",
149
+ isFact: true,
150
+ explanation: "Fact. The sigmoid maps real values into [0,1], giving interpretable probabilities."
151
+ }
152
+ ];
153
+
154
+ // Game logic
155
+ let currentIndex = 0, score = 0, answered = false;
156
+ function shuffle(arr) {
157
+ for (let i = arr.length - 1; i > 0; i--) {
158
+ const j = Math.floor(Math.random() * (i + 1));
159
+ [arr[i], arr[j]] = [arr[j], arr[i]];
160
+ }
161
+ }
162
+ function startGame() {
163
+ shuffle(statements);
164
+ currentIndex = 0; score = 0; answered = false;
165
+ document.getElementById('restart-btn').style.display = 'none';
166
+ loadStatement(); updateScore();
167
+ }
168
+ function loadStatement() {
169
+ if (currentIndex >= statements.length) return endGame();
170
+ const s = statements[currentIndex];
171
+ document.getElementById('statement').textContent = s.text;
172
+ document.getElementById('result').style.display = 'none';
173
+ document.getElementById('explanation').style.display = 'none';
174
+ document.getElementById('next-btn').style.display = 'none';
175
+ answered = false; updateProgress();
176
+ }
177
+ function guess(isFactGuess) {
178
+ if (answered) return;
179
+ answered = true;
180
+ const correct = statements[currentIndex].isFact;
181
+ const resultEl = document.getElementById('result');
182
+ if (isFactGuess === correct) {
183
+ resultEl.textContent = 'Correct!';
184
+ resultEl.className = 'correct';
185
+ score++;
186
+ } else {
187
+ resultEl.textContent = 'Incorrect!';
188
+ resultEl.className = 'incorrect';
189
+ }
190
+ resultEl.style.display = 'block';
191
+ const expEl = document.getElementById('explanation');
192
+ expEl.textContent = statements[currentIndex].explanation + " (See source link above.)";
193
+ expEl.style.display = 'block';
194
+ document.getElementById('next-btn').style.display = 'inline-block';
195
+ updateScore();
196
+ }
197
+ function nextStatement() {
198
+ currentIndex++;
199
+ if (currentIndex < statements.length) loadStatement();
200
+ else endGame();
201
+ }
202
+ function updateScore() {
203
+ document.getElementById('score').textContent = `Score: ${score} / ${statements.length}`;
204
+ }
205
+ function updateProgress() {
206
+ document.getElementById('progress-bar').style.width = `${(currentIndex / statements.length) * 100}%`;
207
+ }
208
+ function endGame() {
209
+ const pct = Math.round((score / statements.length) * 100);
210
+ document.getElementById('statement').textContent =
211
+ `Game Over! You scored ${score} of ${statements.length} (${pct}%).`;
212
+ document.getElementById('result').style.display = 'none';
213
+ document.getElementById('explanation').style.display = 'none';
214
+ document.getElementById('next-btn').style.display = 'none';
215
+ document.getElementById('restart-btn').style.display = 'inline-block';
216
+ document.getElementById('progress-bar').style.width = '100%';
217
+ }
218
+ startGame();
219
+ </script>
220
+ </body>
221
  </html>