RISHABH LALA
  • Home
  • About Me
  • BLOG
  • My Apps
  • INTERESTS
    • Cloud Architecture >
      • AWS Intro >
        • AWS | Hands On 1
      • Cloud Computing
      • Cloud Architecting
      • BIG DATA >
        • MapReduce
        • SPARK
    • Web Development >
      • WEB APP DEV
      • Java Script
      • Java
      • Network Security
    • BIG DATA FOR BUSINESS >
      • SQL
    • Business Analytics >
      • Lift Curves
      • Market Basket Analysis
    • Valuation | Risk Free Rate >
      • Valuation | Example DCW_Part I
      • Valuation | Example DCW_Part II
      • Valuation | The Idea
      • Valuation | Financial Statements
      • Valuation | DCF & Risk Free Rate
      • Valuation|Equity Risk Premium
      • Valuation | Relative Valuation
      • Valuation | Terminal Value
      • Investing
    • Visualizations
    • Skill Set
    • Academics

Predicting Strokes: The Challenges of Imbalanced Data

Have you ever wondered how medical professionals predict the likelihood of a stroke? In an age where data drives decisions, the intersection of healthcare and machine learning offers fascinating insights into this critical health issue. As a Professional Licensed Engineer and ML Architect with years of experience, I've delved deep into this topic, and what I've discovered might surprise you.
Consider this: according to the World Health Organization, stroke is the second leading cause of death globally. But what if we could predict and prevent strokes before they happen? This isn't science fiction—it's the reality of modern data science applied to healthcare.

Let's explore some thought-provoking questions:
  • How accurate can machine learning models be in predicting strokes?
  • What factors contribute most significantly to stroke risk?
  • Can we trust AI to make decisions about our health?

To answer these questions, let's take a look at this recent ML study. The dataset of 5,110 patients with 12 different attributes, ranging from age and gender to more specific health indicators like hypertension and average glucose levels was observed by multiple machine learning algorithms. The machine learning algorithms included Logistic Regression, K-Nearest Neighbors, Support Vector Machines, and more advanced techniques like Random Forests and XGBoost. But here's where it gets interesting: the initial results on imbalanced data showed an impressive 95% accuracy. Sounds great, right?

Not so fast. As an experienced ML Architect, I can tell you that such high accuracy on imbalanced data often masks the model's true performance. Therefore techniques like SMOTE and undersampling to balance the dataset. This reduced the accuracy to around 70-80%, but—and this is crucial—it provided a much more realistic and reliable ML model.

If we naively train a model on such imbalanced data, it might achieve high accuracy simply by predicting that no one will have a stroke. But this isn't helpful; we need a model that can identify those at risk, even if they are a minority.

To help you build a perspective about the magnitude of this challenge, consider this: in a dataset of 1000 patients, if only 50 have had a stroke, a model that predicts no strokes for everyone would still be 95% accurate. Yet, it would fail to identify a single individual at risk. This highlights the critical need to go beyond accuracy and consider metrics like precision, recall, and the F1-score, which provide a more nuanced understanding of model performance on imbalanced data.

The Questions we as ML architects ask ourself are:
  • How can we ensure that our model doesn't simply learn to predict the majority class?
  • What techniques can we employ to give the minority class a stronger voice during training?
  • How do we strike the right balance between identifying those at risk and minimizing false alarms?

The answers include a toolkit of techniques to tackle imbalanced data. Let's explore a few:
  • Undersampling: This involves reducing the number of instances in the majority class to create a more balanced dataset.
  • Oversampling: This technique increases the number of instances in the minority class, often by creating synthetic samples.
  • Cost-sensitive learning: Here, we assign different weights to the classes, making misclassifications of the minority class more costly.
  • Feature Engineering: Features are carefully choosen or dropped based on their importance in prediction of the desired target variable.
  • Overfitting: Here, when the algorithm overlearns from the training data, and does not perform well on the test (or real world) data, the learning magnitute is brought down to close the gap between test and train accuracy score (or RMSE). 

Here's a fact that might surprise you: after balancing the data, the K-Nearest Neighbors algorithm emerged as one of the top performers, with an F1 score of 0.77 and an accuracy of 0.69. This means that 77% of the model's predictions were correct in identifying stroke risk.
But what does this mean for you and your health? It's important to understand that while these models are impressive, they're not infallible. They're tools that can assist healthcare professionals in making more informed decisions. The key factors that emerged as significant predictors included age, average glucose level, and the presence of heart disease or hypertension.

Let's ground these techniques in a real-world example. Imagine a stroke prediction model deployed in a hospital. A false negative (predicting no stroke when one occurs) could have catastrophic consequences, while a false positive (predicting a stroke when there isn't one) might lead to unnecessary anxiety and tests. By carefully choosing our approach and evaluating our model using appropriate metrics, we can strive to minimize both types of errors.

The Final Point:  As a seasoned tech and engineering professional, I've witnessed firsthand the transformative power of this field. People trust engineers similar to medical doctors with their lives, a bridge or building collapse is something nobody wants, that's why engineers are trusted.
Therefore, remember, while AI can process vast amounts of data, it's the human touch—the expertise of healthcare professionals and engineers like myself—that ultimately interprets and applies these insights to save lives.
Summary of Results: The project explored various machine learning algorithms for stroke prediction, encountering the common challenge of imbalanced data. The following summarizes the key findings:
  • Imbalanced Data: The dataset exhibited a significant class imbalance, with a small percentage of patients having experienced a stroke.
  • Model Performance: On the imbalanced data, models like Logistic Regression, Gaussian Naive Bayes, and Support Vector Machines achieved high accuracy (around 95%). However, this accuracy was misleading due to the class imbalance.
  • Undersampling: The use of undersampling techniques helped address the class imbalance, leading to more meaningful model evaluations.
  • K-Nearest Neighbors (KNN): KNN emerged as the best-performing model on the balanced dataset, achieving an F1-score of 0.77 and an accuracy of 0.69.
  • Other Models: Other models, including Decision Trees, Random Forest, and XGBoost, also showed promising results on the balanced dataset.
The project underscores the importance of carefully addressing imbalanced data in machine learning, particularly in critical healthcare applications like stroke prediction. By employing appropriate techniques and evaluating models using relevant metrics, we can strive to build robust and reliable predictive models that can truly make a difference in patient care.
GIT HUB REPOSITORY LINK
Create a free web site with Weebly
  • Home
  • About Me
  • BLOG
  • My Apps
  • INTERESTS
    • Cloud Architecture >
      • AWS Intro >
        • AWS | Hands On 1
      • Cloud Computing
      • Cloud Architecting
      • BIG DATA >
        • MapReduce
        • SPARK
    • Web Development >
      • WEB APP DEV
      • Java Script
      • Java
      • Network Security
    • BIG DATA FOR BUSINESS >
      • SQL
    • Business Analytics >
      • Lift Curves
      • Market Basket Analysis
    • Valuation | Risk Free Rate >
      • Valuation | Example DCW_Part I
      • Valuation | Example DCW_Part II
      • Valuation | The Idea
      • Valuation | Financial Statements
      • Valuation | DCF & Risk Free Rate
      • Valuation|Equity Risk Premium
      • Valuation | Relative Valuation
      • Valuation | Terminal Value
      • Investing
    • Visualizations
    • Skill Set
    • Academics