Learning

Estimate car emissions using machine learning

Estimate vehicle CO₂ ratings from fuel-consumption data

This example learns the relationship between vehicle specifications, standardized fuel-consumption ratings and reported carbon-dioxide emissions. It can support catalogue screening, engineering comparison and data-quality checks while keeping certification decisions with approved test procedures.

7,385vehicle records
11logical inputs
0.9945testing determination
2.47 g/kmtesting MAE

1. Industrial challenge

Vehicle programmes, fleet teams and sustainability functions often need an early estimate or an independent plausibility check before a complete certification record is available. This approximation model maps categorical vehicle descriptors and standardized fuel-consumption ratings to estimated co2_emissions in grams per kilometre.

Screen vehicle specificationsEstimate whether a catalogue CO₂ value is consistent with its powertrain and fuel-consumption record.
Compare fleet candidatesUse one consistent analytical workflow to support procurement and portfolio decarbonization reviews.
Prioritize data-quality checksFlag large measured-versus-expected differences for source-data or homologation review.
Vehicle engineeringHomologationFleet managementSustainabilityAutomotive data quality
Scope of this example. The target is a model-specific fuel-consumption rating expressed as g CO₂/km. It is not an on-road emissions measurement, regulatory certificate or substitute for an approved vehicle test.

2. Data set

The updated co2_emissions.csv contains 7,385 records, eleven inputs and one target. The prepared file uses semicolon delimiters and contains no missing values.

VariableMeaningType, unit or range
brandVehicle manufacturerCategorical; 42 brands
modelCommercial model designationCategorical; 2,053 values
vehicle_classVehicle body/class categoryCategorical; 16 classes
engine_sizeEngine displacement0.9 to 8.4 L
cylindersEngine cylinder count3 to 16
transmissionA automatic, AM automated manual, AS automatic select shift, AV continuously variable, M manual5 categories
fuel_typeD diesel, E ethanol/E85, N natural gas, X regular gasoline, Z premium gasoline5 categories
fuel_consumption_cityStandardized city fuel consumption4.2 to 30.6 L/100 km
fuel_consumption_hwyStandardized highway fuel consumption4.0 to 20.6 L/100 km
fuel_consumption_comb(l/100km)Combined fuel consumption4.1 to 26.1 L/100 km
fuel_consumption_comb(mpg)Combined fuel economy11 to 69 mpg
co2_emissionsReported CO₂ emissions ratingTarget; 96 to 522 g/km
Distribution of vehicle carbon-dioxide emissions in grams per kilometre
Target distribution. Most records lie between approximately 180 and 330 g/km, with a sparse high-emission tail.
Pearson correlations between vehicle inputs and carbon-dioxide emissions
Dominant numeric drivers. Combined, city and highway consumption have the strongest positive relationships; combined mpg has the expected inverse relationship. Correlations for encoded categorical variables are not an interpretable importance measure.
Vehicle carbon-dioxide emissions against combined fuel economy in miles per gallon

The curved inverse pattern against mpg is expected because mpg and L/100 km are reciprocal representations of fuel economy. Including both variables gives the network redundant information and should be reviewed in a production feature set.

Validation design. The saved project uses a random 60/20/20 split: 4,431 training, 1,477 selection and 1,477 testing rows. The file contains 1,112 exact duplicate rows; 293 testing rows also appear exactly in training. Grouping duplicates and restoring model year before splitting would provide a more defensible estimate for unseen vehicles.

3. Model

The network receives eleven logical variables. One-hot encoding expands the five categorical inputs—especially the 2,053-value model field—to 2,127 input features. Numeric variables use mean-and-standard-deviation scaling, while categorical features use minimum–maximum scaling.

A hidden layer with three tanh neurons feeds one identity output neuron. The result is unscaled to g CO₂/km. The saved project applies no output bounding.

Vehicle CO2 neural network with eleven logical inputs, three hidden neurons and one output

4. Training strategy

The model minimizes normalized squared error with L2 regularization of 0.01 and the quasi-Newton method. The recorded run contains 152 epochs: training error falls from 0.974 to 0.00559, while selection error falls from 0.180 to 0.00135.

Quasi-Newton training and selection error history for vehicle CO2 prediction

The smooth convergence supports optimization of the configured network. The unusually low selection error should still be interpreted alongside duplicate overlap and the strong deterministic relationship between fuel consumption, fuel type and CO₂ rating.

5. Model selection

No separate neuron-selection or input-selection task is stored in the regenerated output. The example therefore keeps the configured three-neuron hidden layer and does not claim it as an independently selected optimum.

Professional next step. Repeat selection after grouping duplicate records and compare an engineering-only feature set that excludes high-cardinality model identifiers and one of the two equivalent combined-consumption measures.

6. Testing analysis

The final network is evaluated on 1,477 testing records. Neural Designer reports a determination coefficient of 0.9945. The conventional SSE-based R² is 0.9944.

0.9945determination
2.47 g/kmmean absolute error
4.36 g/kmroot mean squared error
6.32 g/km95th percentile absolute error

Transparent baseline comparison

A linear benchmark was fitted on the same training rows using only combined L/100 km and fuel-type indicators, then evaluated on the same testing rows.

ModelTesting R²MAE (g/km)RMSE (g/km)
Neural network0.99442.474.36
Linear consumption + fuel baseline0.99213.065.20

The network reduces MAE by 19.2% relative to this strong transparent baseline. That improvement is real on the configured split, but it is modest enough that interpretability and unseen-category handling should influence the production choice.

Observed versus predicted vehicle carbon-dioxide emissions on the testing set
Goodness of fit. Most predictions follow the identity line closely. The largest absolute error is 87.0 g/km, and the highest observed value is visibly underpredicted.

7. Model deployment

A defensible application is a catalogue or homologation-data consistency check, not a replacement for the official test. Vehicle data is validated, passed to the model, compared with the recorded rating and routed for review when the residual exceeds a documented tolerance.

Vehicle specification and rating data
Schema, category and unit validation
CO₂ estimation model
Residual check and engineering review

Representative testing case: Toyota Camry

This input combination is a real testing record and does not occur in the training subset. Its absolute error is close to the overall testing MAE, making it more representative than a specially selected near-perfect prediction.

Vehicle inputValue
Brand / modelTOYOTA CAMRY
Vehicle classMid-size
Engine2.5 L, 4 cylinders
TransmissionAS — automatic select shift
FuelX — regular gasoline
City / highway9.5 / 6.6 L/100 km
Combined consumption8.2 L/100 km (34 mpg)
Resultg CO₂/km
Reported rating189
Model estimate191.1
Residual+2.1 (+1.1%)
Empirical p95 absolute-error reference±6.3

Operational interpretation: the estimate is 2.1 g/km from the recorded value, inside the model’s empirical 95th-percentile absolute-error reference. A workflow could accept this row as internally consistent while sending larger residuals for source-data and engineering review. The p95 value is a screening tolerance reference, not a formal prediction interval.

Local sensitivity at a real vehicle reference

The regenerated directional-output task now starts from a valid vehicle record. The HTML table reproduces the reference values used by Neural Designer.

Reference inputValue
VehicleACURA RLX HYBRID, mid-size
Engine3.5 L, 6 cylinders
Transmission / fuelAM / Z — automated manual / premium gasoline
City consumption8.0 L/100 km
Highway consumption7.5 L/100 km
Combined consumption7.7 L/100 km (37 mpg)
Model estimate at reference181.1 g CO₂/km
Local sensitivity of predicted vehicle carbon-dioxide emissions to city fuel consumption from an ACURA RLX HYBRID reference point

The curve shows the model response when only fuel_consumption_city changes and every other input remains fixed. Interpret it only inside the observed city-consumption range of 4.2 to 30.6 L/100 km; the chart extends beyond that domain for visualization. Because city, highway, combined L/100 km and mpg are mathematically related, this is a local sensitivity analysis rather than a feasible vehicle-configuration scenario. Operational comparisons should update the linked consumption fields consistently or compare complete observed configurations.

Deployment boundary. Validate category mappings, reject unseen brands/models or route them to a fallback model, version every prediction, monitor residual and feature drift, and keep regulatory or procurement decisions under qualified human review. This model is not a certified emissions or homologation system.

8. Scope and limitations

  • The prepared extract does not contain model year, so temporal validation and year-to-year regulatory or powertrain shifts cannot be tested.
  • There are 1,112 exact duplicate rows. Random splitting places 293 exact testing rows in training and 462 testing input combinations in training.
  • The model field has 2,053 categories. New vehicle names require an explicit unknown-category policy or a model based on transferable engineering variables.
  • City, highway and combined consumption are strongly related, while combined mpg is a reciprocal representation of combined L/100 km. This multicollinearity increases redundancy.
  • Fuel consumption and fuel type already determine most of the reported CO₂ rating. The neural network should be compared with a transparent emissions-factor or linear calculation before deployment.
  • The target represents standardized/model-specific ratings, not real-world driving emissions. Driver behaviour, load, weather, traffic, maintenance and route conditions are outside the model.
  • The highest-emission observations are sparse, and the goodness-of-fit chart shows underprediction at the extreme tail.
  • Production validation should hold out complete model families and future model years, document unit and category mappings, and monitor data and residual drift.

References