Practice
import numpy as np
from sklearn.metrics import accuracy_score
y_true = np.array([1, 0, 1, 1, 0])
y_pred = np.array([0, 0, 1, 0, 0])
accuracy = accuracy_score(y_true, y_pred)
print(f'Accuracy: {accuracy:.2f}')
Solution
Step 1: Calculate accuracy
Compare y_true and y_pred: only 2 out of 5 predictions are correct.Step 2: Compute accuracy
Accuracy = 2/5 = 0.40.Final Answer:
Option A -> Option AQuick Check:
Count correct predictions, divide by total [OK]
Solution
Step 1: Identify offline data collection characteristics
Offline data collection involves gathering data that has already been generated and stored, not in real-time.Step 2: Eliminate real-time options
Options A, C, and D involve real-time or near-real-time data collection, which is characteristic of online data collection.Final Answer:
Option D -> Option DQuick Check:
Offline = historical, stored data. [OK]
Solution
Step 1: Identify potential issues
Interleaving requires proper randomization to ensure fair comparison.Step 2: Eliminate wrong options
Data leakage and temporal trends are less likely in interleaving. Inadequate sample size affects power, not consistency.Final Answer:
Option D -> Option DQuick Check:
Randomization is key in interleaving. [OK]
Solution
Step 1: Identify the discrepancy
Good validation performance but poor test performance suggests a mismatch between sets.Step 2: Eliminate less likely causes
The model is underfitting the data. is incorrect as underfitting would affect both sets. The validation set is too small. is less likely unless the validation set is extremely small. The model has too many parameters. would likely affect both sets similarly.Final Answer:
Option A -> Option AQuick Check:
Mismatch between validation and test sets. [OK]
Solution
Step 1: Identify the requirement.
The requirement is for a learning rate that decreases over time.Step 2: Match the requirement to the solution.
A learning rate scheduler with SGD allows for controlled decrease over time.Final Answer:
Option D -> Option DQuick Check:
Scheduler with SGD for decreasing lr. [check]
