<jupyter_start><jupyter_text>Capstone Project - Car Accident Severity  1 Introduction / Business Problem  Stakeholders:* Seattle Department of Transportation * Seattle Police Department - Traffic Enforcement Section* Car Drivers in Seattle Car accident is serious problem in Seattle. During the first six months of 2019, 101 people were seriously injured or killed in 98 collisions on Seattle streets, which is the highest number of crashes in the first half of a year since 2010, according to the data provided by the Seattle Department of Transportation (SDOT). The accident victims and their families, the insurance conpanies, health care personal and even the ordinary people, are affected by traffic accidents in many ways. Therefore, predicting the possibility and severity of a car accident based on the weather, road conditions and other factors is important. For drivers, they would drive more carefully or even change their travel if they are able to. For the police and traffic departments, they can put up some warning signs when there is a high traffic accident risk.  2. Data The dataset used in this analysis is provided by SDOT Traffic Management Division, Traffic Records Group. It includes all types of collisions at the intersection or mid-block of a segment recorded by the Traffic Records from 2004 to Present.The dataset contains 194,673 records with 38 attributes: 16 numerical and 22 categorical (see the figures below for the detailed descriptions). Among these 38 features, 6 of them have a large portion of null value, which are INTKEY, EXCEPTRSNCODE, EXCEPTRSNDESC, INATTENTIONIND, PEDROWNOTGRNT, SPEEDING. We will perform imputation on these feature during the feature engineering step. The target for this prediction task is the "Accident Severity", which are represented by three attributes: SEVERITYCODE, SEVERITYCODE.1, SEVERITYDESC, containing two sets of values: 1, 1, Property Damage Only Collision and 2, 2, Injury Collision. The target is unevenly distributed, with ~70% Property Damage Collisions Only and ~30% Injury Collisions. Therefore, target weights will be applied in the modeling step. ![](SDOT1.png)![](SDOT2.png)![](SDOT3.png)<jupyter_code>import numpy as np
import pandas as pd

pd.set_option('display.max_columns', None)
df = pd.read_csv('Data-Collisions.csv', low_memory=False)
df.head()
df.shape
df.filter(regex='SEVERITY').drop_duplicates()
df['SEVERITYCODE'].value_counts(normalize=True)
df.dtypes.value_counts()
df_na = df.isna().mean().to_frame()
df_na[df_na.iloc[:, 0] > 0.50]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.060452418096723866, 'fraction_numerical': 0.01950078003120125, 'mean_word_length': 5.543367346938775, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '151271', 'license': 'MIT', 'n_tokens_mistral': 697, 'n_tokens_neox': 628, 'n_words': 341, 'path': 'capstone.ipynb', 'repo_name': 'smartzdp/Coursera_Capstone', 'size': '2564'}