Auto MPG#
City-cycle fuel consumption in miles per gallon of 398 cars, to be predicted from seven features of the car. It is a small regression dataset with a few missing values in one feature, which makes it a good place to practise imputation.
Overview#
Loader |
|
Task |
Regression |
Samples |
398 |
Features |
7 |
Targets |
1 continuous target, |
Missing values |
6 values in 1 columns, stored as |
License |
CC BY 4.0 |
Features#
The features are stored in this order: cylinders, displacement, horsepower,
weight, acceleration, model_year and origin. The source describes
cylinders, model_year and origin as multi-valued discrete features and the other
four as continuous. All of them are stored as float64 with the numbers of the source.
The UCI page gives no units for the features.
origin has the values 1, 2 and 3. The source does not say what they stand for, so the
feature has no category names and data.categorical_features is empty.
6 values of horsepower are missing in the source and are stored as NaN. The name of
the car is an identifier that is unique for each car, so it is not stored.
Target#
y is mpg, the fuel consumption in miles per gallon, stored as float64. A higher
value means a more economical car. The source removed 8 cars of the StatLib original
because their mpg was unknown, so the target has no missing values.
Source and citation#
Source: UCI Machine Learning Repository
Obtained from: UCI Machine Learning Repository, dataset 9, downloaded with the ucimlrepo package: all 398 examples of the revised version, in which the source already removed 8 examples of the StatLib original because their mpg was unknown. The ucimlrepo version is recorded in the file.
Creators: R. Quinlan
Please cite the dataset as:
Quinlan, R. (1993). Auto MPG [Dataset]. UCI Machine Learning Repository. https://doi.org/10.24432/C5859H
See also:
Quinlan, R. (1993). Combining Instance-Based and Model-Based Learning. In Proceedings on the Tenth International Conference of Machine Learning, 236-243, University of Massachusetts, Amherst. Morgan Kaufmann.
License#
CC BY 4.0, as stated by the source. The license was checked at the source on 2026-10-24. See License and citation.
Changes made#
Converted to the NumPy NPZ format. Features and the target mpg are stored as float64.
The 6 missing values of horsepower are stored as NaN.
The column car_name, which UCI marks as an identifier and describes as a string that is unique for each instance, is not stored, because X holds numbers only. The other columns are stored in the order of the data description of the source.
Note
The source took the data from the StatLib library at Carnegie Mellon University, where it was used in the 1983 American Statistical Association Exposition, and calls it a slightly modified version of that dataset.
Note
6 values of horsepower are missing and stored as NaN. Impute them or drop the rows before fitting a model that cannot handle NaN.
Note
cylinders, model_year and origin are multi-valued discrete features in the source and are stored as its numbers. The source does not say what the numbers of origin stand for, so origin has no category names.
Note
mpg is fuel consumption in miles per gallon, so a higher value means a more economical car.
Example#
>>> import numpy as np
>>> from pyml_datasets import load_auto_mpg
>>> data = load_auto_mpg()
>>> data.X.shape, data.y.shape
((398, 7), (398,))
>>> data.feature_names[2]
'horsepower'
>>> data.has_missing, int(np.isnan(data.X).sum())
(True, 6)
>>> data.categorical_features
()