<jupyter_start><jupyter_text>EDA  Importing Libraries<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Importing Dataset<jupyter_code>dataset = pd.read_csv('Cleaned_Data.csv')
dataset.head().T<jupyter_output><empty_output><jupyter_text>Crash Year Distribution<jupyter_code>sns.countplot(x='Year', palette="pastel", data=dataset)
plt.gcf().set_size_inches(20,10)
plt.title('Year Distribution')
plt.xlabel('Year')
plt.xticks(rotation='vertical')
plt.ylabel('Count')
plt.show()<jupyter_output><empty_output><jupyter_text>Observations- We observe that during the years 2017, 2018 we have an average of 175000 accident.- There is a decrease in the number of accidents in 2020 and 2021 due to the pandemic.  Monthly Distribution of Accidents<jupyter_code>sns.catplot(y="Year", hue="Month", kind="count", palette="pastel", data=dataset)
plt.title('Monthly Distribution of Accidents')
plt.xlabel('Count')
plt.ylabel('Monthly')
plt.gcf().set_size_inches(20,20)
plt.show()<jupyter_output><empty_output><jupyter_text>Observation- From the above graph we can observe that their is a sudden spike in the number of accidents in the months of May and June.  Time of Accidents Distribution<jupyter_code>sns.countplot(x='Hour', palette="pastel", data=dataset)
plt.gcf().set_size_inches(20,10)
plt.title('Time Distribution')
plt.xlabel('Time')
plt.xticks(rotation='vertical')
plt.ylabel('Count')
plt.show()<jupyter_output><empty_output><jupyter_text>Observations- Contrast to common conception most of the accidents took place in the afternoon.  Contributing factor Distribution<jupyter_code>sns.countplot(x='CONTRIBUTING_FACTOR_1', palette="pastel", data=dataset, order=dataset.CONTRIBUTING_FACTOR_1.value_counts().index)
plt.gcf().set_size_inches(20,10)
plt.title('Contributing factor Distribution')
plt.xlabel('Contributing factors')
plt.xticks(rotation='vertical')
plt.ylabel('Count')
plt.show()<jupyter_output><empty_output><jupyter_text>Observations- Lack of attention was the major contributor for accidents followed by following too closely, not DUI or DWI.  Point of Impact and Pre Crash action correlation.<jupyter_code>sns.catplot(y="POINT_OF_IMPACT", hue="PRE_CRASH", kind="count", data=dataset)
plt.title('Point of Impact and Pre Crash action correlation')
plt.xlabel('Count')
plt.ylabel('Point of Impact')
plt.gcf().set_size_inches(30,15)
plt.show()<jupyter_output><empty_output><jupyter_text>Observations- For the accidents having damages on the front end the driver was going straight.- For the accidents having damages on the back end the driver was mostly backing the car.  Point of Impact and Contributing Factor correlation<jupyter_code>sns.catplot(y="POINT_OF_IMPACT", hue="CONTRIBUTING_FACTOR_1", kind="count", data=dataset)
plt.title('Point of Impact and Contributing Factor correlation')
plt.xlabel('Count')
plt.ylabel('Point of Impact')
plt.gcf().set_size_inches(30,15)
plt.show()<jupyter_output><empty_output><jupyter_text>Observations- For the accidents having damages on the front end the Contributing Factor was drivers inattention.- For the accidents having damages on the back end the Contributing Factor was the driver was backing the car unsafely.- For the accidents having damages on the sides end the Contributing Factor was unsafe lane changing.  Pre Crash and Contributing Factor correlation<jupyter_code>sns.catplot(y="PRE_CRASH", hue="CONTRIBUTING_FACTOR_1", kind="count", data=dataset)
plt.title('Pre Crash and Contributing Factor correlation')
plt.xlabel('Count')
plt.ylabel('Pre Crash Action')
plt.gcf().set_size_inches(30,15)
plt.show()<jupyter_output><empty_output><jupyter_text>Vehicle Make Distribution<jupyter_code>sns.countplot(x='MAKE', palette="pastel", data=dataset, order=dataset.MAKE.value_counts().index)
plt.gcf().set_size_inches(20,10)
plt.title('Vehicle Make Distribution')
plt.xlabel('Vehicle Make')
plt.xticks(rotation='vertical')
plt.ylabel('Count')
plt.show()<jupyter_output><empty_output><jupyter_text>How old the car is Distribution<jupyter_code>sns.countplot(x='how_old', palette="pastel", data=dataset)
plt.gcf().set_size_inches(20,10)
plt.title('how old the car is Distribution')
plt.xlabel('years')
plt.xticks(rotation='vertical')
plt.ylabel('Count')
plt.show()<jupyter_output><empty_output><jupyter_text>Vehicle Occupants and Contributing Factor Distribution.<jupyter_code>sns.catplot(y="VEHICLE_OCCUPANTS", hue="CONTRIBUTING_FACTOR_1", kind="count", palette="pastel", data=dataset)
plt.title('Monthly Distribution')
plt.xlabel('Count')
plt.ylabel('Monthly')
plt.gcf().set_size_inches(30,20)
plt.show()<jupyter_output><empty_output><jupyter_text>Observations- When there is only one person in the vehicle lack of attention and over speeding were the causes for accidents<jupyter_code>sns.catplot(x="DRIVER_SEX", hue="CONTRIBUTING_FACTOR_1", kind="count", palette="pastel", data=dataset)
plt.title('Sex and Contributing Factors')
plt.xlabel('Drivers sex')
plt.ylabel('Count')
plt.gcf().set_size_inches(20,15)
plt.show()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup