Vehicle Crashes & Machine Learning

Can machine learning help us understand the causes and the factors that affect car crash severity?In this article, we will do a complete machine learning pipeline from getting data through APIs, performing exploratory data analysis and formulating a real-world problem into a machine learning model..The complete code and Jupyter notebooks are available in this Github Gist..The whole process is carried out in Google Colab using their free GPU/TPU environment so you can directly open the notebook from Github and experiment it in Google Colab.Get the DataThe Crash Analysis System (CAS) data is available in different formats and APIs..It is simple to grab them through API interfaces, instead of downloading to your local machine..This is beneficial, as we will access the latest updated data every time we run the Jupyter notebook..I find this particular problem, the vehicle accidents, to be strongly related to location (Geography), so we will grab the Geojson file, instead of the usual CSV file, so that we can perform geographic data analysis without creating geometries from latitude and longitude and deal with coordinate reference systems and projections.We will use Geopandas library to read the data..If you are familiar with Pandas library, then you should feel home as Geopandas is built on top pandas..Geopandas is a high-level library that makes working with geographic data in Python easier as it allows pandas functionality and data types to allow spatial operations on geographic geometries..It is well integrated with the Python ecosystem and depends much on pandas, Matplotlib and shapely library for geometric operations.# Get the data from url and request it as json fileurl = ''geojson = requests.get(url).json()# Read the data as GeodataFrame in Geopandascrs = {'init': 'epsg:3851'} # Coordinate reference system (CRS) for Newzealandgdf = gpd.GeoDataFrame.from_features(geojson['features'], crs=crs)Exploratory Data AnalysisIn New Zealand, the total fatalities in crash accidents since the year 2000, up to 2018 is 6922..While the total number of serious injuries and minor injuries in car accidents reach 45044, 205895 respectively..Although this dataset records all crashes reported to NZ Police, we have to consider that all crashes are not reported to NZ police especially non-fatal crashes..Most of the crashes are non-injury crashes while fatal crashes are the least.. More details

Leave a Reply