-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMLQuizGame.html
681 lines (668 loc) · 29.6 KB
/
MLQuizGame.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
<!DOCTYPE html>
<html>
<head>
<title>Quiz Game</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
font-family: Arial, sans-serif;
width: 75%;
margin: 0 auto;
background-color: #F5F5F5;
color: #333;
padding-top: 100px;
line-height: 2em;
}
.question {
font-size: 24px;
margin-bottom: 20px;
}
.options {
display: flex;
flex-direction: column;
gap: 10px;
}
.option {
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.option.active:hover {
background-color: #f0f0f0;
}
.correct {
background-color: #a4d6a2;
}
.wrong {
background-color: #f0a4a4;
}
.progress {
height: 30px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container mt-5">
<div class="progress">
<div class="progress-bar" id="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="question" id="question"></div>
<div class="options" id="options"></div>
<button id="retryButton" class="btn btn-primary mt-3" style="display:none;">Try Again</button>
</div>
<script>
const all_questions = [
{
question: "What is Machine Learning?",
options: ["A branch of AI focused on computer vision", "A technique for developing software", "A method for data analysis that automates model building", "A type of computer hardware"],
correct: 2
},
{
question: "Which of the following is a supervised learning task?",
options: ["Clustering", "Regression", "Dimensionality Reduction", "Association Rules"],
correct: 1
},
{
question: "What is the main difference between supervised and unsupervised learning?",
options: ["The presence of labeled data", "The complexity of algorithms", "The type of data used", "The computational resources required"],
correct: 0
},
{
question: "What is overfitting in machine learning?",
options: ["When a model performs well on training data but poorly on new data", "When a model is too simple to capture the underlying pattern", "When a model uses too much computational power", "When a model's predictions are always incorrect"],
correct: 0
},
{
question: "Which of the following is a technique to avoid overfitting?",
options: ["Increasing model complexity", "Reducing training data size", "Regularization", "Using a simpler algorithm"],
correct: 2
},
{
question: "What is a confusion matrix?",
options: ["A matrix that displays the confusion of the model", "A tool to visualize data distribution", "A table used to evaluate the performance of a classification model", "A matrix used for matrix operations in linear algebra"],
correct: 2
},
{
question: "What is precision in the context of classification metrics?",
options: ["The number of true positive predictions", "The proportion of true positive predictions to the total positive predictions", "The proportion of true positive predictions to the total actual positives", "The overall accuracy of the model"],
correct: 1
},
{
question: "What is recall in the context of classification metrics?",
options: ["The number of true positive predictions", "The proportion of true positive predictions to the total positive predictions", "The proportion of true positive predictions to the total actual positives", "The overall accuracy of the model"],
correct: 2
},
{
question: "What is the purpose of the training set in machine learning?",
options: ["To test the model's performance", "To validate the model's hyperparameters", "To train the model to learn the underlying patterns", "To check the model's robustness"],
correct: 2
},
{
question: "What is the purpose of the test set in machine learning?",
options: ["To test the model's performance", "To validate the model's hyperparameters", "To train the model to learn the underlying patterns", "To check the model's robustness"],
correct: 0
},
{
question: "Which algorithm is commonly used for classification tasks?",
options: ["K-Means Clustering", "Principal Component Analysis", "Linear Regression", "Support Vector Machine"],
correct: 3
},
{
question: "Which algorithm is commonly used for regression tasks?",
options: ["K-Means Clustering", "Principal Component Analysis", "Linear Regression", "Support Vector Machine"],
correct: 2
},
{
question: "What is a hyperparameter in machine learning?",
options: ["A parameter that is set before the learning process begins", "A parameter that is learned during the training process", "A parameter that is used to predict the target variable", "A parameter that is used to measure the model's performance"],
correct: 0
},
{
question: "What is cross-validation in machine learning?",
options: ["A technique to compare different models", "A technique to test the model's performance on unseen data", "A technique to split the dataset into training and testing sets", "A technique to estimate the performance of a model by partitioning the data"],
correct: 3
},
{
question: "What is the purpose of feature scaling in machine learning?",
options: ["To increase the model's accuracy", "To reduce the computational complexity", "To make the features more interpretable", "To bring different features to a similar scale"],
correct: 3
},
{
question: "What is the purpose of the activation function in a neural network?",
options: ["To normalize the output", "To allow the network to learn complex patterns", "To reduce computational complexity", "To increase the speed of training"],
correct: 1
},
{
question: "What is the difference between a deep neural network and a shallow neural network?",
options: ["The number of hidden layers", "The type of activation function used", "The size of the input data", "The learning rate"],
correct: 0
},
{
question: "What is the role of the loss function in machine learning?",
options: ["To define the model architecture", "To initialize the model weights", "To evaluate the model's performance", "To update the model parameters"],
correct: 2
},
{
question: "Which of the following is a commonly used optimizer in deep learning?",
options: ["Linear regression", "K-means clustering", "Gradient descent", "Support vector machine"],
correct: 2
},
{
question: "What is the purpose of dropout in a neural network?",
options: ["To reduce the number of neurons", "To prevent overfitting", "To increase model accuracy", "To speed up training"],
correct: 1
},
{
question: "What is the difference between batch gradient descent and stochastic gradient descent?",
options: ["The number of epochs", "The size of the data used for each update", "The learning rate", "The type of loss function"],
correct: 1
},
{
question: "What is a hyperparameter in machine learning?",
options: ["A parameter that is learned from the data", "A parameter set before the training process", "A parameter that is updated during training", "A parameter that defines the model architecture"],
correct: 1
},
{
question: "What is the bias-variance tradeoff?",
options: ["The tradeoff between model complexity and model interpretability", "The tradeoff between training time and model accuracy", "The tradeoff between the model's ability to generalize and its accuracy on training data", "The tradeoff between the number of features and the number of samples"],
correct: 2
},
{
question: "What is a feature in machine learning?",
options: ["A unique attribute of the data", "A type of machine learning model", "A technique for data preprocessing", "A method for model evaluation"],
correct: 0
},
{
question: "What is the purpose of feature scaling in machine learning?",
options: ["To increase the number of features", "To reduce the dimensionality of the data", "To make the training process faster", "To ensure that features contribute equally to the model"],
correct: 3
},
{
question: "What is regularization in machine learning?",
options: [
"The process of training a model using a regular dataset",
"A technique to reduce overfitting by adding a penalty term to the loss function",
"The process of normalizing the input features of a model",
"A technique to increase the variance of a model"
],
correct: 1
},
{
question: "What is the purpose of the activation function in a neural network?",
options: [
"To normalize the input features",
"To aggregate the input from all neurons",
"To introduce non-linearity into the model",
"To reduce the dimensionality of the input data"
],
correct: 2
},
{
question: "What is the difference between supervised and unsupervised learning?",
options: [
"Supervised learning requires labeled data, while unsupervised learning does not",
"Supervised learning is faster than unsupervised learning",
"Unsupervised learning requires more computational resources",
"Supervised learning can only be used for classification tasks"
],
correct: 0
},
{
question: "What is a convolutional neural network (CNN) primarily used for?",
options: [
"Time series analysis",
"Image recognition and processing",
"Natural language processing",
"Reinforcement learning"
],
correct: 1
},
{
question: "What is the difference between a generative and discriminative model?",
options: [
"Generative models can generate new data points, while discriminative models cannot",
"Discriminative models are used for regression, while generative models are used for classification",
"Generative models are faster to train than discriminative models",
"Discriminative models focus on the boundary between classes, while generative models focus on the distribution of individual classes"
],
correct: 0
},
{
question: "What is the purpose of dropout in a neural network?",
options: [
"To speed up the training process",
"To reduce the number of parameters in the model",
"To prevent overfitting by randomly dropping units during training",
"To increase the robustness of the network to noisy data"
],
correct: 2
},
{
question: "What is the difference between batch gradient descent and stochastic gradient descent?",
options: [
"Batch gradient descent computes the gradient using the entire dataset, while stochastic gradient descent uses only one sample",
"Stochastic gradient descent is always faster than batch gradient descent",
"Batch gradient descent is more prone to local minima than stochastic gradient descent",
"Stochastic gradient descent requires more memory than batch gradient descent"
],
correct: 0
},
{
question: "What is a decision tree?",
options: [
"A model used for regression tasks",
"A tree-like graph used for classification and regression tasks",
"A neural network architecture",
"A clustering algorithm"
],
correct: 1
},
{
question: "What is the role of the cost function in machine learning?",
options: [
"To define the architecture of a neural network",
"To determine the optimal number of clusters in a dataset",
"To measure the performance of a model and guide the optimization process",
"To select the most important features in a dataset"
],
correct: 2
},
{
question: "What is the difference between precision and recall?",
options: [
"Precision is the ratio of true positives to false positives, while recall is the ratio of true positives to false negatives",
"Precision is used for regression tasks, while recall is used for classification tasks",
"Recall is the accuracy of the model, while precision is the model's completeness",
"Precision measures the model's performanceon the training data, while recall measures the model's performance on the test data"
],
correct: 0
},
{
question: "What is cross-validation in machine learning?",
options: [
"A technique to combine predictions from multiple models",
"A method to evaluate the performance of a model on unseen data",
"A process to split the dataset into training and test sets",
"A strategy to update the weights of a neural network"
],
correct: 1
},
{
question: "What is the purpose of feature scaling in machine learning?",
options: [
"To increase the computational efficiency of the model",
"To reduce the dimensionality of the dataset",
"To ensure that features contribute equally to the model's performance",
"To balance the bias and variance of the model"
],
correct: 2
},
{
question: "What is the main advantage of using ensemble methods in machine learning?",
options: [
"They require less computational resources",
"They are easier to interpret than single models",
"They can improve the model's performance by combining multiple models",
"They reduce the need for feature engineering"
],
correct: 2
},
{
question: "What is the difference between a shallow and a deep neural network?",
options: [
"Shallow networks have fewer layers, while deep networks have more layers",
"Deep networks are always better than shallow networks",
"Shallow networks are used for image processing, while deep networks are used for text processing",
"Deep networks require less training data than shallow networks"
],
correct: 0
},
{
question: "What is the purpose of transfer learning?",
options: [
"To transfer knowledge from one domain to another",
"To reduce the size of the neural network",
"To increase the speed of the training process",
"To prevent overfitting in the model"
],
correct: 0
},
{
question: "What is the difference between hard and soft clustering?",
options: [
"Hard clustering assigns each data point to a single cluster, while soft clustering assigns probabilities to each cluster",
"Soft clustering is faster than hard clustering",
"Hard clustering is used for classification tasks, while soft clustering is used for regression tasks",
"Soft clustering requires more computational resources than hard clustering"
],
correct: 0
},
{
question: "What is the significance of the learning rate in gradient descent?",
options: [
"It determines the speed at which the model learns",
"It defines the architecture of the neural network",
"It measures the accuracy of the model",
"It selects the most important features for the model"
],
correct: 0
},
{
question: "What is the difference between a parametric and a non-parametric model?",
options: [
"Parametric models have a fixed number of parameters, while non-parametric models do not",
"Non-parametric models are always more accurate than parametric models",
"Parametric models are used for classification tasks, while non-parametric models are used for regression tasks",
"Non-parametric models require less training data than parametric models"
],
correct: 0
},
{
question: "What is the purpose of the ReLU (Rectified Linear Unit) activation function?",
options: [
"To normalize the input features",
"To introduce non-linearity into the model while being computationally efficient",
"To reduce the dimensionality of the input data",
"To aggregate the input from all neurons"
],
correct: 1
},
{
question: "What is the difference between L1 and L2 regularization?",
options: [
"L1 regularization adds the absolute value of the weights to the loss function, while L2 adds the squared value of the weights",
"L2 regularization is always better than L1 regularization",
"L1 regularization is used for regression tasks, while L2 regularization is used for classification tasks",
"L2 regularization requires more computational resources than L1 regularization"
],
correct: 0
},
{
question: "What is the role of the optimizer in training a neural network?",
options: [
"To define the architecture of the network",
"To select the most important features for the network",
"To update the weights of the network to minimize the loss function",
"To evaluate the performance of the network on the test data"
],
correct: 2
},
{
question: "What is the purpose of the softmax function in a neural network?",
options: [
"To introduce non-linearity into the network",
"To normalize the output of the final layerfor classification tasks",
"To reduce the dimensionality of the input data",
"To aggregate the input from all neurons"
],
correct: 1
},
{
question: "What is the difference between a static and a dynamic model in machine learning?",
options: [
"Static models do not change over time, while dynamic models can adapt to new data",
"Dynamic models are always more accurate than static models",
"Static models are used for time series analysis, while dynamic models are used for classification tasks",
"Dynamic models require more computational resources than static models"
],
correct: 0
},
{
question: "What is the significance of the number of layers in a neural network?",
options: [
"It determines the speed at which the network learns",
"It defines the complexity and depth of the network",
"It measures the accuracy of the network",
"It selects the most important features for the network"
],
correct: 1
},
{
question: "What is the purpose of data augmentation in machine learning?",
options: [
"To increase the size of the training dataset",
"To reduce the dimensionality of the dataset",
"To ensure that features contribute equally to the model's performance",
"To balance the bias and variance of the model"
],
correct: 0
},
{
question: "What is the difference between an epoch and an iteration in neural network training?",
options: [
"An epoch is a single pass through the entire dataset, while an iteration is a single update of the model's weights",
"An iteration is always longer than an epoch",
"An epoch is used for regression tasks, while an iteration is used for classification tasks",
"An iteration requires more computational resources than an epoch"
],
correct: 0
},
{
question: "What is the purpose of the pooling layer in a convolutional neural network?",
options: [
"To increase the computational efficiency of the network",
"To reduce the spatial dimensions of the feature maps",
"To introduce non-linearity into the network",
"To aggregate the input from all neurons"
],
correct: 1
},
{
question: "What is the difference between a one-hot encoding and a label encoding?",
options: [
"One-hot encoding represents categorical variables as binary vectors, while label encoding assigns a unique integer to each category",
"Label encoding is always better than one-hot encoding",
"One-hot encoding is used for regression tasks, while label encoding is used for classification tasks",
"Label encoding requires more computational resources than one-hot encoding"
],
correct: 0
},
{
question: "What is the role of the loss function in machine learning?",
options: [
"To define the architecture of the model",
"To select the most important features for the model",
"To measure the performance of the model and guide the optimization process",
"To evaluate the performance of the model on the test data"
],
correct: 2
},
{
question: "What is the purpose of the stride in a convolutional layer?",
options: [
"To determine the number of filters in the layer",
"To control the overlap between the receptive fields",
"To increase the depth of the feature maps",
"To aggregate the input from all neurons"
],
correct: 1
},
{
question: "What is the difference between a feedforward and a recurrent neural network?",
options: [
"Feedforward networks have cycles in their graph structure, while recurrent networks do not",
"Recurrent networks are always more accurate than feedforward networks",
"Feedforward networks are used for time series analysis, while recurrent networks are used for sequential data processing",
"Recurrent networks require more computational resources than feedforward networks"
],
correct: 2
},
{
question: "What is the purpose of the early stopping technique in training a model?",
options: [
"To prevent overfitting by stopping the training process when the model's performance on the validation set starts to degrade",
"To increase the speed of the training process",
"To reduce the size of the neural network",
"To balance the bias and variance of the model"
],
correct: 0
},
{
question: "What is the difference between a time series and a sequence model?",
options: [
"Time series models are used for forecasting, while sequence models are used for natural language processing",
"Sequence models require more computational resources than time series models",
"Time series models are used for classification tasks, while sequence models are used for regression tasks",
"Sequence models can handle variable-length input, while time series models cannot"
],
correct: 0
},
{
question: "What is the significance of the batch size in training a neural network?",
options: [
"It determines the number of samples used to update the weights of the network",
"It defines the architecture of the neural network",
"It measures the accuracy of the network",
"It selects the most important features for the network"
],
correct: 0
},
{
question: "What is the difference between online and batch learning?",
options: [
"Online learning updates the model with each new data point, while batch learning updates the model with batches of data",
"Batch learning is always more accurate than online learning",
"Online learning is used for classification tasks, while batch learning is used for regression tasks",
"Batch learning requires more computational resources than online learning"
],
correct: 0
},
{
question: "What is the purpose of data augmentation in machine learning?",
options: [
"To reduce the size of the dataset",
"To increase the diversity of the training data and reduce overfitting",
"To speed up the training process",
"To select the most important features in the dataset"
],
correct: 1
},
{
question: "What is the difference between a linear and a nonlinear model?",
options: [
"Linear models can only model linear relationships, while nonlinear models can model complex relationships",
"Nonlinear models are always more accurate than linear models",
"Linear models are used for classification tasks, while nonlinear models are used for regression tasks",
"Nonlinear models require more computational resources than linear models"
],
correct: 0
},
{
question: "What is the purpose of the pooling layer in a convolutional neural network?",
options: [
"To normalize the input features",
"To introduce non-linearity into the network",
"To reduce the spatial dimensions of the input data",
"To aggregate the input from all neurons"
],
correct: 2
},
{
question: "What is the difference between a static and a dynamic model?",
options: [
"Static models do not change over time, while dynamic models can adapt to new data",
"Dynamic models are always more accurate than static models",
"Static models are used for classification tasks, while dynamic models are used for regression tasks",
"Dynamic models require more computational resources than static models"
],
correct: 0
},
{
question: "What is the significance of the epoch number in training a neural network?",
options: [
"It determines the number of times the entire dataset is used to update the weights of the network",
"It defines the architecture of the neural network",
"It measures the accuracy of the network",
"It selects the most important features for the network"
],
correct: 0
},
{
question: "What is the difference between an autoencoder and a variational autoencoder?",
options: [
"Autoencoders are used for dimensionality reduction, while variational autoencoders are used for generative tasks",
"Variational autoencoders are always more accurate than autoencoders",
"Autoencoders are used for classification tasks, while variational autoencoders are used for regression tasks",
"Variational autoencoders require more computational resources than autoencoders"
],
correct: 0
},
{
question: "What is the purpose of the loss function in training a neural network?",
options: [
"To define the architecture of the network",
"To select the most important features for the network",
"To measure the performance of the network and guide the optimization process",
"To evaluate the performance of the network on the test data"
],
correct: 2
},
{
question: "What is the significance of the F1 score in evaluating classifiers?",
options: [
"It is the harmonic mean of precision and recall",
"It defines the architecture of the neural network",
"It measures the accuracy of the model",
"It selects the most important features for the model"
],
correct: 0
}
]
function getRandomQuestions(questions, sampleSize) {
const shuffled = [...questions].sort(() => 0.5 - Math.random());
return shuffled.slice(0, sampleSize);
}
const questions = getRandomQuestions(all_questions, 10); // Get 10 random questions
let currentQuestion = 0;
let score = 0;
function resetGame() {
currentQuestion = 0;
score = 0;
displayQuestion();
document.getElementById("retryButton").style.display = "none"; // Hide retry button
}
function displayQuestion() {
const progressBar = document.getElementById("progress-bar");
progressBar.style.width = `${(currentQuestion / questions.length) * 100}%`;
if (currentQuestion < questions.length) {
document.getElementById("question").textContent = questions[currentQuestion].question;
const optionsContainer = document.getElementById("options");
optionsContainer.innerHTML = "";
questions[currentQuestion].options.forEach((option, index) => {
const optionElement = document.createElement("div");
optionElement.className = "option";
optionElement.textContent = option;
optionElement.classList.add("active");
optionElement.addEventListener("click", () => checkAnswer(index));
optionsContainer.appendChild(optionElement);
});
} else {
document.getElementById("question").textContent = `Game Over! Your score: ${score}/${questions.length}`;
document.getElementById("options").innerHTML = "";
const retryButton = document.getElementById("retryButton");
retryButton.style.display = "block"; // Show retry button
retryButton.addEventListener("click", resetGame);
}
}
function checkAnswer(selectedIndex) {
const options = document.querySelectorAll(".option");
options.forEach(option => option.classList.remove("active"));
if (selectedIndex === questions[currentQuestion].correct) {
score++;
options[selectedIndex].classList.add("correct");
} else {
options[questions[currentQuestion].correct].classList.add("correct")
options[selectedIndex].classList.add("wrong");
}
setTimeout(() => {
currentQuestion++;
displayQuestion();
}, 700);
}
displayQuestion();
</script>
</body>
</html>