ML for Robotics · CS-4090 · 22I-2327

Predicting a robot’s energy use from four mission numbers

I fitted an RBF support-vector regressor and ordinary least squares on a ten-mission table, then held out two rows. Both models have negative test R². The SVR comes back at −0.8904, a little less bad than the line, and still worse than predicting the training-set mean.

Python 3 scikit-learn SVR and LinearRegression Jupyter Notebook License: MIT
10Missions in the table
8 / 2Train / test, random_state=42
−0.8904Test R², RBF SVR
−1.8261Test R², linear regression

Overview

This is Assignment 03 from ML for Robotics (CS-4090), Spring 2026. I wanted to see whether an RBF support-vector regressor could map load, speed, terrain roughness and task duration to a robot’s energy use, in watt-hours, better than a straight line.

The table is the ten-row example from the assignment brief — there is no larger log in this repository. I hard-coded those missions in the notebook, and they also sit in data/missions.csv.

I re-ran the work from src/predict_robot_energy.py. The printed test scores match the executed notebook exactly: SVR MSE 47.26049282170618, R² −0.8904197128682472; linear regression MSE 70.65189898206445, R² −1.8260759592825782. A train-mean baseline on the same two rows has MSE 31.25, which is ahead of both. With only two held-out points I am not treating the ranking as a stable result — only as what this split produced. The numbers from that run are under results/.

What's Inside

Notebook

notebooks/i222327_Mohammad_Rohaan_A_03_ML.ipynb

The original 23-cell walkthrough, with the executed outputs still in it.

Script

src/predict_robot_energy.py

The same split, scaler and two fits, runnable from the command line. It prints the report and writes the files under results/.

Data

data/missions.csv

The ten-row table, same values as the notebook and the brief.

Results

results/

metrics.csv, coefficients, predictions with errors, the out-of-range query, and the figures.

The Data

Ten missions, five columns, no missing cells. The values are exactly the ones in the assignment brief.

#Load (kg)Speed (m/s)RoughnessDuration (min)Energy (Wh)Split
0101.2315120train
1151.5520180test
281.021090train
3201.8625250train
4121.3418150train
5181.6722220train
650.831280train
7222.0830300train
8141.4519170test
9161.7621210train

This is a hand-built example, not a logged fleet. The four inputs move together, and so does energy. Pearson correlations with the target: duration 0.9868, load 0.9867, speed 0.9830, roughness 0.9572. The inputs are also strongly correlated with each other (0.92 to 0.99), so I would not read a single coefficient as the isolated effect of roughness.

How the Models Are Fitted

1

Split

train_test_split(test_size=0.2, random_state=42) — eight training rows, two test rows (loads 14 and 15 kg).

2

Scale

StandardScaler fitted on the training features only, then applied to the test rows. The target is not scaled, same as the notebook.

3

SVR

SVR(kernel='rbf') with library defaults: C=1.0, epsilon=0.1, gamma='scale'. All eight training rows are support vectors.

4

Linear regression

LinearRegression() on the same scaled training features. Intercept on, no regularisation.

Test Results

Test set, two rows. The SVR and linear-regression figures match the original notebook exactly. The train-mean baseline is an extra comparison from the re-run.

Test metrics

ModelMSERMSEMAER²
SVR (RBF)47.2604928217066.8746267405375.063336003029−0.890419712868
Linear Regression70.6518989820648.4054683975418.327820078686−1.826075959283
Train-mean baseline31.2500000000005.5901699437495.000000000000−0.250000000000

The baseline is ahead of both fitted models on this split. Negative R² already means worse than the mean of the test energies; the training-mean comparison says the same thing more directly.

Training metrics (8 rows)

ModelMSERMSEMAER²
SVR (RBF)5209.86503410577172.17939480285165.0388767366850.060227276824
Linear Regression20.2758910920164.5028758690443.9836853334380.996342567560

Linear regression is almost perfect on the eight training rows and then falls apart on the two held-out ones. The SVR barely leaves a flat line on either split.

The two test predictions

RowLoadActualPred. SVRPred. LRErr. SVRErr. LR
814170179.713403177.187947+9.713403+7.187947
115180180.413269189.467694+0.413269+9.467694

Out-of-range query

The brief asks for a prediction at load 25 kg, speed 2.2 m/s, roughness 7, duration 35 minutes — outside the training hull. The SVR answers 180.893219405397 Wh (the notebook’s figure). Linear regression answers 332.50 Wh.

Linear equation (standardised features)

Energy ≈ 177.5 + 24.6713×z(Load) + 13.9964×z(Speed) + 9.4609×z(Roughness) + 27.2790×z(Duration)

The intercept is the training-set mean, 177.5 Wh. Because the four inputs are nearly collinear, I would not treat these coefficients as a physical breakdown. The raw numbers are in results/.

Training and Test Files

Everything the script writes, plus the original notebook and the brief.

FileWhat’s in it
data/missions.csvAll ten missions
results/metrics.csvTest and training MSE, RMSE, MAE and R², plus the train-mean baseline
results/predictions_test.csvThe two test rows, both predictions, and signed errors
results/coefficients_scaled.csvLinear coefficients on the standardised features
results/correlations.csvThe 5×5 Pearson matrix
results/ood_prediction.csvThe [25, 2.2, 7, 35] query, SVR and linear
notebooks/i222327_Mohammad_Rohaan_A_03_ML.ipynbThe original executed notebook
docs/assignment/Asg-3-ML-for-Robotics-Spring-2026-NU.pdfThe assignment brief

Folder Structure

Predict_Robot_Energy/
├── notebooks/                original executed notebook
├── src/predict_robot_energy.py
├── data/missions.csv         the ten-row table
├── results/                  metrics, coefficients, predictions, figures
├── docs/assignment/          the original brief
├── screenshots/              24 × 1600×1000
├── assets/                   css, js, favicon
├── index.html
├── requirements.txt
├── LICENSE                   MIT 2026
└── README.md

How to run

Python 3, with the packages in requirements.txt. The CSV is already in data/.

Linux / macOS

git clone https://github.com/rohaan2802/Predict_Robot_Energy.git
cd Predict_Robot_Energy
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python3 src/predict_robot_energy.py

Windows

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
python src\predict_robot_energy.py

That prints the notebook’s test scores, the extra training metrics and the out-of-range query, and writes files under results/. Optional flags: --data-dir, --results-dir and --no-plots. The same steps are in notebooks/i222327_Mohammad_Rohaan_A_03_ML.ipynb.

License

The code in this repository is under the MIT License, Copyright (c) 2026 Mohammad Rohaan.