hosseinirtr / Fuel-Consumption

Fuel Consumption Regression Mode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ“ The Fuel Consumption Regression Model πŸš—

πŸ”Ž Overview

This code uses a dataset called "FuelConsumption.csv" to build a regression model for predicting CO2 emissions based on engine size, number of cylinders, and fuel consumption. The model is built using linear regression, and the performance is evaluated using the residual sum of squares and the variance score.

πŸ“¦ Required Libraries

  • NumPy
  • Pandas
  • Matplotlib
  • Scikit-learn

πŸƒβ€β™€οΈ How to Run

  1. Download the "FuelConsumption.csv" dataset and save it in the same directory as the code file.
  2. Install the required libraries using pip or conda.
  3. Open the code file in a Python environment (e.g. Jupyter Notebook).
  4. Run the code line by line, or run the entire code at once.

πŸ› οΈ Code Explanation

  • The code first imports the required libraries and reads in the dataset using Pandas.
  • The dataset is then summarized using the describe() function, and the relevant features are selected and stored in a new dataframe called cdf.
  • The dataset is split into a training set and a testing set using a 75-25 ratio.
  • A linear regression model is created using the training data, and the coefficients and intercept of the model are printed.
  • The model is then used to predict CO2 emissions for the testing data, and the residual sum of squares and variance score are calculated and printed.
  • Finally, the variance score is checked to see if it is equal to 1, which would indicate overfitting.

πŸ‘ Conclusion

This code provides a simple example of how to build a linear regression model for predicting CO2 emissions based on engine size, number of cylinders, and fuel consumption. It can be used as a starting point for more complex regression models or for predicting other variables based on different features.

About

Fuel Consumption Regression Mode


Languages

Language:Jupyter Notebook 100.0%