0
0
ML Pythonml~20 mins

Time series evaluation metrics in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Time Series Metrics Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Mean Absolute Error (MAE) in Time Series

Which statement best describes the Mean Absolute Error (MAE) when used to evaluate time series predictions?

AMAE calculates the average of the absolute differences between predicted and actual values, treating all errors equally regardless of direction.
BMAE measures the average of the squared differences between predicted and actual values, penalizing larger errors more heavily.
CMAE measures the correlation between predicted and actual values to assess prediction accuracy.
DMAE is the percentage of predictions that exactly match the actual values in the time series.
Attempts:
2 left
💡 Hint

Think about how MAE treats errors without squaring them.

Predict Output
intermediate
2:00remaining
Calculate RMSE for a Time Series Prediction

What is the output of the following Python code that calculates the Root Mean Squared Error (RMSE) for given true and predicted values?

ML Python
import numpy as np
true = np.array([3, -0.5, 2, 7])
pred = np.array([2.5, 0.0, 2, 8])
rmse = np.sqrt(np.mean((true - pred) ** 2))
print(round(rmse, 3))
A0.750
B1.118
C0.612
D0.957
Attempts:
2 left
💡 Hint

Calculate squared errors, average them, then take the square root.

Model Choice
advanced
2:00remaining
Choosing the Best Metric for Skewed Time Series Data

You have a time series dataset with many small values and a few very large spikes. Which evaluation metric is best to use to avoid the large spikes dominating the error measurement?

AR-squared (Coefficient of Determination)
BRoot Mean Squared Error (RMSE)
CMean Squared Error (MSE)
DMean Absolute Error (MAE)
Attempts:
2 left
💡 Hint

Consider which metric is less sensitive to large errors.

Metrics
advanced
2:00remaining
Interpreting Mean Absolute Percentage Error (MAPE)

Given the true values [100, 200, 300] and predicted values [110, 190, 310], what is the Mean Absolute Percentage Error (MAPE) expressed as a percentage?

ML Python
true = [100, 200, 300]
pred = [110, 190, 310]
errors = [abs(t - p) / t for t, p in zip(true, pred)]
mape = sum(errors) / len(errors) * 100
print(round(mape, 2))
A8.33
B6.11
C7.14
D5.56
Attempts:
2 left
💡 Hint

Calculate absolute percentage errors for each point, then average.

🔧 Debug
expert
2:00remaining
Identify the Error in Time Series Metric Calculation Code

What error does the following Python code raise when calculating Mean Absolute Error (MAE) for time series predictions?

ML Python
true = [1, 2, 3, 4]
pred = [1, 2, 3]
mae = sum(abs(t - p) for t, p in zip(true, pred)) / len(true)
print(mae)
ANo error; output is 0.0
BNo error; output is 0.25
CIndexError because lists have different lengths
DZeroDivisionError because denominator is zero
Attempts:
2 left
💡 Hint

Check how zip works with lists of different lengths.