ISYE 6402 Python Forecasting Applied Practice - Questions & Answers
with Rationales
1. Which Python NumPy expression computes root mean squared error from error array e?
A. np.mean(np.abs(e))
B. np.max(e)
C. np.sqrt(np.mean(e**2))
D. np.sum(e)
Answer: C. np.sqrt(np.mean(e**2))
Rationale: RMSE is the square root of the mean squared forecast errors.
2. What does pandas s.pct_change() compute by default?
A. Fractional change from the prior observation
B. The next-period forecast
C. A seasonally adjusted mean
D. Raw first differences
Answer: A. Fractional change from the prior observation
Rationale: pct_change computes relative change, not percentage units unless multiplied by 100.
3. In pandas, what does s.diff(1) compute?
A. Current value minus previous value
B. Twelve-period moving average
C. Cumulative sum
D. Future value divided by current value
Answer: A. Current value minus previous value
Rationale: diff(1) calculates the first difference across adjacent rows.
,4. Which pandas method calculates a rolling mean over five observations?
A. s.rolling(5).mean()
B. s.diff(5).sum()
C. s.cumsum().head()
D. s.shift(5).mean()
Answer: A. s.rolling(5).mean()
Rationale: rolling(5).mean computes averages over sliding five-observation windows.
5. Which pandas operation commonly removes rows with missing lag features?
A. df.dropna()
B. df.describe()
C. df.transpose()
D. df.cumsum()
Answer: A. df.dropna()
Rationale: dropna can remove initial rows made missing by lag and rolling feature creation.
6. Two forecast errors are 14 and -14. What is their mean absolute error?
A. 14
B. 196
C. 0
D. 28
Answer: A. 14
Rationale: MAE=(|14|+|-14|)/2=14.
, 7. Why should a StandardScaler be fitted on training data only?
A. Make all training and test targets equal
B. Determine the time-series sampling interval
C. Prevent leakage of test-period statistics
D. Guarantee zero model bias
Answer: C. Prevent leakage of test-period statistics
Rationale: Fitting transformations on held-out data contaminates the evaluation with future
information.
8. An observation has value 57; feature standardization here divides values by a known training scale
of 10 with zero center. What is the transformed value?
A. 5.70
B. 67.00
C. 570.00
D. 47.00
Answer: A. 5.70
Rationale: With zero centering, transformed value = 57/10=5.70.
9. Why use a fixed random_state in stochastic forecasting experiments?
A. Enforce a unit root
B. Make repeated runs more reproducible
C. Guarantee a better test score
D. Eliminate estimation error
Answer: B. Make repeated runs more reproducible
Rationale: A stable seed reduces uncontrolled randomness when comparing experimental runs.
with Rationales
1. Which Python NumPy expression computes root mean squared error from error array e?
A. np.mean(np.abs(e))
B. np.max(e)
C. np.sqrt(np.mean(e**2))
D. np.sum(e)
Answer: C. np.sqrt(np.mean(e**2))
Rationale: RMSE is the square root of the mean squared forecast errors.
2. What does pandas s.pct_change() compute by default?
A. Fractional change from the prior observation
B. The next-period forecast
C. A seasonally adjusted mean
D. Raw first differences
Answer: A. Fractional change from the prior observation
Rationale: pct_change computes relative change, not percentage units unless multiplied by 100.
3. In pandas, what does s.diff(1) compute?
A. Current value minus previous value
B. Twelve-period moving average
C. Cumulative sum
D. Future value divided by current value
Answer: A. Current value minus previous value
Rationale: diff(1) calculates the first difference across adjacent rows.
,4. Which pandas method calculates a rolling mean over five observations?
A. s.rolling(5).mean()
B. s.diff(5).sum()
C. s.cumsum().head()
D. s.shift(5).mean()
Answer: A. s.rolling(5).mean()
Rationale: rolling(5).mean computes averages over sliding five-observation windows.
5. Which pandas operation commonly removes rows with missing lag features?
A. df.dropna()
B. df.describe()
C. df.transpose()
D. df.cumsum()
Answer: A. df.dropna()
Rationale: dropna can remove initial rows made missing by lag and rolling feature creation.
6. Two forecast errors are 14 and -14. What is their mean absolute error?
A. 14
B. 196
C. 0
D. 28
Answer: A. 14
Rationale: MAE=(|14|+|-14|)/2=14.
, 7. Why should a StandardScaler be fitted on training data only?
A. Make all training and test targets equal
B. Determine the time-series sampling interval
C. Prevent leakage of test-period statistics
D. Guarantee zero model bias
Answer: C. Prevent leakage of test-period statistics
Rationale: Fitting transformations on held-out data contaminates the evaluation with future
information.
8. An observation has value 57; feature standardization here divides values by a known training scale
of 10 with zero center. What is the transformed value?
A. 5.70
B. 67.00
C. 570.00
D. 47.00
Answer: A. 5.70
Rationale: With zero centering, transformed value = 57/10=5.70.
9. Why use a fixed random_state in stochastic forecasting experiments?
A. Enforce a unit root
B. Make repeated runs more reproducible
C. Guarantee a better test score
D. Eliminate estimation error
Answer: B. Make repeated runs more reproducible
Rationale: A stable seed reduces uncontrolled randomness when comparing experimental runs.