The goal of this project is to model the relationship between vehicle specifications and CO2 emissions using Multiple Linear Regression.
We aim to predict CO2EMISSIONS from features like ENGINESIZE, CYLINDERS, and FUELCONSUMPTION_COMB.
هدف پروژه مدلسازی رابطهی بین ویژگیهای فنی خودرو و میزان انتشار گاز CO2 با استفاده از رگرسیون خطی چندمتغیره است.
This notebook demonstrates the full pipeline of implementing multiple linear regression using scikit-learn:
-
Data Loading
Load theFuelConsumption.csvdataset using pandas. -
Feature Selection
Selected columns:
ENGINESIZE,CYLINDERS,FUELCONSUMPTION_COMB, andCO2EMISSIONS. -
Data Visualization
Scatter plots to explore correlation between features and target. -
Train-Test Split
Dataset split randomly into training (80%) and test (20%) subsets. -
Model Training
A linear regression model is trained using:regr = LinearRegression() regr.fit(train_x, train_y)
``
-
Evaluation
- Coefficients and intercept are printed.
- R² score is computed on test data using
r2_score.
- Python 3
- Pandas – data manipulation
- NumPy – numerical operations
- Matplotlib & Pylab – plotting
- scikit-learn –
LinearRegressionandr2_score
pip install pandas numpy matplotlib scikit-learnPlace FuelConsumption.csv in the appropriate directory or update the path in the notebook accordingly.
Use Jupyter to open and run the notebook:
jupyter notebook 02_Multiple-Linear-Regression.ipynb-
Coefficients:
[[10.52277345, 7.57289264, 9.46033011]] -
R² Score: ~0.84 (reported from other version)
مدل موفق شد با دقت حدود ۸۴٪ واریانس CO2 را با استفاده از ویژگیها پیشبینی کند.
ENGINESIZE | CYLINDERS | FUELCONSUMPTION_COMB | CO2EMISSIONS
2.0 | 4 | 8.5 | 196
ENGINESIZE | CYLINDERS | FUELCONSUMPTION_COMB | CO2EMISSIONS
2.4 | 4 | 9.6 | 221
ENGINESIZEvsCO2EMISSIONS- Train/Test scatter plot
- Regression line on training data
نمودارها برای درک بهتر رابطه ویژگیها و متغیر هدف استفاده شدهاند.
- Practical understanding of multiple linear regression
- Feature selection and preprocessing
- Model training with scikit-learn
- Use of R² score for evaluation
- Professional plotting for data interpretation
- Documentation and clarity in model-building steps
Mehran Asgari 📧 imehranasgari@gmail.com 🔗 github.com/imehranasgari
This project is licensed under the Apache 2.0 License.