0
0
ML Pythonml~20 mins

Autocorrelation analysis in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Autocorrelation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Autocorrelation
What does a high positive autocorrelation at lag 1 indicate in a time series?
AValues at time t are negatively related to values at time t-1
BValues at time t are completely independent from values at time t-1
CValues at time t are strongly similar to values at time t-1
DValues at time t are random and show no pattern
Attempts:
2 left
💡 Hint
Think about how values close in time relate to each other.
Predict Output
intermediate
2:00remaining
Output of Autocorrelation Calculation
What is the output of the following Python code calculating autocorrelation for lag 1?
ML Python
import numpy as np
from statsmodels.tsa.stattools import acf

data = np.array([1, 2, 3, 4, 5])
result = acf(data, nlags=1, fft=False)
print(round(result[1], 2))
A0.8
B1.0
C0.5
D0.0
Attempts:
2 left
💡 Hint
Autocorrelation at lag 0 is always 1. Check how values relate at lag 1.
Model Choice
advanced
1:30remaining
Choosing Model Based on Autocorrelation
You observe strong autocorrelation at multiple lags in your time series data. Which model is best suited to capture this pattern?
ADecision Tree Classifier
BLinear Regression without lag features
CK-Means Clustering
DARIMA (AutoRegressive Integrated Moving Average)
Attempts:
2 left
💡 Hint
Look for models designed for time series with autocorrelation.
Hyperparameter
advanced
1:30remaining
Selecting Lag Parameter for Autocorrelation
When computing autocorrelation for a time series, what is the effect of increasing the maximum lag parameter?
AYou analyze relationships between points farther apart in time
BYou increase the speed of computation
CYou reduce the number of data points used in the calculation
DYou ignore short-term dependencies
Attempts:
2 left
💡 Hint
Think about what lag means in time series.
🔧 Debug
expert
2:00remaining
Debugging Autocorrelation Calculation Error
What error will this code raise when calculating autocorrelation on a constant time series?
ML Python
import numpy as np
from statsmodels.tsa.stattools import acf

data = np.array([5, 5, 5, 5, 5])
result = acf(data, nlags=2, fft=False)
print(result)
AZeroDivisionError: division by zero
BValueError: The input data is constant
CTypeError: unsupported operand type(s)
DNo error, outputs array of ones
Attempts:
2 left
💡 Hint
Consider variance of constant data in autocorrelation formula.