session: "6103-advanced-ml/2026-10-31 0925 Advance Machine Learning"
title: "Advance Machine Learning"
date: "2026-10-31 09:25"
duration: "--"
language: "en"
model: "deepseek-ai/DeepSeek-V3.2"
parts: 3
transcript_chars: 63362
generated: "2026-11-23T00:44:57+05:30"
Advanced Machine Learning
Overview
This class introduced time series analysis and forecasting. It covered the fundamental characteristics of time series data, including its components (trend, seasonality, cyclicality, noise) and how it differs from cross-sectional data. The lecture progressed from identifying patterns using autocorrelation to techniques for making a series stationary via differencing. It culminated in an introduction to the ARIMA (AutoRegressive Integrated Moving Average) model framework, detailing how to determine its parameters (p, d, q) and compare models. This session lays the groundwork for classical statistical forecasting methods within the broader machine learning curriculum.
Learning outcomes
- Define time series data and its core components (trend, seasonality, cyclicality, noise).
- Calculate and interpret autocorrelation to identify seasonal patterns.
- Apply differencing to remove trends and achieve stationarity.
- Determine the parameters (p, d, q) for an ARIMA model using ACF/PACF plots and information criteria.
- Compare ARIMA models using AIC/BIC and justify its use over other methods like linear regression or neural networks for certain temporal problems.
Core concepts
Time Series Data
A sequence of data points collected in chronological order for the same variable. It matters because many real-world phenomena (sales, weather, stock prices) are observed over time, and their sequential nature creates dependencies that must be modeled explicitly, unlike cross-sectional data.
Components of Time Series
A time series is typically decomposed into Trend (long-term direction), Seasonality (fixed-period repeats), Cyclicality (non-fixed period repeats), and Noise/Irregularity (random shocks). Identifying these components is the first step in building an accurate forecasting model, as each may require a different modeling approach.
Stationarity
A time series property where the mean and variance are constant over time and autocovariance depends only on the lag. It matters because most classical time series models (like ARIMA) require stationarity. Differencing is a primary technique to transform a non-stationary series into a stationary one.
Autocorrelation and Partial Autocorrelation
Autocorrelation (ACF) measures the correlation between a series and its lagged values. Partial Autocorrelation (PACF) measures the correlation between a series and its lag, controlling for intermediate lags. They are used to identify the order of Moving Average (q from ACF) and AutoRegressive (p from PACF) components, respectively, within an ARIMA model.
ARIMA Model
A classical forecasting model combining AutoRegressive (AR), Integrated (I, for differencing), and Moving Average (MA) components. It matters as a foundational, interpretable model for a wide range of time series forecasting problems, especially when data shows trends and short-term dependencies without complex seasonal patterns.
Formulas and maths
- Linear Trend Model: \( y = a + bx \)
- \(a\) is the intercept, \(b\) is the slope, \(x\) is the time index.
- Used to model a simple linear trend in a time series.
- Slope Calculation (centered): \( b = \frac{\Sigma xy}{\Sigma x^2} \)
- \(x\) is the centered time index, \(y\) is the observation.
- Used to fit a linear trend when the time index is centered around its mean.
- Autocorrelation at lag k: \( \rho_k = \frac{\text{Cov}(x_t, x_{t-k})}{\sqrt{\text{Var}(x_t) * \text{Var}(x_{t-k})}} \)
- \(\rho_k\) is the autocorrelation at lag \(k\), Cov is covariance, Var is variance.
- Used to quantify the correlation between observations separated by \(k\) time periods.
- Covariance at lag k: \( c_k = \sum_{t=1}^{n-k} [(x_t - \bar{x}) * (x_{t+k} - \bar{x})] \)
- \(c_k\) is the covariance at lag \(k\), \(\bar{x}\) is the series mean.
- A component in the calculation of autocorrelation.
- First Differencing: \( \Delta y_t = y_t - y_{t-1} \)
- \(\Delta y_t\) is the first difference at time \(t\).
- Used to remove a linear trend and attempt to achieve stationarity.
- Second Differencing: \( \Delta^2 y_t = \Delta y_t - \Delta y_{t-1} \)
- \(\Delta^2 y_t\) is the second difference.
- Used if first differencing does not achieve stationarity (rarely needed).
- AIC: \( \text{AIC} = -2 \log(L) + 2 k \)
- \(L\) is the likelihood of the model, \(k\) is the number of estimated parameters.
- Used to compare ARIMA models; lower AIC is better.
- BIC: \( \text{BIC} = -2 \log(L) + \log(n) k \)
- \(n\) is the sample size.
- Used to compare ARIMA models with a stronger penalty for complexity; lower BIC is better.
Worked examples
1. Linear Trend Fitting: Annual sales data for years 21–25: sales = [10, 12, 15, 18, 20]. Centered x values: [-2, -1, 0, 1, 2]. Calculated slope: \( b = \frac{\Sigma xy}{\Sigma x^2} = \frac{26}{10} = 2.6 \). Fitted trend: \( y_t = 15 + 2.6x \).
2. Autocorrelation for Seasonality: Quarterly data for 4 years (16 values). Computed autocorrelations: lag 0 = 1, lag 4 = 0.7, lag 8 = 0.43. The strong autocorrelation at lag 4 and its multiples identifies quarterly seasonality (s=4).
3. Differencing for Stationarity: For a non-stationary series with an increasing trend, first differencing (d=1) is applied. Example: original observations become differences (e.g., resulting in values like "10 10" after differencing).
4. Parameter Identification from Plots: In an ACF plot example, significant positive correlations were seen at lags 1 through 5, then decreasing, suggesting a potential q value. In a PACF plot example, significant correlations were present up to lag 15, after which they became very small, suggesting a potential p value.
Questions asked in class
- Q: What is the difference between cyclical and seasonal?
- A: Seasonal patterns repeat at fixed times (e.g., every Saturday). Cyclical patterns repeat but not at fixed intervals (e.g., stock market dips every few years, but the interval is not fixed).
- Q: Does an increasing trend with a specific pattern for a short period, but not repeating, qualify as cyclical?
- A: Modeling cyclical patterns is different. A complete time series model must account for trend, seasonality, cycle, and random noise together. For a short, non-repeating pattern, it might be random noise or part of a cycle, but the model will incorporate it.
- Q: How to identify p, d, q?
- A: d is found by differencing until stationarity (often d=1). p and q are identified from ACF and PACF plots (looking for where they cut off/tail off). Final selection is via AIC/BIC comparison of candidate models.
- Q: Why use time series models over linear regression or neural networks?
- A: Time series models are specialized for temporal patterns (trend, seasonality, cyclicity) with few parameters. Linear regression may require many parameters for complex patterns. Neural networks (RNNs, LSTMs) are more complex, computationally heavy, and can be overkill for simple temporal patterns where ARIMA is sufficient and faster.
Key takeaways
- Time series data is ordered chronologically, creating dependencies that cross-sectional data does not have.
- The four core components of a time series are trend, seasonality, cyclicality, and noise/irregularity.
- Autocorrelation function (ACF) plots are used to detect seasonality (peaks at seasonal lags) and help determine the Moving Average (MA) order (q).
- Partial Autocorrelation Function (PACF) plots are used to determine the AutoRegressive (AR) order (p).
- Differencing (Δy_t = y_t - y_{t-1}) is the primary method for removing trend and achieving stationarity, which is a prerequisite for ARIMA modeling.
- The order of differencing required defines the 'd' parameter in ARIMA(p, d, q).
- Model selection among candidate ARIMA models is done using information criteria like AIC and BIC, where lower values indicate a better fit penalized for complexity.
- ARIMA models are often preferable to linear regression or neural networks for univariate time series forecasting due to their specialization for temporal dependencies, interpretability, and computational efficiency.
- Stationarity implies constant mean and variance over time; it can be checked visually or with tests like the Augmented Dickey-Fuller (ADF) test (p-value < 0.05 suggests stationarity).
- Residual diagnostics (e.g., checking error terms for patterns) are a crucial final step to validate a fitted ARIMA model.
- For data with strong seasonal patterns, SARIMA (Seasonal ARIMA) is the appropriate extension of the ARIMA model.
Exam-style questions
1. Given a plot of the Autocorrelation Function (ACF) for a quarterly sales dataset showing significant spikes at lags 4, 8, and 12, what does this indicate, and how would you modify the data to check if you have successfully removed this pattern?
- Answer Outline: This indicates quarterly seasonality. To check removal, compute the seasonal difference: y_t - y_{t-4}. Then, plot the ACF of the differenced series. If the seasonality is removed, the significant spikes at lags 4, 8, and 12 should disappear.
2. A time series has a clear upward linear trend. Describe the steps you would take to prepare this series for an ARIMA model, including how you would determine the appropriate differencing order (d).
- Answer Outline: First, apply first differencing: Δy_t = y_t - y_{t-1}. Then, check the resulting series for stationarity by plotting it and checking if the mean appears constant. You could also use the Augmented Dickey-Fuller test. If the series is now stationary, d=1. If a trend remains, apply second differencing (d=2), but this is rarely needed.
3. You have fitted two ARIMA models to a stationary dataset: Model A (p=1, d=0, q=1) with AIC=300 and BIC=310, and Model B (p=2, d=0, q=2) with AIC=295 and BIC=312. Which model would you select and why?
- Answer Outline: Select Model A. While Model B has a slightly lower AIC (295 < 300), its BIC is higher (312 > 310). BIC imposes a heavier penalty for model complexity. Given the small AIC improvement and the higher BIC, Model A is likely the more parsimonious and preferable choice to avoid overfitting.
Glossary
- Trend - A long-term increase or decrease in the level of a time series.
- Seasonality - Regular, repeating patterns in a time series at fixed intervals (e.g., daily, quarterly).
- Cyclicality - Patterns that repeat but not at fixed, predictable intervals.
- Noise/Irregularity - Unpredictable, random variations in a time series.
- Stationarity - A property of a time series where its statistical properties (mean, variance) are constant over time.
- Differencing - The process of computing the differences between consecutive observations to remove trend.
- Autocorrelation (ACF) - The correlation between a time series and a lagged version of itself.
- Partial Autocorrelation (PACF) - The correlation between a time series and its lag, after removing the effects of intermediate lags.
- ARIMA - AutoRegressive Integrated Moving Average, a class of models for forecasting time series data.
- SARIMA - Seasonal ARIMA, an extension of ARIMA that explicitly models seasonal patterns.
Follow-ups
- The exact calculation and interpretation of the Ljung-Box test (referred to in notes) for checking autocorrelation in residuals needs clarification.
- The full, detailed step-by-step process for building an ARIMA model, including combining trend removal, seasonality analysis, and cyclical modeling into a single procedure, is promised for a later session.
- Implementation details using Python libraries like
pandas and statsmodels were noted but not elaborated. - The specific formulas for calculating ACF and PACF values directly from data were mentioned but not fully detailed.