<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yougeshshah on Medium]]></title>
        <description><![CDATA[Stories by Yougeshshah on Medium]]></description>
        <link>https://medium.com/@yougeshshah0?source=rss-e3e4ba6cc970------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oCeF88Mw2TUUpsaB</url>
            <title>Stories by Yougeshshah on Medium</title>
            <link>https://medium.com/@yougeshshah0?source=rss-e3e4ba6cc970------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:18:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yougeshshah0/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Data Analysis and Visualization of CO2 Emission]]></title>
            <link>https://medium.com/@yougeshshah0/data-analysis-and-visualization-of-co2-emission-b4102694efc6?source=rss-e3e4ba6cc970------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4102694efc6</guid>
            <dc:creator><![CDATA[Yougeshshah]]></dc:creator>
            <pubDate>Thu, 08 Jan 2026 14:18:11 GMT</pubDate>
            <atom:updated>2026-01-08T14:18:11.777Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Data analysis plays a crucial role in understanding real-world problems and making informed decisions. Python has become one of the most widely used languages for data analysis due to its simplicity and powerful ecosystem of libraries. This article focuses on analyzing vehicle data to understand and predict <strong>carbon dioxide (CO₂) emissions</strong>, an important factor in environmental sustainability and climate change.</p><p>Using Python libraries such as <strong>NumPy, Pandas, Matplotlib, and Scikit-learn</strong>, this study explores how vehicle characteristics influence CO₂ emissions and demonstrates how regression models can be used to make accurate predictions from real-world data.</p><h3>Objective</h3><p>The main objective of this analysis is to examine vehicle data and predict CO₂ emissions based on engine specifications and fuel consumption characteristics. Regression techniques are applied to understand how different vehicle features contribute to carbon emissions and to evaluate the effectiveness of predictive models.</p><h3>Dataset Overview</h3><p>The dataset contains <strong>7,385 vehicle records</strong> with <strong>12 attributes</strong>, including:</p><ul><li>Make and Model</li><li>Vehicle Class</li><li>Engine Size (L)</li><li>Number of Cylinders</li><li>Transmission Type</li><li>Fuel Type</li><li>Fuel Consumption (City, Highway, and Combined)</li><li>Fuel Consumption in MPG</li><li>CO₂ Emissions (g/km)</li></ul><p>This dataset provides a comprehensive view of vehicle performance and environmental impact.</p><h3>Tools and Libraries Used</h3><ul><li><strong>Pandas</strong>: Data loading and manipulation</li><li><strong>Matplotlib</strong>: Data visualization</li><li><strong>Scikit-learn</strong>: Regression models and evaluation metrics</li></ul><h3>Data Loading and Exploration</h3><p>We begin by importing the required libraries and loading the dataset.</p><pre># Import required libraries<br>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt</pre><pre># DataSet Import<br>df = pd.read_csv(&quot;CO2_Emissions.csv&quot;)</pre><h3><strong>Data Set Link</strong>:</h3><p>https://docs.google.com/spreadsheets/d/1ZUs74t3x2N3T5sK7qzVONIBfJWkFfBy1ZUSMrBpsLk8/edit?usp=sharing</p><p>To understand the structure of the dataset:</p><pre># View dataset<br>print(df.head())<br>print(df.shape)<br>print(df.columns)<br>print(df.dtypes)</pre><p><strong>Observations:</strong></p><ul><li>The dataset has <strong>7385 rows and 12 columns</strong></li><li>Contains both <strong>categorical and numerical</strong> features</li><li>No major missing values in key numerical columns</li></ul><h3>Data Visualization</h3><h3>Fuel Consumption Distribution</h3><pre># Histogram of Fuel Consumption<br>plt.figure()<br>plt.hist(df[&#39;Fuel Consumption Comb (L/100 km)&#39;], bins=20)<br>plt.xlabel(&quot;Fuel Consumption&quot;)<br>plt.ylabel(&quot;Frequency&quot;)<br>plt.title(&quot;Fuel Consumption Distribution&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*c8t1qEMFvt4VJbE9Q2gCbA.png" /></figure><h3>CO₂ Emissions Distribution</h3><pre># Histogram of CO2 Emissions<br>plt.hist(df[&#39;CO2 Emissions(g/km)&#39;], bins=20)<br>plt.xlabel(&quot;CO2 Emissions&quot;)<br>plt.ylabel(&quot;Frequency&quot;)<br>plt.title(&quot;CO2 Emissions Distribution&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*joeEW-iwpjc2dvjv4leQ_g.png" /></figure><p><strong>Insight:</strong><br> Both fuel consumption and CO₂ emissions show a <strong>right-skewed distribution</strong>, indicating that high-emission vehicles are fewer but significantly impact.</p><h3>Simple Linear Regression</h3><p>We first build a <strong>simple linear regression model</strong> using:</p><ul><li><strong>Independent Variable:</strong> Engine Size (L)</li><li><strong>Dependent Variable:</strong> CO₂ Emissions (g/km)</li></ul><pre>from sklearn.model_selection import train_test_split<br>from sklearn.linear_model import LinearRegression<br>from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score</pre><pre># Simple Linear Regression<br># ENGINE SIZE vs CO2<br><br>X = df[[&#39;Engine Size(L)&#39;]]<br>y = df[&#39;CO2 Emissions(g/km)&#39;]<br><br>#Split data (80% train and 20% test)<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<br><br>#Fit model<br>model1 = LinearRegression()<br>model1.fit(X_train, y_train)<br><br>#Evaluate<br>y_pred = model1.predict(X_test)<br><br>print(&quot;MAE:&quot;, mean_absolute_error(y_test, y_pred))<br>print(&quot;MSE:&quot;, mean_squared_error(y_test, y_pred))<br>print(&quot;R2:&quot;, r2_score(y_test, y_pred))</pre><h3>Model Performance</h3><ul><li><strong>MAE:</strong> ~22.9</li><li><strong>MSE:</strong> ~950</li><li><strong>R² Score:</strong> ~0.72</li></ul><p>This indicates a <strong>strong positive relationship</strong> between engine size and CO₂ emissions.</p><h3>Regression Visualization</h3><pre># Scatter plot with regression line<br>plt.scatter(X, y)<br>plt.plot(X, model1.predict(X), color=&#39;red&#39;)<br>plt.xlabel(&quot;Engine Size&quot;)<br>plt.ylabel(&quot;CO2 Emissions&quot;)<br>plt.title(&quot;Engine Size vs CO2 Emissions&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*90J1DNTlRs2va48KI2qBAA.png" /></figure><h3>Multiple Linear Regression</h3><p>To improve prediction accuracy, we include multiple predictors:</p><ul><li>Engine Size (L)</li><li>Number of Cylinders</li><li>Fuel Consumption (Combined)</li></ul><pre># Multiple Linear Regression<br>#Predictors Engine Size(L), Cylinders, Fuel Consumption Comb (L/100 km)<br>X_multi = df[[&#39;Engine Size(L)&#39;, &#39;Cylinders&#39;, &#39;Fuel Consumption Comb (L/100 km)&#39;]]<br>y = df[&#39;CO2 Emissions(g/km)&#39;]<br><br>#Split data (80% train and 20% test)<br>X_train, X_test, y_train, y_test = train_test_split(X_multi, y, test_size=0.2, random_state=42)<br><br>#Fit model<br>model2 = LinearRegression()<br>model2.fit(X_train, y_train)<br><br>#Evaluate<br>y_pred_multi = model2.predict(X_test)<br><br>print(&quot;MAE:&quot;, mean_absolute_error(y_test, y_pred_multi))<br>print(&quot;MSE:&quot;, mean_squared_error(y_test, y_pred_multi))<br>print(&quot;R2:&quot;, r2_score(y_test, y_pred_multi))</pre><h3>Improved Performance</h3><ul><li><strong>MAE:</strong> ~13.5</li><li><strong>MSE:</strong> ~422</li><li><strong>R² Score:</strong> ~0.88</li></ul><p>Including multiple predictors significantly enhances the model’s accuracy and explanatory power.</p><h3>Conclusion</h3><p>This analysis demonstrates that CO₂ emissions can be effectively predicted using vehicle engine and fuel consumption data. Engine size, number of cylinders, and fuel consumption are identified as key factors influencing emission levels. While engine size alone provides meaningful insights, models that incorporate multiple predictors deliver more accurate and reliable results.</p><p>The study highlights the importance of data analysis and machine learning techniques in understanding environmental impacts and supports the use of data-driven approaches for promoting sustainable transportation solutions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4102694efc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>