Sign in

Soledad Galli, PhD

@solegalli.bsky.social
130 followers 24 following 508 posts

Python Open-Source Developer | Developer Advocate | Scientific Python & Machine Learning | AI Educator | Author & Speaker Find out more at Train in Data: www.trainindata.com

PostsRepliesMedia
Soledad Galli, PhD @solegalli.bsky.social · 11h
Understand this diagram and you understand why resampling rarely improves a model. Cost, threshold and class weights are one lever 👇 www.trainindata.com/p/imbalanced-da…
Diagram showing cost, threshold, resampling and class weights as one cycle
000
Soledad Galli, PhD @solegalli.bsky.social · 13h
Resampling, class weights and threshold tuning are the same lever. None makes your model better at separating classes. They move where the decision boundary sits. The maths is in my blog 👇
blog.trainindata.com
Imbalanced Data in Machine Learning: Techniques and Best Practices
Learn why imbalanced datasets rarely need rebalancing. Compare SMOTE, sampling and class weights with strong classifiers, probability scoring and threshold tuning.
000
Soledad Galli, PhD @solegalli.bsky.social · 17h
Two models, identical ROC AUC of 1, very different log loss. Ranking and calibration are not the same thing. This article explains why 👇
towardsdatascience.com
Intuition behind ROC-AUC score
In Machine Learning, classification problem refers to predictive modeling where a class label needs to be predicted for a given...
000
Soledad Galli, PhD @solegalli.bsky.social · 20h
Different metrics evaluate different characteristics of a model's predictions, so no single metric is universally appropriate. The right choice depends on what you need the model to achieve.
010
Soledad Galli, PhD @solegalli.bsky.social · 13/10/2026
Most people assume class_weight only changes training. Set the weights, done, probabilities stay untouched. That assumption breaks down, and your predicted probabilities shift with it. What actually happens 👇
trainindata.com
Imbalanced Data - Myths, Mistakes and Modern Solu
Master imbalanced data with practical, modern machine learning techniques. Learn why class weights and resampling don’t improve performance, and how threshold tuning leads to better cost-sensitive decisions.
000
Soledad Galli, PhD @solegalli.bsky.social · 13/10/2026
Stop guessing which resampling method to use. The evidence is in my book on imbalanced data 👇 www.trainindata.com/p/imbalanced-da…
Book cover of Imbalanced Data: Myths, Mistakes and Modern Solutions
000
Soledad Galli, PhD @solegalli.bsky.social · 13/10/2026
Buried in this paper: micro precision and micro recall are mathematically identical. So why do we keep reporting both?
arxiv.org
Metrics for Multi-Class Classification: an Overview
Classification tasks in machine learning involving more than two classes are known by the name of "multi-class classification". Performance indicators are very useful when the aim is to evaluate and compare different classification models or machine learning techniques. Many metrics come in handy to test the ability of a multi-class classifier. Those metrics turn out to be useful at different stage of the development process, e.g. comparing the performance of two different models or analysing the behaviour of the same model by tuning different parameters. In this white paper we review a list of the most promising multi-class metrics, we highlight their advantages and disadvantages and show their possible usages during the development of a classification model.
000
Soledad Galli, PhD @solegalli.bsky.social · 13/10/2026
Most machine learning models are not really classifiers. We turn them into classifiers by setting a cutoff over their output and assigning each observation to a class based on it.
000
Soledad Galli, PhD @solegalli.bsky.social · 12/10/2026
Something I wish I had known in my first year as a data scientist: 0.5 is rarely a good threshold for a classification task.
trainindata.com
Imbalanced Data - Myths, Mistakes and Modern Solu
Master imbalanced data with practical, modern machine learning techniques. Learn why class weights and resampling don’t improve performance, and how threshold tuning leads to better cost-sensitive decisions.
000
Soledad Galli, PhD @solegalli.bsky.social · 12/10/2026
Same model, same predictions: ROC AUC of 0.91, average precision of 0.51. Neither number is wrong. They answer different questions. My blog plots both curves side by side and explains what each one tells you 👇
blog.trainindata.com
Precision-Recall Curves: A Complete Guide With Python Examples
Learn what Precision-Recall curves are, how they compare to ROC curves, and how to plot, interpret and evaluate them in Python with imbalanced data examples.
010
Soledad Galli, PhD @solegalli.bsky.social · 12/10/2026
Five years of imbalanced data research, summarised so you don't have to read all of it. Our free booklet, recently updated 👇
trainindata.com
7 Takes on Working with Imbalanced Data
Read Sole's discussion of three recent articles that shift the conversation around handling imbalanced datasets. These articles explore whether generating synthetic data is effective with current state-of-the-art algorithms, and examine the implications of using synthetic data on model performance and deployment.
010
Soledad Galli, PhD @solegalli.bsky.social · 09/10/2026
SMOTE raised recall from 0.76 to 0.80 on credit card fraud. Precision fell from 0.96 to 0.87. That is a threshold shift, not a better model. My blog gets the same result without synthetic data 👇
blog.trainindata.com
SMOTE in Python and whether you should still use it in 2026
Learn how to implement SMOTE in Python and whether you should still use it to work with imbalanced datasets in 2026.
000
Soledad Galli, PhD @solegalli.bsky.social · 09/10/2026
Job descriptions rarely tell the whole story. Did you apply for a job only to find out they were looking for something else? You are not alone. I talk about that in the next issue of my newsletter. Subscribe to say in the loop 👇 tech.trainindata.com
000
Soledad Galli, PhD @solegalli.bsky.social · 08/10/2026
More evidence that resampling does not improve performance when you measure properly. ROC-AUC and PR-AUC unchanged. Only precision and recall at the default threshold move.
medrxiv.org
Class imbalance correction in artificial intelligence models leads to miscalibrated clinical predictions: a real-world evaluation
Background Predictive models employing machine learning algorithms are increasingly being used in clinical decision making, and improperly calibrated models can result in systematic harm. We sought to investigate the impact of class imbalance correction, a commonly applied preprocessing step in machine learning model development, on calibration and modelled clinical decision making in a large real-world context. Methods A histogram boosted gradient classifier was trained on a highly imbalanced national dataset of > 1.8 million patients undergoing surgery, to predict the risk of 90-day mortality and complications after surgery. Class imbalance correction strategies including random oversampling, synthetic minority oversampling technique, random under-sampling, and cost-sensitive learning were compared to the natural distribution (‘natural’). Models were tested and compared with classification metrics, calibration plots, decision curve analysis, and simulated clinical impact analysis. Results The natural model demonstrated high performance (AUROC 0.94, 95% CI 0.94–0.95 for mortality; 0.84, 95% CI 0.84–0.85 for complications) and calibration (log loss 0.05, 95% CI 0.04–0.05 for mortality; 0.23, 95% CI 0.23–0.24 for complications). Class imbalance mitigation (CSL, ROS, RUS, and SMOTE) did not improve AUROC or AUPRC but increased recall and F1 scores at the expense of precision and accuracy. However, these methods severely compromised model calibration, leading to significant over-prediction of risks (up to a 62.8 % increase) as further evidenced by increased log loss across all mitigation techniques. Decision curve analysis and clinical scenario testing confirmed that the natural model provided the highest net benefit. Conclusion Class imbalance correction methods result in significant miscalibration, leading to possible harm when used for clinical decision making. ### Competing Interest Statement The authors have declared no competing interest. ### Funding Statement This work was funded by the Health Research Council of New Zealand 2025 Artificial Intelligence (AI) in Healthcare Project Grant. ### Author Declarations I confirm all relevant ethical guidelines have been followed, and any necessary IRB and/or ethics committee approvals have been obtained. Yes The details of the IRB/oversight body that provided approval or exemption for the research described are given below: Ethical approval was obtained from the Auckland Health Research Ethics Committee (AH29056). I confirm that all necessary patient/participant consent has been obtained and the appropriate institutional forms have been archived, and that any patient/participant/sample identifiers included were not known to anyone (e.g., hospital staff, patients or participants themselves) outside the research group so cannot be used to identify individuals. Yes I understand that all clinical trials and any other prospective interventional studies must be registered with an ICMJE-approved registry, such as ClinicalTrials.gov. I confirm that any such study reported in the manuscript has been registered and the trial registration ID is provided (note: if posting a prospective study registered retrospectively, please provide a statement in the trial ID field explaining why the study was not registered in advance). Yes I have followed all appropriate research reporting guidelines, such as any relevant EQUATOR Network research reporting checklist(s) and other pertinent material, if applicable. Yes Data can be obtained from the New Zealand Ministry of Health National Collections team. Requests can be made by contacting data-enquiries{at}health.govt.nz. A Python package was created to create training and evaluation pipelines and is freely available on Github at <<https://github.com/Surgical-Recovery-and-Safety-Lab/medpipe>>. The code used to train the models and create the figures is freely available on GitHub at <https://github.com/Surgical-Recovery-and-Safety-Lab/AI-risk-score>.
010
Soledad Galli, PhD @solegalli.bsky.social · 08/10/2026
What’s new in Machine Learning Interpretability? ✨ ELI5 replaces treeinterpreter scikit-learn or custom code replaces DALEX and ALIBI implementations And a small workaround keeps LIME running for now. Updated notebooks are ready!
trainindata.com
Machine Learning Interpretability
Learn to explain interpretable and black box machine learning models with LIME, Shap, partial dependence plots, ALE plots, permutation feature importance and more, utilizing Python open source libraries..
000
Soledad Galli, PhD @solegalli.bsky.social · 07/10/2026
You probably do not need to balance your data. Train a strong classifier on the original data, tune with log loss, then pick a threshold. My new blog explains why this beats reaching for SMOTE 👇
blog.trainindata.com
Imbalanced Data in Machine Learning: Techniques and Best Practices
Learn why imbalanced datasets rarely need rebalancing. Compare SMOTE, sampling and class weights with strong classifiers, probability scoring and threshold tuning.
000
Soledad Galli, PhD @solegalli.bsky.social · 07/10/2026
A churn paper compares RF and XGBoost against SMOTE, ADASYN and GNUS across four imbalance levels. It never reports either model without resampling. No baseline, no conclusion.
mdpi.com
Comprehensive Analysis of Random Forest and XGBoost Performance with SMOTE, ADASYN, and GNUS Under Varying Imbalance Levels
This study examines the efficacy of Random Forest and XGBoost classifiers in conjunction with three upsampling techniques—SMOTE, ADASYN, and Gaussian noise upsampling (GNUS)—across datasets with varying class imbalance levels, ranging from moderate to extreme (15% to 1% churn rate). Employing metrics such as F1 score, ROC AUC, PR AUC, Matthews Correlation Coefficient (MCC), and Cohen’s Kappa, this research provides a comprehensive evaluation of classifier performance under different imbalance scenarios, focusing on applications in the telecommunications domain. The findings highlight that tuned XGBoost paired with SMOTE (Tuned_XGB_SMOTE) consistently achieves the highest F1 score and robust performance across all imbalance levels. SMOTE emerged as the most effective upsampling method, particularly when used with XGBoost, whereas Random Forest performed poorly under severe imbalance. ADASYN showed moderate effectiveness with XGBoost but underperformed with Random Forest, and GNUS produced inconsistent results. This study underscores the impact of data imbalance, with MCC, Kappa, and F1 scores fluctuating significantly, whereas ROC AUC and PR AUC remained relatively stable. Moreover, rigorous statistical analyses employing the Friedman test and Nemenyi post hoc comparisons confirmed that the observed improvements in F1 score, PR-AUC, Kappa, and MCC were statistically significant (p < 0.05), with Tuned_XGB_SMOTE significantly outperforming Tuned_RF_GNUS. While differences in ROC-AUC were not significant, the consistency of these results across multiple performance metrics underscores the reliability of our framework, offering a statistically validated and attractive solution for model selection in imbalanced classification scenarios.
000
Soledad Galli, PhD @solegalli.bsky.social · 07/10/2026
Less time wrestling with libraries, more time understanding your models! 🔍 My Machine Learning Interpretability course now includes updated tools and notebooks. Already enrolled? Download the latest version and jump back in! www.trainindata.com/p/machine-learn…
000
Soledad Galli, PhD @solegalli.bsky.social · 06/10/2026
Every figure illustrates a concept instead of decorating the page. That's surprisingly rare. Says ChatGPT, not me. 👉 Chapter 2 in Imbalanced Data: Myths, Mistakes and Modern Solutions
trainindata.com
Imbalanced Data - Myths, Mistakes and Modern Solu
Master imbalanced data with practical, modern machine learning techniques. Learn why class weights and resampling don’t improve performance, and how threshold tuning leads to better cost-sensitive decisions.
000
Soledad Galli, PhD @solegalli.bsky.social · 06/10/2026
If ROC AUC never fully clicked for you, this walkthrough uses simple visual examples and it's the clearest explanation I've found 👇
towardsdatascience.com
Intuition behind ROC-AUC score
In Machine Learning, classification problem refers to predictive modeling where a class label needs to be predicted for a given...
000
Soledad Galli, PhD @solegalli.bsky.social · 06/10/2026
Python evolves. And my courses evolve with it! 🐍 I’ve updated Machine Learning Interpretability to replace libraries that haven’t kept up. Same interpretability methods, refreshed code to help you put them into practice.
trainindata.com
Machine Learning Interpretability
Learn to explain interpretable and black box machine learning models with LIME, Shap, partial dependence plots, ALE plots, permutation feature importance and more, utilizing Python open source libraries..
000
Soledad Galli, PhD @solegalli.bsky.social · 05/10/2026
PR curves are not automatically better than ROC curves on imbalanced data. That claim gets repeated everywhere, usually with no source. My new blog shows what the studies actually found, and how to choose 👇
blog.trainindata.com
Precision-Recall Curves: A Complete Guide With Python Examples
Learn what Precision-Recall curves are, how they compare to ROC curves, and how to plot, interpret and evaluate them in Python with imbalanced data examples.
000
Soledad Galli, PhD @solegalli.bsky.social · 05/10/2026
A solid review of multi-class metrics: precision, recall, F1, Matthews Correlation Coefficient. My issue with it: it never asks whether we should be optimising for these at all. Cross-entropy is the better target.
arxiv.org
Metrics for Multi-Class Classification: an Overview
Classification tasks in machine learning involving more than two classes are known by the name of "multi-class classification". Performance indicators are very useful when the aim is to evaluate and compare different classification models or machine learning techniques. Many metrics come in handy to test the ability of a multi-class classifier. Those metrics turn out to be useful at different stage of the development process, e.g. comparing the performance of two different models or analysing the behaviour of the same model by tuning different parameters. In this white paper we review a list of the most promising multi-class metrics, we highlight their advantages and disadvantages and show their possible usages during the development of a classification model.
000
Soledad Galli, PhD @solegalli.bsky.social · 05/10/2026
My Machine Learning Interpretability course just got a refresh! 🎉 Updated notebooks, practical alternatives to outdated libraries, and fixes for compatibility issues. Come explore what drives your models’ predictions! www.trainindata.com/p/machine-learn…
000
Soledad Galli, PhD @solegalli.bsky.social · 02/10/2026
You can browse all our machine learning courses on ClassCentral 👇
classcentral.com
Train in Data Courses [2026] | Learn Online | Class Central
Class Central ratings are the most trusted measurement of quality for online courses. Now you can easily decide which Train in Data course to take next.
000
Soledad Galli, PhD @solegalli.bsky.social · 02/10/2026
Imbalanced Data: Myths, Mistakes and Modern Solutions is available now 👇 www.trainindata.com/p/imbalanced-da…
Book cover of Imbalanced Data: Myths, Mistakes and Modern Solutions
001
Soledad Galli, PhD @solegalli.bsky.social · 02/10/2026
Optuna does the tuning while you do the thinking. My Udemy course shows you how to set it up and trust the results. Short courses, one skill each, all in one place 👇 linktr.ee/solegalli
Course cover for Automate Hyperparameter Tuning with Optuna
000
Soledad Galli, PhD @solegalli.bsky.social · 02/10/2026
AI-generated pull requests won't land you that data science job. That's what I'll discuss in my next newsletter.  Subscribe to stay in the loop👇 tech.trainindata.com
000
Soledad Galli, PhD @solegalli.bsky.social · 01/10/2026
Python code for every method discussed, so you can test the claims yourself 👇 www.trainindata.com/p/imbalanced-da…
Book cover of Imbalanced Data: Myths, Mistakes and Modern Solutions
000
Soledad Galli, PhD @solegalli.bsky.social · 01/10/2026
Random search tries. Bayesian optimisation learns. If you want tuning that gets smarter with every trial, this Udemy course is for you. One skill at a time, all courses here 👇 linktr.ee/solegalli
Course cover for Master Hyperparameter Tuning: Bayesian Optimization and TPE
000
Soledad Galli, PhD @solegalli.bsky.social · 01/10/2026
This is all SMOTE does. Once you see the mechanics, the claims made about it become much easier to evaluate 👇 www.trainindata.com/p/imbalanced-da…
Illustration of the SMOTE algorithm
000
Soledad Galli, PhD @solegalli.bsky.social · 30/09/2026
If you understand this diagram, you understand why resampling rarely improves a model. Cost, threshold and class weights are the same lever 👇 www.trainindata.com/p/imbalanced-da…
Diagram showing cost, threshold, resampling and class weights as one cycle
000
Soledad Galli, PhD @solegalli.bsky.social · 30/09/2026
Out now. The imbalanced data book I wanted when I was building credit risk and fraud models 👇 www.trainindata.com/p/imbalanced-da…
Book cover of Imbalanced Data: Myths, Mistakes and Modern Solutions
000
Soledad Galli, PhD @solegalli.bsky.social · 30/09/2026
Tuning big models on full data is expensive. Multifidelity methods let you test on less and still find the winner. That is the whole point of this Udemy course. More focused courses in the series 👇 linktr.ee/solegalli
Course cover for Accelerate Hyperparameter Tuning with Multifidelity Models
000
Soledad Galli, PhD @solegalli.bsky.social · 30/09/2026
There's no universally correct metric, but there is a correct process for picking one. This decision tree from Chapter 2 walks you through it 👇 www.trainindata.com/p/imbalanced-da…
Decision tree for choosing an evaluation metric
001
Soledad Galli, PhD @solegalli.bsky.social · 29/09/2026
0.51 and 0.99 both become a 1. That's what a threshold does to your predictions, and why the distinction between predicting and deciding matters so much 👇 www.trainindata.com/p/imbalanced-da…
Diagram showing a continuous prediction converted into a binary decision
000
Soledad Galli, PhD @solegalli.bsky.social · 29/09/2026
My new book won't tell you to balance your dataset. It'll tell you what to do instead 👇 www.trainindata.com/p/imbalanced-da…
Book cover of Imbalanced Data: Myths, Mistakes and Modern Solutions
000
Soledad Galli, PhD @solegalli.bsky.social · 29/09/2026
Still tuning by hand and hoping? Grid and random search are the foundation, and my Udemy course covers them properly. One skill, one course. See the whole series 👇 linktr.ee/solegalli
Course cover for Master Hyperparameter Tuning with Grid and Random Search
000
Soledad Galli, PhD @solegalli.bsky.social · 29/09/2026
Every evaluation metric belongs to a family, and each family answers a different question. Here's the map I use in Chapter 2 👇 www.trainindata.com/p/imbalanced-da…
Diagram of model evaluation metric families
000
Soledad Galli, PhD @solegalli.bsky.social · 28/09/2026
Optimising for the wrong metric doesn't just misrank your models. It changes the weights they learn 👇
trainindata.com
Imbalanced Data - Myths, Mistakes and Modern Solu
Master imbalanced data with practical, modern machine learning techniques. Learn why class weights and resampling don’t improve performance, and how threshold tuning leads to better cost-sensitive decisions.
000
Soledad Galli, PhD @solegalli.bsky.social · 28/09/2026
Metrics, calibration, cost sensitive learning, undersampling, oversampling, and AI. Seven chapters on imbalanced data 👇 www.trainindata.com/p/imbalanced-da…
Book cover of Imbalanced Data: Myths, Mistakes and Modern Solutions
000
Soledad Galli, PhD @solegalli.bsky.social · 28/09/2026
Your model made a prediction. Can you explain it to a stakeholder? My SHAP and Shapley values masterclass on Udemy walks you through it, one concept at a time. Part of my new focused course series 👇 linktr.ee/solegalli
Course cover for The Complete SHAP and Shapley Values Masterclass
010
Soledad Galli, PhD @solegalli.bsky.social · 28/09/2026
Before reaching for cross validation, look at your learning curve. If validation scores barely move across fold sizes, a simple 3 way split is enough 👇 www.trainindata.com/p/imbalanced-da…
Learning curve comparing train and validation ROC AUC across training set sizes
000
Soledad Galli, PhD @solegalli.bsky.social · 25/09/2026
Accuracy hides imbalance. Balanced accuracy averages recall. F1 ignores a quadrant. MCC covers all four. Each metric has a blind spot 👇
trainindata.com
Imbalanced Data - Myths, Mistakes and Modern Solu
Master imbalanced data with practical, modern machine learning techniques. Learn why class weights and resampling don’t improve performance, and how threshold tuning leads to better cost-sensitive decisions.
000
Soledad Galli, PhD @solegalli.bsky.social · 25/09/2026
I know how many of you learn on Udemy, so I built a new series for you. One skill per course, no filler. Friday's pick: automating hyperparameter tuning with Optuna. Start here 👇 linktr.ee/solegalli
Course cover for Automate Hyperparameter Tuning with Optuna
000
Soledad Galli, PhD @solegalli.bsky.social · 25/09/2026
My next newsletter "How to Choose the Right Hyperparameter Search" is coming Monday.  Subscribe to get it and stay in the loop on everything I'm creating. tech.trainindata.com
000
Soledad Galli, PhD @solegalli.bsky.social · 25/09/2026
SMOTE in one picture. Find the nearest neighbours, pick one at random, drop a synthetic point in between. Whether that helps is a separate question, and Chapter 6 answers it 👇 www.trainindata.com/p/imbalanced-da…
Illustration of the SMOTE algorithm placing a synthetic point between nearest neighbours
010
Soledad Galli, PhD @solegalli.bsky.social · 24/09/2026
Before choosing a model, ask what you need it to tell you. A ranking? A calibrated probability? A label? The answer shapes everything downstream 👇
trainindata.com
Imbalanced Data - Myths, Mistakes and Modern Solu
Master imbalanced data with practical, modern machine learning techniques. Learn why class weights and resampling don’t improve performance, and how threshold tuning leads to better cost-sensitive decisions.
001
Soledad Galli, PhD @solegalli.bsky.social · 24/09/2026
Everything I know about imbalanced datasets, tested and written down 👇 www.trainindata.com/p/imbalanced-da…
Book cover of Imbalanced Data: Myths, Mistakes and Modern Solutions
000
Soledad Galli, PhD @solegalli.bsky.social · 24/09/2026
Many of you use Udemy and love it. Good news: I am back there with focused courses, one skill each. Up today: Bayesian optimisation and TPE, for tuning that learns from every trial instead of guessing. See the full list 👇 linktr.ee/solegalli
Course cover for Master Hyperparameter Tuning: Bayesian Optimization and TPE
000