Coder Social home page Coder Social logo

gprzy / stroke-prediction Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.17 MB

🩺 Machine Learning applied to stroke prediction for unbalanced data

License: MIT License

Jupyter Notebook 100.00%
stroke-prediction data-science machine-learning random-forest unbalanced-data

stroke-prediction's Introduction

Stroke Prediction

Open in colab GitHub license

This project is a professional test for the position of Data Scientist, in which a problem of predicting stroke in patients is explored with machine learning. Furthermore, several steps of a typical data science project are covered, such as EDA, feature selection, as well as testing tree-based and neural network models.

Problem

According to the World Health Organization (WHO) stroke is the 2nd leading cause of death globally, responsible for approximately 11% of total deaths. This dataset is used to predict whether a patient is likely to get stroke based on the input parameters like gender, age, various diseases, and smoking status. Each row in the data provides relavant information about the patient. Continue reading here.

Binary classification

The problem can be approached as a binary classification task, in which the main objective is to correctly classify patients who are most likely to have a stroke. The data in question is unbalanced, making it difficult and inaccurate to use metrics such as accuracy. In this case, the metric chosen was the KS (Kolmogorov-Smirnov), as well as the ROC curve. From the metrics above, the equal error rate (EER) was calculated, as well as the optimal threshold to correctly classify the largest number of stroke patients as likely to have stroke (true positives).

Data can be obtained here: https://www.kaggle.com/fedesoriano/stroke-prediction-dataset

According to the data source, this is the description of the features:

  • id: unique identifier
  • gender: "Male", "Female" or "Other"
  • age: age of the patient
  • hypertension: 0 if the patient doesn't have hypertension, 1 if the patient has hypertension
  • heart_disease: 0 if the patient doesn't have any heart diseases, 1 if the patient has a heart disease
  • ever_married: "No" or "Yes"
  • work_type: "children", "Govt_jov", "Never_worked", "Private" or "Self-employed"
  • Residence_type: "Rural" or "Urban"
  • avg_glucose_level: average glucose level in blood
  • bmi: body mass index
  • smoking_status: "formerly smoked", "never smoked", "smokes" or "Unknown"*
  • stroke: 1 if the patient had a stroke or 0 if not

Results

The recall in test, using the StackingClassfier (combining RanfomForestClassifier, LinearSVC and MLP) was 94% for stroke patients (59 of 63 correct predictions in affirmative cases). Furthermore, the RanfomForestClassifier model was loaded into a class for use, as well as subjected to SHAP analysis for explainability.



The SHAP chart is about the RanfomForestClassifier, as is the ROC curve. The confusion matrix is about StackingClassifier.

stroke-prediction's People

Watchers

 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.