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.
Live Links
The repository, this page, and a ZIP of the current main branch.
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/
I re-ran the work from src/
What's Inside
notebooks/i222327_Mohammad_Rohaan_A_03_ML.ipynb
The original 23-cell walkthrough, with the executed outputs still in it.
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/missions.csv
The ten-row table, same values as the notebook and the brief.
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) | Roughness | Duration (min) | Energy (Wh) | Split |
|---|---|---|---|---|---|---|
| 0 | 10 | 1.2 | 3 | 15 | 120 | train |
| 1 | 15 | 1.5 | 5 | 20 | 180 | test |
| 2 | 8 | 1.0 | 2 | 10 | 90 | train |
| 3 | 20 | 1.8 | 6 | 25 | 250 | train |
| 4 | 12 | 1.3 | 4 | 18 | 150 | train |
| 5 | 18 | 1.6 | 7 | 22 | 220 | train |
| 6 | 5 | 0.8 | 3 | 12 | 80 | train |
| 7 | 22 | 2.0 | 8 | 30 | 300 | train |
| 8 | 14 | 1.4 | 5 | 19 | 170 | test |
| 9 | 16 | 1.7 | 6 | 21 | 210 | train |
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
Split
train_test_split(test_size=0.2, random_state=42) — eight training rows, two test rows (loads 14 and 15 kg).
Scale
StandardScaler fitted on the training features only, then applied to the test rows. The target is not scaled, same as the notebook.
SVR
SVR(kernel='rbf') with library defaults: C=1.0, epsilon=0.1, gamma='scale'. All eight training rows are support vectors.
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
| Model | MSE | RMSE | MAE | R² |
|---|---|---|---|---|
| SVR (RBF) | 47.260492821706 | 6.874626740537 | 5.063336003029 | −0.890419712868 |
| Linear Regression | 70.651898982064 | 8.405468397541 | 8.327820078686 | −1.826075959283 |
| Train-mean baseline | 31.250000000000 | 5.590169943749 | 5.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)
| Model | MSE | RMSE | MAE | R² |
|---|---|---|---|---|
| SVR (RBF) | 5209.865034105771 | 72.179394802851 | 65.038876736685 | 0.060227276824 |
| Linear Regression | 20.275891092016 | 4.502875869044 | 3.983685333438 | 0.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
| Row | Load | Actual | Pred. SVR | Pred. LR | Err. SVR | Err. LR |
|---|---|---|---|---|---|---|
| 8 | 14 | 170 | 179.713403 | 177.187947 | +9.713403 | +7.187947 |
| 1 | 15 | 180 | 180.413269 | 189.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.
| File | What’s in it |
|---|---|
| data/ | All ten missions |
| results/ | Test and training MSE, RMSE, MAE and R², plus the train-mean baseline |
| results/ | The two test rows, both predictions, and signed errors |
| results/ | Linear coefficients on the standardised features |
| results/ | The 5×5 Pearson matrix |
| results/ | The [25, 2.2, 7, 35] query, SVR and linear |
| notebooks/ | The original executed notebook |
| docs/ | The assignment brief |
Screenshots
24 images, each 1600×1000. Click one to enlarge it.
No matching screenshots.
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/
License
The code in this repository is under the MIT License, Copyright (c) 2026 Mohammad Rohaan.