Code Monkey home page Code Monkey logo

gandalf1819 / sf-opioid-crisis Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 8.48 MB

San Francisco (SF) has a long history of pushing the envelope on progressive public health solutions, including medical cannabis and needle exchange, before either was legal or broadly embraced. It is so out of proportion, that California passed a bill allowing SF to open Safe Injection Sites (SIS).

Home Page: https://towardsdatascience.com/san-franciscos-opioid-crisis-and-drug-problem-and-effects-on-public-safety-1ffad5040e0f

License: MIT License

Jupyter Notebook 100.00%
opioid-crisis sf-opioid-crisis francisco python3 jupyter-notebook google-colaboratory machine-learning-algorithms logistic-regression xgboost knn-classifier

sf-opioid-crisis's Introduction

SF-Opioid-Crisis

License: MIT PRs Welcome Python

Buy Me A Coffee

San Francisco

San Francisco (SF) has a long history of pushing the envelope on progressive public health solutions, including medical cannabis and needle exchange, before either was legal or broadly embraced. It is so out of proportion, that California passed a bill allowing SF to open Safe Injection Sites (SIS).

Safe injection sites (SIS):

Safe injection sites are medically supervised facilities designed to provide a hygienic and stress-free environment in which individuals are able to consume illicit recreational drugs intravenously and reduce nuisance from public drug use. They are part of a harm reduction approach towards drug problems. North America’s first SIS Insite opened in the Downtown Eastside (DTES) neighborhood of Vancouver in 2003.

Check out the Medium post for the complete analysis published in Towards Data Science here:
https://towardsdatascience.com/san-franciscos-opioid-crisis-and-drug-problem-and-effects-on-public-safety-1ffad5040e0f

Potential Questions:

  1. Comparing types of crime across different neighborhoods. What are the top 5 neighborhoods, where you can get assaulted? Do certain “pairs” of crime frequently co-occur together in a certain neighborhood?
  2. Identifying potential neighborhoods for installing SIS for San Francisco government

Target Variables:

  1. Correlation between types of crime and neighborhoods from 2003 to 2018
  2. Do certain types of crime co-occur together frequently, or co-occur together in particular neighborhoods (i.e. association rule mining)
  3. Correlation between types of drugs used and neighborhoods from 2003 to 2018
  4. Identify potential neighborhoods/areas for San Francisco’s government to build safe injection sites
  5. Predict the type/category of crime-based on spatial and temporal features provided

Data:

Our data is collected from the San Francisco police department’s database. It is his- torical data regarding crimes from 2003 to May 2018. The dataset has 13 columns.

Dataset

Analysis Approach:

  1. Perform data profiling using frequent statistics, and detect any outliers. For example, EDA/visualizations, null analysis. Semantic profiling to identify ho- mogeneous columns - to eliminate extraneous features
  2. Create cluster-maps between crime type/category and neighborhoods - perform data normalization/standardization as necessary. Cluster-maps i.e. unsuper- vised learning, will help us to find the correlation between different neighbor- hoods and type of crime.
  3. Since this is a classification problem, we are using algorithms like XGBoost, CatBoost, Naive Bayes and Random Forest classifier with the response/target variable as the category/type of crime, and predictors as spatial-temporal columns. Hyperparamater tuning using k-folds cross-validation
  4. Preprocess data to filter out crimes that involved Drugs/Narcotics. Perform Step 1 on this subset again. Perform aggregations as necessary to get granu- lar information i.e. Narcotics based crimes categorized by types of drugs i.e. opioids, marijuana, etc.
  5. Create cluster-maps between different types of drugs and neighborhoods. Normalize or standardize data as required
  6. Encode the data to a transactional form - execute Apriori and FP-growth to find interesting patterns (i.e association rules). Comparative study : FP- Growth vs Apriori

Results:

Distribution of categories of crimes from 2003 to 2018:

Picture-1

After Normalization

Picture-2

Cluster-maps b/w categories of crimes vs neighborhoods:

Picture-3

Picture-4

Cluster-maps b/w different opioids & neighborhoods:

Picture-9

Picture-5

Specific Opioid Distributions across time:

Picture-6

Picture-7

Opioid Distributions across years:

Picture-8

Interactive Visualizations

Check out interactive visualizations on the Opioid dataset in Tableau:

https://public.tableau.com/profile/chinmaynw#!/vizhome/SFDrugOpioidCrisis/Sheet1

Team:

References:

  1. https://www.kqed.org/news/11766169/san-francisco-fentanyl-deaths-up-almost-150
  2. https://www.sfchronicle.com/bayarea/article/Bay-Briefing-Fentanyl-epidemic-worsens-in-San-14032040.php
  3. https://www.businessinsider.com/san-franciscos-dirtiest-street-has-a-drug-market-and-piles-of-poop-2018-10
  4. https://www.sfchronicle.com/bayarea/article/California-bill-allowing-San-Francisco-safe-13589277.php
  5. https://data.sfgov.org/Public-Safety/Police-Department-Incident-Reports-Historical-2003/tmnf-yvry/data
  6. https://data.sfgov.org/Public-Safety/Police-Department-Incident-Reports-2018-to-Present/wg3w-h783/data
  7. https://data.sfgov.org/d/wkhw-cjsf

sf-opioid-crisis's People

Contributors

gandalf1819 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.