Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Interpreting Tabular Models

Two Random Forest case studies on how model explanations change with their scope and feature representation.

This repository explores model interpretation through two tabular prediction problems: hospital readmission and New York City taxi fares. The datasets are very different, but the question is the same: once a model makes a prediction, what can its explanation actually tell us?

Case study Prediction task Main focus
Hospital readmission Binary classification Global behavior and one local explanation
NYC taxi fares Regression Feature representation and permutation importance

Hospital readmission

The first study trains a classifier to predict whether a hospital encounter will be followed by readmission. I begin with validation performance, then use permutation importance and partial dependence to inspect the model globally. SHAP is used to examine how individual features contribute to one specific prediction.

This progression matters because the methods answer different questions. A feature can influence the model overall without having the same role for every encounter.

New York City taxi fares

The second study focuses on how the inputs themselves shape an explanation. I compare the importance profile of a model using raw pickup and drop-off coordinates with another configuration that also includes absolute coordinate changes.

The experiment shows how engineered features can reorganize what a model relies on. It also highlights why correlated variables and importance scores need to be interpreted carefully: a different ranking does not automatically mean a better model or a causal pricing rule.

Big ideas

The two case studies are built around three ideas:

  • Evaluate before interpreting. An importance score is only useful when the model's predictive behavior is understood first.
  • Global and local explanations answer different questions. Permutation importance and partial dependence describe broader model behavior; SHAP explains one output in detail.
  • Representation changes the explanation. Adding engineered features gives the model a different way to use the same underlying information, which can reshape the importance ranking.

These methods describe the behavior of fitted models. They do not, by themselves, establish why a patient is readmitted or how a taxi fare is determined.

Repository

Stack

Python · pandas · NumPy · scikit-learn · ELI5 · SHAP · Matplotlib · Seaborn

Setup and run

The project uses Python 3.11 through Conda. The prepared datasets and saved notebook outputs are already included, so the analysis can be inspected before rerunning it.

From the repository root:

conda env create -f hw5-fr/environment.yml
conda activate hw4_DS
cd hw5-fr
jupyter lab hw5.ipynb

The Conda environment installs the data, modeling, notebook and interpretability libraries used by the analysis.

About

Two Random Forest case studies connecting validation performance, global feature reliance, local SHAP attribution and input representation.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages