Analytics Vidhya

Analytics Vidhya is a community of Generative AI and Data Science professionals. We are building…

Follow publication

Carbon-dioxide emission estimator model

This story aims to built a simple co2 emission estimator model using dataset from UCI Machine Learning Repository.

This is a part of a sample project I had done, which aims to find out the carbon-dioxide emission estimation during a road trip. The dataset I used is from UCI Machine Learning Repository, and can be downloaded directly from here.

Firstly, we import typing, which provide runtime support for type hints.

import typing

As per data from U.S Environmental Protection Agency ( E.P.A ), grams of co2 produced per gallon in case of gasoline is 8,887 gm/gallon and for diesel it is 10,180 gm/gallon. Now, we use auto-mpg.data as data and converting it into pandas dataframe.

As this dataset, which I am working upon have number of columns, among which one of them contains information regarding car name, other contain information like car model and so on. I thought to make a function which provide suggestions of car names, which are similar to what user will input as car name.

When a user input a car name, this function is called and this function will provide suitable suggestions as per user input.

choose_car = input()
car_suggestions(choose_car)

After this the user chooses one among the suggested cars/vehicles, and also inputs distance to travel, but before that a function should be defined which should take two parameters i.e distance of trip and index number of car from suggestions, and should return co2 emission of the trip as output. The required function is as follows.

Now the user inputs car name from suggestions, and also inputs the trip distance, which are inputs for the above function.

Conclusion and Result

Through this we get co2 emission of a road trip. The function made for co2 emission i.e carbon_emission, only uses car mpg (mile per gallon) value, which is insufficient to calculate carbon-emission value, but as stated earlier that this is a simple project, hence I take only 1 parameter into consideration. Other parameters like car age, traffic, location, engine-type, vehicle type (light weight, heavy-duty) etc. play key role in co2 emission.

Feel free to comment below.

Sign up to discover human stories that deepen your understanding of the world.

Analytics Vidhya
Analytics Vidhya

Published in Analytics Vidhya

Analytics Vidhya is a community of Generative AI and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Mayank Bhandari
Mayank Bhandari

Written by Mayank Bhandari

Software Engineer who loves working with data, to enhance user experience.

No responses yet

Write a response