Module 8/15 · Weeks 8 · 9 h

Regression, regularisation and time-series data

UAT 456 Artificial Intelligence, Machine Learning and Computer Vision for UAS

About 95 minDraft, awaiting reviewLast updated 1 October 2026

Lesson

By the end of this module you will be able to

  1. Choose and interpret the regression metrics MAE, RMSE, MAPE and R² to match the task
  2. Explain how correlated features affect coefficients, and use ridge and lasso to control complexity, choosing alpha with grouped cross-validation
  3. Explain why tree-based models cannot extrapolate, and report the valid range of a regression model
  4. Build lag and rolling-window features that use only the past
  5. Evaluate a time-series model with walk-forward validation against a persistence baseline

Prerequisites: Modules 6 and 7 of this course and UAT 306 Artificial Intelligence for UAS (module 2)

Why this matters

Most predictive-maintenance questions ask for a number, not a yes or a no: how much capacity does this battery have left, what should the motor current be in the next hour? If the true value strays far from the prediction, something is wrong. ISO 13381-1, the guideline on prognostics for machines, describes the process of estimating condition and remaining useful life (the current edition is 2025; the 2015 edition has been withdrawn). In batteries, Severson et al. (2019) used discharge data from early cycles that show no capacity fade yet to predict the cycle life of 124 cells with a 9.1% test error using only the first 100 cycles, and the lithium-ion ageing data set of the NASA Prognostics Center of Excellence (Saha and Goebel, 2007) lets students experiment with real data. This module teaches regression in its practical form: choose the right metric, control complexity when features are correlated, know where the model is valid, and evaluate time-series data without looking backwards from the future. All data in this module is synthetic and all numbers are assumed.

Regression metrics

The error of one prediction is . The metrics differ in how they combine these errors.

  • MAE is the mean absolute error, in the same unit as the answer, and easy to interpret.
  • RMSE is the square root of the mean squared error, also in the unit of the answer, but squaring before averaging gives large errors more weight. RMSE is always at least MAE and larger when errors are uneven. Chai and Draxler (2014) argue that RMSE should not be avoided just because MAE reads more easily: when errors are close to normally distributed, RMSE is the more appropriate summary, and reporting both is more informative.
  • MAPE is the percentage error relative to the true value. It is easy to communicate but unusable when true values are near zero, and it tends to hide large errors at high values.
  • is the share of variance the model explains compared with predicting the mean. It has no unit, but a high value on the training data does not guarantee performance outside its range.

As in classification, the meaningful figure comes from data not used for training, and it needs a baseline (for example the mean, or the previous hour’s value).

Correlated features, ridge and lasso

The survey company wants to predict the capacity (Ah) of each battery from its usage record. The synthetic data has 30 packs with about 40 measurements each. There are six features: the number of charge cycles (cycles), the internal resistance (ir), the cumulative charge throughput (throughput), the mean charge current in C (crate), the mean temperature (temp) and the depth of discharge (dod). The first three say the same thing, “how much has this battery been used”, so they are highly correlated. True capacity has a knee: it fades faster after about cycle 350.

When two features carry the same information, ordinary least squares (OLS) splits the credit between them in any way that gives the same total, so coefficients swing widely when the training data changes slightly, even though the predictions stay good. Ridge (Hoerl and Kennard, 1970) adds a penalty to the function being minimised, pulling coefficients towards zero and giving correlated features similar credit. Lasso (Tibshirani, 1996) uses a penalty , which sets the coefficients of unneeded features to exactly zero and so selects features along the way. (scikit-learn scales the penalty slightly differently for ridge and lasso, so values cannot be compared across the two.) Always standardise the features first; otherwise the penalty hits small-scale features harder.

Example 1 Coefficients swing when training data is small and features are correlated

Suppose the team has training data from only 5 packs and must predict all the others (within the first 300 cycles, where real data exists). The code draws 5 packs for training 200 times, records the RMSE on the remaining packs and the coefficients of cycles and ir each time, then summarises the mean and standard deviation (SD).

import numpy as np, pandas as pd
from sklearn.linear_model import LinearRegression, Ridge, Lasso
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

def make_packs(seed=482, n_packs=30):
    rng = np.random.default_rng(seed)
    rows = []
    for k in range(n_packs):
        crate, temp, dod = rng.normal(1.2, 0.25), rng.normal(30, 4), rng.uniform(0.6, 0.95)    # usage habit of this pack
        stress = 1 + 0.6 * (crate - 1.2) + 0.03 * (temp - 30)                                  # the harder the current draw and the heat, the faster the ageing
        for c in range(10, int(rng.integers(380, 460)), 10):                                   # c = number of charge cycles
            rows.append(dict(pack=k, cycles=c, crate=crate, temp=temp, dod=dod,
                             throughput=c * dod * 10 / 1000 + rng.normal(0, 0.05),             # cumulative charge throughput (kAh), tied to cycles
                             ir=18 + 0.035 * c * stress + rng.normal(0, 0.4),                   # internal resistance (mOhm)
                             cap=10 * (1 - 0.00045 * c * stress - 0.03 * np.exp((c - 400) / 45)) + rng.normal(0, 0.05)))   # capacity (Ah), with a knee after cycle 350
    return pd.DataFrame(rows)

packs = make_packs()
FEATS = ["cycles", "ir", "throughput", "crate", "temp", "dod"]
print(f"{len(packs)} rows, {packs.pack.nunique()} packs, capacity {packs.cap.min():.2f} to {packs.cap.max():.2f} Ah")
print("correlation with cycles: " + ", ".join(f"{f} {packs[f].corr(packs.cycles):+.2f}" for f in ("ir", "throughput", "crate")))

seen = packs[packs.cycles <= 300]                                   # the range of cycles that has real data
makers = {"OLS": lambda: LinearRegression(), "ridge a=1": lambda: Ridge(1), "ridge a=10": lambda: Ridge(10), "ridge a=100": lambda: Ridge(100),
          "lasso a=0.01": lambda: Lasso(0.01), "lasso a=0.05": lambda: Lasso(0.05)}
rng = np.random.default_rng(0)
out = {k: dict(rmse=[], coef=[]) for k in makers}
for _ in range(200):                                                # draw only 5 packs as training data; the rest are the test set
    pick = rng.choice(seen.pack.unique(), 5, replace=False)
    a, b = seen[seen.pack.isin(pick)], seen[~seen.pack.isin(pick)]
    for k, make in makers.items():
        m = make_pipeline(StandardScaler(), make()).fit(a[FEATS], a.cap)
        out[k]["rmse"].append(np.sqrt(np.mean((b.cap - m.predict(b[FEATS])) ** 2))); out[k]["coef"].append(m[-1].coef_)
print("model         test RMSE   cycles coef: mean (sd)    ir coef: mean (sd)   dropped: crate temp dod")
for k, v in out.items():
    c = np.array(v["coef"]); z = (np.abs(c) < 1e-9).mean(0)
    print(f"{k:<13} {np.mean(v['rmse']):>8.3f}   {c[:, 0].mean():>+9.3f} ({c[:, 0].std():.3f})   {c[:, 1].mean():>+9.3f} ({c[:, 1].std():.3f})       {z[3]:>4.0%} {z[4]:>4.0%} {z[5]:>4.0%}")
1242 rows, 30 packs, capacity 6.79 to 10.05 Ah
correlation with cycles: ir +0.93, throughput +0.97, crate +0.01
model         test RMSE   cycles coef: mean (sd)    ir coef: mean (sd)   dropped: crate temp dod
OLS              0.077      -0.103 (0.105)      -0.188 (0.082)         0%   0%   0%
ridge a=1        0.073      -0.100 (0.060)      -0.188 (0.063)         0%   0%   0%
ridge a=10       0.077      -0.112 (0.022)      -0.158 (0.027)         0%   0%   0%
ridge a=100      0.117      -0.102 (0.009)      -0.113 (0.009)         0%   0%   0%
lasso a=0.01     0.082      -0.067 (0.066)      -0.257 (0.081)        22%  46%  92%
lasso a=0.05     0.098      -0.033 (0.057)      -0.272 (0.081)       100% 100% 100%

The first three features are very highly correlated with the cycle count (internal resistance +0.93, cumulative charge +0.97). With OLS, the coefficient of cycles has a mean of −0.103 but an SD of 0.105 across training sets, as large as the mean itself: some training sets give a positive coefficient and others a strongly negative one, while the test RMSE is not hurt (0.077). Ridge at cuts the SD to 0.060 and improves the RMSE slightly to 0.073. At the SD falls to 0.022 with an RMSE equal to OLS (0.077). At the coefficients are very still (SD 0.009) because they are squeezed so hard that the model gets crude, and the RMSE rises to 0.117. Lasso at drops dod in 92% of training sets, temp in 46% and crate in 22%, keeping ir as the main feature (−0.257). At it drops all three every time but the RMSE worsens to 0.098. Three conclusions follow. First, prediction accuracy and coefficient stability are different things. Second, never read the coefficients of correlated features as engineering explanations. Third, has a good range: too low does not help, too high underfits.

Horizontal bar chart of the standard deviation of the cycles coefficient: OLS 0.105 in pink, ridge alpha 1 0.060, ridge alpha 10 0.022, ridge alpha 100 0.009, lasso alpha 0.01 0.066. Test RMSE in brackets: 0.077, 0.073, 0.077, 0.117, 0.082
Figure 1 Stability of the cycles coefficient when retrained 200 times on data from 5 packs

is chosen with cross-validation that always splits by pack, because measurements from one pack are very similar, like the flights of one airframe in module 6.

Example 2 Choose the ridge alpha with cross-validation by pack

Train on 12 packs, choose with GridSearchCV using 4-fold GroupKFold, then test on the other 18 packs that were never used.

from sklearn.model_selection import GridSearchCV, GroupKFold
rng = np.random.default_rng(1)
pick = rng.choice(seen.pack.unique(), 12, replace=False)             # train on 12 packs; choose alpha with cross-validation by pack
a, b = seen[seen.pack.isin(pick)], seen[~seen.pack.isin(pick)]
grid = GridSearchCV(make_pipeline(StandardScaler(), Ridge()), {"ridge__alpha": [0.01, 0.1, 1, 10, 100, 1000]},
                    cv=GroupKFold(4), scoring="neg_root_mean_squared_error").fit(a[FEATS], a.cap, groups=a.pack)
print("alpha     CV RMSE")
for alpha, s in zip(grid.cv_results_["param_ridge__alpha"], grid.cv_results_["mean_test_score"]):
    print(f"{alpha:>7}   {-s:.4f}")
best = grid.best_estimator_
print(f"chosen alpha {grid.best_params_['ridge__alpha']}; RMSE on the 18 packs never used: {np.sqrt(np.mean((b.cap - best.predict(b[FEATS])) ** 2)):.4f} Ah")
alpha     CV RMSE
   0.01   0.0610
    0.1   0.0609
    1.0   0.0609
   10.0   0.0612
  100.0   0.0779
 1000.0   0.2282
chosen alpha 1; RMSE on the 18 packs never used: 0.0699 Ah

The CV RMSE is almost identical for from 0.01 to 10 (0.0609 to 0.0612), so the result is insensitive to in that range. It starts to worsen at 100 (0.0779) and collapses at 1000 (0.2282), as the coefficients are squeezed towards zero. Everything in the flat range is statistically the same, so the strongest value in that range should be preferred for stability (this example gives from the lowest mean). The RMSE on the 18 new packs is 0.0699 Ah, slightly above the CV figure, which is normal and is the number to report.

The limits of a regression model: extrapolation

A regression model learns a relationship from the range of data it has seen. When it must predict outside that range, which happens often when someone asks what a battery used for 300 cycles will do at 400, each family fails differently. A linear model extends the trend in a straight line, so it does not see accelerating ageing. A random forest or gradient boosting predicts with averages of leaves from the training data, so it can never predict beyond the range of values it has seen: the trend goes flat, at the value of the training data nearest the edge. No family of model can predict a knee it has never seen. Two working rules follow: report the training range together with the model, and check against out-of-range data whose answer is already known.

Example 3 Train up to cycle 300, then predict cycles 310 to 450

Train ridge, a random forest and gradient boosting on the measurements at 300 cycles or fewer of all packs, then test on the later measurements. The first table reports every metric and the RMSE by cycle band. The second table follows pack number 3 cycle by cycle.

from sklearn.ensemble import GradientBoostingRegressor, RandomForestRegressor
from sklearn.metrics import mean_absolute_error, mean_absolute_percentage_error, mean_squared_error, r2_score
train = packs.cycles <= 300                                         # train on cycles up to 300, test on later cycles
models = {"ridge": make_pipeline(StandardScaler(), Ridge(1)),
          "random forest": RandomForestRegressor(200, random_state=0, n_jobs=-1),
          "gradient boosting": GradientBoostingRegressor(random_state=0)}
bands = [(310, 350), (360, 400), (410, 450)]
print("model              MAE    RMSE   MAPE    R2  | RMSE by cycle band: 310-350  360-400  410-450")
for name, m in models.items():
    m.fit(packs.loc[train, FEATS], packs.cap[train])
    t = packs[~train]; p = m.predict(t[FEATS])
    by = [np.sqrt(np.mean((t.cap[(t.cycles >= lo) & (t.cycles <= hi)] - p[((t.cycles >= lo) & (t.cycles <= hi)).to_numpy()]) ** 2)) for lo, hi in bands]
    print(f"{name:<18} {mean_absolute_error(t.cap, p):.3f}  {mean_squared_error(t.cap, p) ** .5:.3f}  {mean_absolute_percentage_error(t.cap, p):.1%}  {r2_score(t.cap, p):>5.2f}  |{by[0]:>26.3f}{by[1]:>9.3f}{by[2]:>9.3f}")
one = packs[(packs.pack == 3) & packs.cycles.isin([250, 300, 350, 400])]   # pack number 3 at cycles 250 to 400
print("pack 3     cycles   true  " + "  ".join(f"{n[:5]:>7}" for n in models))
for (_, r), *ps in zip(one.iterrows(), *[m.predict(one[FEATS]) for m in models.values()]):
    print(f"           {int(r.cycles):>6}  {r.cap:.2f}  " + "  ".join(f"{p:>7.2f}" for p in ps))
model              MAE    RMSE   MAPE    R2  | RMSE by cycle band: 310-350  360-400  410-450
ridge              0.190  0.262  2.4%   0.66  |                     0.093    0.204    0.530
random forest      0.268  0.391  3.4%   0.24  |                     0.106    0.330    0.783
gradient boosting  0.270  0.396  3.5%   0.22  |                     0.105    0.334    0.792
pack 3     cycles   true    ridge    rando    gradi
              250  8.82     8.87     8.81     8.83
              300  8.53     8.60     8.52     8.54
              350  8.31     8.38     8.41     8.39
              400  7.91     8.17     8.31     8.32

The overall metrics give different pictures. Ridge’s MAPE of only 2.4% sounds good, but an RMSE of 0.262 Ah and an of 0.66 show that large errors are hidden, and ridge’s RMSE in the 410 to 450 band is as high as 0.530 Ah against 0.093 Ah at 310 to 350: the error grows faster than the distance from the training range. The random forest and gradient boosting are worse than ridge in every band (last-band RMSE 0.783 and 0.792 Ah) because their trend goes flat. The table for pack 3 shows this clearly. At cycle 400 the true capacity is 7.91 Ah, ridge predicts 8.17 and the random forest predicts 8.31. Every model is too high because none has seen the knee of the ageing. The team must therefore write in the model documentation that it is valid only for cycles 10 to 300, and when packs pass 300 cycles it must collect more data and retrain.

Grouped bar chart for three cycle bands 310-350, 360-400 and 410-450 with three bars each: ridge, random forest, gradient boosting. First band 0.093, 0.106, 0.105. Second band 0.204, 0.330, 0.334. Third band 0.530, 0.783, 0.792
Figure 2 RMSE by cycle band outside the training range
Line chart of the capacity of pack 3 at cycles 250, 300, 350 and 400. The pink line, true values, falls from 8.82 to 7.91. The green ridge line ends at 8.17. The yellow random forest line ends at 8.31
Figure 3 True capacity of pack 3 and predictions outside the training range

Time-series data from the bottling line

The conveyor motor of the bottling line logs its current every hour. The current depends on the line speed set by shift (morning shift 240, afternoon 300, night 270 bottles per minute, Sundays at half speed), has a small daily pattern, and carries a bearing-wear trend that slowly accelerates. Technicians want to forecast the current of the next hour so they can raise an alert when the real value departs far from the expected one. The data is synthetic, 60 days.

Time-series data needs features built differently from tabular data.

  • Lags. The value of earlier hours (lag1, lag2) and of the same time yesterday (lag24).
  • Rolling windows. The mean of the last 6 hours. Use shift(1) before rolling so that the window does not include the hour being predicted (in module 6 the moving average of flights also counted only the past).
  • Variables known in advance. The line-speed schedule of the coming shift is known beforehand, so using it does not break the rule.
  • Cyclic patterns. Convert the hour of day to and so that 23:00 and 00:00 are close together.

The baselines to beat first are persistence (guess the same as the previous hour) and seasonal naive (guess the same as the same hour yesterday). Hyndman and Athanasopoulos describe time-series cross-validation with a rolling forecasting origin: the training set holds only data before the test point, and the origin moves forward step by step. This is what scikit-learn’s TimeSeriesSplit does.

Example 4 Next-hour current forecast, walk-forward against shuffled folds

Compare ridge and gradient boosting using five test windows of one week (168 hours) each in time order, against five-fold cross-validation with shuffled rows, and compare skill against persistence (). The feature set includes the day index (day).

from sklearn.model_selection import KFold, TimeSeriesSplit

def make_line(seed=482, hours=24 * 60):
    rng = np.random.default_rng(seed)
    h = np.arange(hours); hod = h % 24
    speed = np.where(hod < 8, 240, np.where(hod < 16, 300, 270)).astype(float)       # line speed by shift (bottles per minute)
    speed[(h // 24) % 7 == 6] *= 0.5                                                  # Sundays run at half speed
    noise = np.zeros(hours)
    for t in range(1, hours): noise[t] = 0.7 * noise[t - 1] + rng.normal(0, 0.06)     # noise correlated with the previous hour
    amps = 2.0 + 0.0075 * speed + 0.0035 * (h / 24) + 0.00012 * (h / 24) ** 2 + 0.15 * np.sin(2 * np.pi * (hod - 14) / 24) + noise   # includes an accelerating wear trend
    return pd.DataFrame(dict(hour=h, hod=hod, speed=speed, amps=amps))

line = make_line()
for lag in (1, 2, 24): line[f"lag{lag}"] = line.amps.shift(lag)                 # values of earlier hours (past only)
line["roll6"] = line.amps.shift(1).rolling(6).mean()                            # shift before rolling so the window never peeks at the current hour
line["day"] = line.hour / 24
line["s"], line["c"] = np.sin(2 * np.pi * line.hod / 24), np.cos(2 * np.pi * line.hod / 24)
line = line.dropna().reset_index(drop=True)
LF = ["speed", "lag1", "lag2", "lag24", "roll6", "day", "s", "c"]
XL, yL = line[LF], line.amps
tss = TimeSeriesSplit(5, test_size=168)                                         # 5 test windows of one week each, in time order
naive = np.array([mean_absolute_error(yL.iloc[b], line.lag1.iloc[b]) for _, b in tss.split(XL)])
print(f"persistence (previous hour) MAE {naive.mean():.3f}; same hour yesterday MAE {np.mean([mean_absolute_error(yL.iloc[b], line.lag24.iloc[b]) for _, b in tss.split(XL)]):.3f}")
print("model              walk-forward MAE   shuffled KFold MAE   skill vs persistence")
for name, make in (("ridge", lambda: make_pipeline(StandardScaler(), Ridge(1))), ("gradient boosting", lambda: GradientBoostingRegressor(random_state=0))):
    wf = [mean_absolute_error(yL.iloc[b], make().fit(XL.iloc[a], yL.iloc[a]).predict(XL.iloc[b])) for a, b in tss.split(XL)]
    sh = [mean_absolute_error(yL.iloc[b], make().fit(XL.iloc[a], yL.iloc[a]).predict(XL.iloc[b])) for a, b in KFold(5, shuffle=True, random_state=0).split(XL)]
    print(f"{name:<18} {np.mean(wf):>10.3f} (sd {np.std(wf, ddof=1):.3f})   {np.mean(sh):>10.3f}           {1 - np.mean(wf) / naive.mean():>10.0%}")
persistence (previous hour) MAE 0.091; same hour yesterday MAE 0.346
model              walk-forward MAE   shuffled KFold MAE   skill vs persistence
ridge                   0.075 (sd 0.009)        0.065                  18%
gradient boosting       0.073 (sd 0.012)        0.054                  20%

Persistence gets an MAE of 0.091 A, and seasonal naive is much worse (0.346 A) because the line speed differs by shift and by day. The result to take in is that the two models beat persistence by only 18% and 20% (skill), less than one might expect, which is the reality of next-hour forecasting when values change slowly. Without a baseline we would not know whether an MAE of 0.073 A is good. Shuffled folds give an MAE that is too low: ridge 0.065 A against 0.075 A from walk-forward (13% too good) and gradient boosting 0.054 A against 0.073 A (26% too good). Shuffled folds put rows of adjacent hours and days on the training side, so the model can interpolate between points it has seen, and trees can memorise the level of each day from the day index. In real use the model must forecast hours that have not yet arrived, and the accelerating wear trend means test windows always lie outside the range already seen. The standard deviation of walk-forward (0.009 to 0.012) also shows that some weeks are harder than others.

Horizontal bar chart of the MAE of the next-hour forecast: persistence 0.091 in grey, ridge walk-forward 0.075 in green, ridge shuffled folds 0.065 in pink, boosting walk-forward 0.073 in green, boosting shuffled folds 0.054 in pink
Figure 4 MAE of the next-hour current forecast by evaluation method

Module lab

Lab: regression, complexity control and time-series forecasting

  1. Run Example 1 with 3, 5, 10 and 20 training packs. Plot the SD of the cycles coefficient for OLS and ridge side by side and explain why the SD falls as data grows.
  2. Add one more feature correlated with cycles (for example cycles plus a little noise) and see how the SD of OLS changes and how much ridge helps.
  3. Run Example 2 with a finer alpha grid and write which value you choose, with a reason based on how flat the CV curve is.
  4. Run Example 3 with the training edge at cycle 200 and at 350. Record the RMSE of each band and explain how the random forest’s result changes once the training edge passes the knee.
  5. Write a short model-documentation note stating the training range and the cycle range where the model must not be used.
  6. Run Example 4 adding a lag48 feature and removing day, and compare the walk-forward and shuffled-fold MAE.
  7. If the department has real motor-current or battery-voltage logs, build persistence as the baseline, then report the skill of one model using walk-forward.

Common mistakes

Watch out

  • Reading the coefficients of correlated features as engineering explanations. The values swing when the training data changes slightly.
  • Not standardising before ridge or lasso. The penalty hits small-scale features harder.
  • Choosing on the test set, or splitting the measurements of one pack at random.
  • Setting so high that the model underfits. The coefficients are very still but the RMSE rises.
  • Using a random forest or boosting to predict outside the training range. The trend goes flat and the miss is large.
  • Reporting only MAPE or . They hide large errors outside the range.
  • Not calling shift before rolling. The window secretly includes the value being predicted.
  • Shuffling time-series rows and then cross-validating. The numbers are too good.
  • Having no persistence baseline. You cannot tell how much value the model adds.

Summary

  • Each regression metric views the errors differently. Report MAE and RMSE together, and compare with a baseline.
  • With correlated features, OLS gives swinging coefficients, ridge shrinks them together and lasso selects features. Both need standardisation and an chosen by cross-validation by group.
  • Prediction accuracy and coefficient stability are different things.
  • No regression model can predict what it has never seen. Tree-based models go flat outside the range, so the training range must be reported.
  • Time-series features use lags, rolling windows that count only the past, and variables known in advance.
  • Evaluate time series with walk-forward against persistence. Shuffled folds give numbers that are too good.

Self-check questions

  1. The true values are 10, 12, 14 and the predictions are 11, 12, 17. Compute MAE and RMSE and say why RMSE is larger.
  2. In ridge, what does the model predict as grows without limit?
  3. Two features are correlated at 0.99. Why are the OLS coefficients unstable, and how can it be fixed?
  4. Why does a random forest trained on packs up to cycle 300 predict the capacity at cycle 400 too high (8.31 Ah against 7.91 Ah)?
  5. Persistence has an MAE of 0.091 A and a model has 0.073 A. What is the skill?
Answers
  1. The errors are . MAE and RMSE . RMSE is larger because squaring before averaging gives the error of 3 a lot of weight.
  2. The coefficients are squeezed to zero and the model predicts a constant (the mean of the training data), the maximum underfit.
  3. The two features carry the same information, so a small change in the training data changes how credit is split between them. Fix it with ridge (splits credit evenly), lasso (keeps one), or by dropping one feature, and never read the coefficients as engineering explanations.
  4. Trees predict with leaf averages from the training data, so they cannot go beyond the range they have seen. At cycle 400 the prediction sits near the edge of the training data, which has no knee yet and is higher than the truth.
  5. Skill , about 20%.

Key formulas

MAE and RMSE
Coefficient of determination
Ridge and lasso
Skill against persistence

Key references

  1. Géron, A. (2022). Hands-on machine learning with Scikit-Learn, Keras, and TensorFlow (3rd ed.). O'Reilly.
  2. scikit-learn developers. Metrics and scoring: Quantifying the quality of predictions (scikit-learn 1.9). link
  3. scikit-learn developers. Cross-validation: Evaluating estimator performance (scikit-learn 1.9). link
  4. Hoerl, A. E., & Kennard, R. W. (1970). Ridge regression: Biased estimation for nonorthogonal problems. Technometrics, 12(1), 55–67. link
  5. Tibshirani, R. (1996). Regression shrinkage and selection via the lasso. Journal of the Royal Statistical Society: Series B, 58(1), 267–288. link
  6. Chai, T., & Draxler, R. R. (2014). Root mean square error (RMSE) or mean absolute error (MAE)? Arguments against avoiding RMSE in the literature. Geoscientific Model Development, 7(3), 1247–1250. link
  7. Hyndman, R. J., & Athanasopoulos, G. (2021). Forecasting: Principles and practice (3rd ed.). OTexts. link
  8. Severson, K. A., Attia, P. M., Jin, N., Perkins, N., Jiang, B., Yang, Z., Chen, M. H., Aykol, M., Herring, P. K., Fraggedakis, D., Bazant, M. Z., Harris, S. J., Chueh, W. C., & Braatz, R. D. (2019). Data-driven prediction of battery cycle life before capacity degradation. Nature Energy, 4(5), 383–391. link
  9. Saha, B., & Goebel, K. (2007). Battery data set. NASA Prognostics Data Repository, NASA Ames Research Center. link
  10. International Organization for Standardization. (2025). Condition monitoring and diagnostics of machine systems: Prognostics, Part 1: General guidelines and requirements (ISO 13381-1:2025). link

Further reading

Study the assigned knowledge units in advance, review media and take the module quiz

In class / field

Lab or field practice from worksheets with a safety checklist

Learning evidence: Checked worksheets and quiz results

Module quiz

This is a formative self-check, not a graded exam

Knowledge domain: Mathematics, physics and statistics · Programming and digital technology · Automation, robotics and swarms