Note
Go to the end to download the full example code.
SKD009 - Model worse than baseline#
This example walks through mitigations when check
SKD009 fires. The check trains a strong
tabular_pipeline() baseline (gradient boosting on vectorized
data) and flags estimators that are significantly worse on default metrics.
Mitigations from the user guide, in the order we try them here:
revisit feature engineering and preprocessing,
check whether the model family is appropriate,
switch to a stronger default such as HistGradientBoostingRegressor,
tune the model (here: moderated HGB capacity plus a log target).
We use the medical charge dataset with provider IDs and leakage columns removed. We will see how applying these recommendations leads to a model that improves on the baseline.
Load the medical charge dataset#
skrub.datasets.fetch_medical_charge() returns hospital billing records.
We drop provider identifiers and columns that leak the target, then subsample
2,000 rows for a challenging regression task.
from skrub.datasets import fetch_medical_charge
dataset = fetch_medical_charge()
X_full, y_full = dataset.X, dataset.y
id_cols = [
"Provider_Zip_Code",
"Provider_Id",
"Provider_Name",
"Provider_Street_Address",
]
leakage_cols = ["Average_Covered_Charges", "Average_Medicare_Payments"]
X = X_full.drop(columns=id_cols + leakage_cols).sample(2_000, random_state=42)
y = y_full.loc[X.index]
Downloading 'medical_charge' from https://github.com/skrub-data/skrub-data-files/raw/refs/heads/main/medical_charge.zip (attempt 1/3)
Inspect the features matrix with TableReport.
from skrub import TableReport
TableReport(X)
| DRG_Definition | Provider_City | Provider_State | Hospital_Referral_Region_(HRR)_Description | Total_Discharges | |
|---|---|---|---|---|---|
| 136,351 | 683 - RENAL FAILURE W CC | FRESNO | CA | CA - Fresno | 164 |
| 89,009 | 330 - MAJOR SMALL & LARGE BOWEL PROCEDURES W CC | BIDDEFORD | ME | ME - Portland | 17 |
| 123,343 | 563 - FX, SPRN, STRN & DISL EXCEPT FEMUR, HIP, PELVIS & THIGH W/O MCC | SAINT CHARLES | MO | MO - St. Louis | 13 |
| 24,542 | 191 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W CC | PARSONS | KS | KS - Wichita | 30 |
| 65,814 | 292 - HEART FAILURE & SHOCK W CC | WALLA WALLA | WA | WA - Spokane | 26 |
| 49,479 | 251 - PERC CARDIOVASC PROC W/O CORONARY ARTERY STENT W/O MCC | KALAMAZOO | MI | MI - Kalamazoo | 12 |
| 109,737 | 460 - SPINAL FUSION EXCEPT CERVICAL W/O MCC | LAS VEGAS | NV | NV - Las Vegas | 63 |
| 111,643 | 470 - MAJOR JOINT REPLACEMENT OR REATTACHMENT OF LOWER EXTREMITY W/O MCC | FORT COLLINS | CO | CO - Fort Collins | 667 |
| 86,080 | 315 - OTHER CIRCULATORY SYSTEM DIAGNOSES W CC | FORT COLLINS | CO | CO - Fort Collins | 12 |
| 119,396 | 491 - BACK & NECK PROC EXC SPINAL FUSION W/O CC/MCC | MIDLAND | MI | MI - Saginaw | 94 |
DRG_Definition
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
100 (5.0%)
This column has a high cardinality (> 40).
Most frequent values
292 - HEART FAILURE & SHOCK W CC
194 - SIMPLE PNEUMONIA & PLEURISY W CC
291 - HEART FAILURE & SHOCK W MCC
603 - CELLULITIS W/O MCC
192 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W/O CC/MCC
690 - KIDNEY & URINARY TRACT INFECTIONS W/O MCC
872 - SEPTICEMIA OR SEVERE SEPSIS W/O MV 96+ HOURS W/O MCC
481 - HIP & FEMUR PROCEDURES EXCEPT MAJOR JOINT W CC
190 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W MCC
List:293 - HEART FAILURE & SHOCK W/O CC/MCC
['292 - HEART FAILURE & SHOCK W CC', '194 - SIMPLE PNEUMONIA & PLEURISY W CC', '291 - HEART FAILURE & SHOCK W MCC', '603 - CELLULITIS W/O MCC', '192 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W/O CC/MCC', '690 - KIDNEY & URINARY TRACT INFECTIONS W/O MCC', '872 - SEPTICEMIA OR SEVERE SEPSIS W/O MV 96+ HOURS W/O MCC', '481 - HIP & FEMUR PROCEDURES EXCEPT MAJOR JOINT W CC', '190 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W MCC', '293 - HEART FAILURE & SHOCK W/O CC/MCC']
Provider_City
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
945 (47.2%)
This column has a high cardinality (> 40).
Most frequent values
LOS ANGELES
NEW YORK
CHICAGO
SPRINGFIELD
BROOKLYN
LAS VEGAS
HOUSTON
COLUMBUS
CINCINNATI
List:RICHMOND
['LOS ANGELES', 'NEW YORK', 'CHICAGO', 'SPRINGFIELD', 'BROOKLYN', 'LAS VEGAS', 'HOUSTON', 'COLUMBUS', 'CINCINNATI', 'RICHMOND']
Provider_State
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
51 (2.5%)
This column has a high cardinality (> 40).
Most frequent values
CA
TX
FL
NY
IL
PA
OH
MI
NJ
List:VA
['CA', 'TX', 'FL', 'NY', 'IL', 'PA', 'OH', 'MI', 'NJ', 'VA']
Hospital_Referral_Region_(HRR)_Description
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
287 (14.3%)
This column has a high cardinality (> 40).
Most frequent values
CA - Los Angeles
MA - Boston
TX - Houston
NY - Manhattan
FL - Fort Lauderdale
PA - Philadelphia
FL - Orlando
IN - Indianapolis
MO - St. Louis
List:NY - East Long Island
['CA - Los Angeles', 'MA - Boston', 'TX - Houston', 'NY - Manhattan', 'FL - Fort Lauderdale', 'PA - Philadelphia', 'FL - Orlando', 'IN - Indianapolis', 'MO - St. Louis', 'NY - East Long Island']
Total_Discharges
Int64DType- Null values
- 0 (0.0%)
- Unique values
-
183 (9.2%)
This column has a high cardinality (> 40).
- Mean ± Std
- 43.7 ± 53.2
- Median ± IQR
- 27 ± 33
- Min | Max
- 11 | 778
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
|
Column
|
Column name
|
dtype
|
Is sorted
|
Null values
|
Unique values
|
Mean
|
Std
|
Min
|
Median
|
Max
|
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | DRG_Definition | StringDtype | False | 0 (0.0%) | 100 (5.0%) | |||||
| 1 | Provider_City | StringDtype | False | 0 (0.0%) | 945 (47.2%) | |||||
| 2 | Provider_State | StringDtype | False | 0 (0.0%) | 51 (2.5%) | |||||
| 3 | Hospital_Referral_Region_(HRR)_Description | StringDtype | False | 0 (0.0%) | 287 (14.3%) | |||||
| 4 | Total_Discharges | Int64DType | False | 0 (0.0%) | 183 (9.2%) | 43.7 | 53.2 | 11 | 27 | 778 |
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
DRG_Definition
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
100 (5.0%)
This column has a high cardinality (> 40).
Most frequent values
292 - HEART FAILURE & SHOCK W CC
194 - SIMPLE PNEUMONIA & PLEURISY W CC
291 - HEART FAILURE & SHOCK W MCC
603 - CELLULITIS W/O MCC
192 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W/O CC/MCC
690 - KIDNEY & URINARY TRACT INFECTIONS W/O MCC
872 - SEPTICEMIA OR SEVERE SEPSIS W/O MV 96+ HOURS W/O MCC
481 - HIP & FEMUR PROCEDURES EXCEPT MAJOR JOINT W CC
190 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W MCC
List:293 - HEART FAILURE & SHOCK W/O CC/MCC
['292 - HEART FAILURE & SHOCK W CC', '194 - SIMPLE PNEUMONIA & PLEURISY W CC', '291 - HEART FAILURE & SHOCK W MCC', '603 - CELLULITIS W/O MCC', '192 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W/O CC/MCC', '690 - KIDNEY & URINARY TRACT INFECTIONS W/O MCC', '872 - SEPTICEMIA OR SEVERE SEPSIS W/O MV 96+ HOURS W/O MCC', '481 - HIP & FEMUR PROCEDURES EXCEPT MAJOR JOINT W CC', '190 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W MCC', '293 - HEART FAILURE & SHOCK W/O CC/MCC']
Provider_City
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
945 (47.2%)
This column has a high cardinality (> 40).
Most frequent values
LOS ANGELES
NEW YORK
CHICAGO
SPRINGFIELD
BROOKLYN
LAS VEGAS
HOUSTON
COLUMBUS
CINCINNATI
List:RICHMOND
['LOS ANGELES', 'NEW YORK', 'CHICAGO', 'SPRINGFIELD', 'BROOKLYN', 'LAS VEGAS', 'HOUSTON', 'COLUMBUS', 'CINCINNATI', 'RICHMOND']
Provider_State
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
51 (2.5%)
This column has a high cardinality (> 40).
Most frequent values
CA
TX
FL
NY
IL
PA
OH
MI
NJ
List:VA
['CA', 'TX', 'FL', 'NY', 'IL', 'PA', 'OH', 'MI', 'NJ', 'VA']
Hospital_Referral_Region_(HRR)_Description
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
287 (14.3%)
This column has a high cardinality (> 40).
Most frequent values
CA - Los Angeles
MA - Boston
TX - Houston
NY - Manhattan
FL - Fort Lauderdale
PA - Philadelphia
FL - Orlando
IN - Indianapolis
MO - St. Louis
List:NY - East Long Island
['CA - Los Angeles', 'MA - Boston', 'TX - Houston', 'NY - Manhattan', 'FL - Fort Lauderdale', 'PA - Philadelphia', 'FL - Orlando', 'IN - Indianapolis', 'MO - St. Louis', 'NY - East Long Island']
Total_Discharges
Int64DType- Null values
- 0 (0.0%)
- Unique values
-
183 (9.2%)
This column has a high cardinality (> 40).
- Mean ± Std
- 43.7 ± 53.2
- Median ± IQR
- 27 ± 33
- Min | Max
- 11 | 778
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
| Column 1 | Column 2 | Cramér's V | Pearson's Correlation |
|---|---|---|---|
| Provider_State | Hospital_Referral_Region_(HRR)_Description | 0.426 | |
| Provider_City | Hospital_Referral_Region_(HRR)_Description | 0.418 | |
| Provider_City | Provider_State | 0.262 | |
| DRG_Definition | Total_Discharges | 0.0915 | |
| Provider_City | Total_Discharges | 0.0905 | |
| Provider_State | Total_Discharges | 0.0800 | |
| DRG_Definition | Provider_State | 0.0723 | |
| DRG_Definition | Hospital_Referral_Region_(HRR)_Description | 0.0688 | |
| Hospital_Referral_Region_(HRR)_Description | Total_Discharges | 0.0674 | |
| DRG_Definition | Provider_City | 0.0654 |
Please enable javascript
The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").
The target is continuous total payment.
| Average_Total_Payments | |
|---|---|
| 136,351 | 7.73e+03 |
| 89,009 | 1.60e+04 |
| 123,343 | 4.46e+03 |
| 24,542 | 5.73e+03 |
| 65,814 | 6.02e+03 |
| 49,479 | 1.44e+04 |
| 109,737 | 2.59e+04 |
| 111,643 | 1.47e+04 |
| 86,080 | 6.70e+03 |
| 119,396 | 6.64e+03 |
Average_Total_Payments
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
1,995 (99.8%)
This column has a high cardinality (> 40).
- Mean ± Std
- 9.39e+03 ± 6.99e+03
- Median ± IQR
- 7.00e+03 ± 5.70e+03
- Min | Max
- 2.72e+03 | 7.32e+04
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
|
Column
|
Column name
|
dtype
|
Is sorted
|
Null values
|
Unique values
|
Mean
|
Std
|
Min
|
Median
|
Max
|
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Average_Total_Payments | Float64DType | False | 0 (0.0%) | 1995 (99.8%) | 9.39e+03 | 6.99e+03 | 2.72e+03 | 7.00e+03 | 7.32e+04 |
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
Average_Total_Payments
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
1,995 (99.8%)
This column has a high cardinality (> 40).
- Mean ± Std
- 9.39e+03 ± 6.99e+03
- Median ± IQR
- 7.00e+03 ± 5.70e+03
- Min | Max
- 2.72e+03 | 7.32e+04
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
Please enable javascript
The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").
from skore import TrainTestSplit
splitter = TrainTestSplit(random_state=42, test_size=0.2)
Trigger SKD009 with a linear pipeline#
Start with tabular_pipeline() around
Ridge so that encoding and imputation are
already in place before fitting the linear model.
from sklearn.linear_model import Ridge
from skore import evaluate
from skrub import tabular_pipeline
report_ridge = evaluate(tabular_pipeline(Ridge()), X=X, y=y, splitter=splitter)
report_ridge
| Metric | Ridge |
|---|---|
| R² | 0.383493 |
| RMSE | 4888.241035 |
| MAE | 3391.632636 |
| MAPE | 0.416913 |
| Fit time (s) | 0.458600 |
| Predict time (s) | 0.243509 |
No issues were detected in your report.
- [SKD003] Inconsistent performance across splits. Not applicable to estimator reports.
- [SKD004] High class imbalance. ML task is not binary classification. Got regression.
- [SKD005] Underrepresented classes. ML task is not multiclass classification. Got regression.
- [SKD007] MDI biased for high-cardinality features. Estimator is not a tree-based model: it does not have a `feature_importances_` attribute.
- [SKD013] Train-test overlap in time series. No datetime column found.
- [SKD014] Hyperparameters at search edge. Estimator is not a BaseSearchCV instance. Got Pipeline.
- [SKD015] Hyperparameters worth tuning. Estimator is not a BaseSearchCV instance. Got Pipeline.
No checks were muted.
Fast mode is on: expensive checks are skipped unless already cached.
Mute a check by passing its code to ignore, e.g. .checks.summarize(ignore=['SKD001']).
Pipeline(steps=[('tablevectorizer',
TableVectorizer(datetime=DatetimeEncoder(periodic_encoding='spline'))),
('simpleimputer', SimpleImputer(add_indicator=True)),
('squashingscaler', SquashingScaler(max_absolute_value=5)),
('ridge', Ridge())])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
Fitted attributes
Parameters
Fitted attributes
['Total_Discharges']
Parameters
Parameters
Parameters
['DRG_Definition', 'Provider_City', 'Provider_State', 'Hospital_Referral_Region_(HRR)_Description']
Parameters
100 of 121 features
| DRG_Definition_00 |
| DRG_Definition_01 |
| DRG_Definition_02 |
| DRG_Definition_03 |
| DRG_Definition_04 |
| DRG_Definition_05 |
| DRG_Definition_06 |
| DRG_Definition_07 |
| DRG_Definition_08 |
| DRG_Definition_09 |
| DRG_Definition_10 |
| DRG_Definition_11 |
| DRG_Definition_12 |
| DRG_Definition_13 |
| DRG_Definition_14 |
| DRG_Definition_15 |
| DRG_Definition_16 |
| DRG_Definition_17 |
| DRG_Definition_18 |
| DRG_Definition_19 |
| DRG_Definition_20 |
| DRG_Definition_21 |
| DRG_Definition_22 |
| DRG_Definition_23 |
| DRG_Definition_24 |
| DRG_Definition_25 |
| DRG_Definition_26 |
| DRG_Definition_27 |
| DRG_Definition_28 |
| DRG_Definition_29 |
| Provider_City_00 |
| Provider_City_01 |
| Provider_City_02 |
| Provider_City_03 |
| Provider_City_04 |
| Provider_City_05 |
| Provider_City_06 |
| Provider_City_07 |
| Provider_City_08 |
| Provider_City_09 |
| Provider_City_10 |
| Provider_City_11 |
| Provider_City_12 |
| Provider_City_13 |
| Provider_City_14 |
| Provider_City_15 |
| Provider_City_16 |
| Provider_City_17 |
| Provider_City_18 |
| Provider_City_19 |
| Provider_City_20 |
| Provider_City_21 |
| Provider_City_22 |
| Provider_City_23 |
| Provider_City_24 |
| Provider_City_25 |
| Provider_City_26 |
| Provider_City_27 |
| Provider_City_28 |
| Provider_City_29 |
| Provider_State_00 |
| Provider_State_01 |
| Provider_State_02 |
| Provider_State_03 |
| Provider_State_04 |
| Provider_State_05 |
| Provider_State_06 |
| Provider_State_07 |
| Provider_State_08 |
| Provider_State_09 |
| Provider_State_10 |
| Provider_State_11 |
| Provider_State_12 |
| Provider_State_13 |
| Provider_State_14 |
| Provider_State_15 |
| Provider_State_16 |
| Provider_State_17 |
| Provider_State_18 |
| Provider_State_19 |
| Provider_State_20 |
| Provider_State_21 |
| Provider_State_22 |
| Provider_State_23 |
| Provider_State_24 |
| Provider_State_25 |
| Provider_State_26 |
| Provider_State_27 |
| Provider_State_28 |
| Provider_State_29 |
| Hospital_Referral_Region_(HRR)_Description_00 |
| Hospital_Referral_Region_(HRR)_Description_01 |
| Hospital_Referral_Region_(HRR)_Description_02 |
| Hospital_Referral_Region_(HRR)_Description_03 |
| Hospital_Referral_Region_(HRR)_Description_04 |
| Hospital_Referral_Region_(HRR)_Description_05 |
| Hospital_Referral_Region_(HRR)_Description_06 |
| Hospital_Referral_Region_(HRR)_Description_07 |
| Hospital_Referral_Region_(HRR)_Description_08 |
| Hospital_Referral_Region_(HRR)_Description_09 |
Parameters
Fitted attributes
100 of 121 features
| DRG_Definition_00 |
| DRG_Definition_01 |
| DRG_Definition_02 |
| DRG_Definition_03 |
| DRG_Definition_04 |
| DRG_Definition_05 |
| DRG_Definition_06 |
| DRG_Definition_07 |
| DRG_Definition_08 |
| DRG_Definition_09 |
| DRG_Definition_10 |
| DRG_Definition_11 |
| DRG_Definition_12 |
| DRG_Definition_13 |
| DRG_Definition_14 |
| DRG_Definition_15 |
| DRG_Definition_16 |
| DRG_Definition_17 |
| DRG_Definition_18 |
| DRG_Definition_19 |
| DRG_Definition_20 |
| DRG_Definition_21 |
| DRG_Definition_22 |
| DRG_Definition_23 |
| DRG_Definition_24 |
| DRG_Definition_25 |
| DRG_Definition_26 |
| DRG_Definition_27 |
| DRG_Definition_28 |
| DRG_Definition_29 |
| Provider_City_00 |
| Provider_City_01 |
| Provider_City_02 |
| Provider_City_03 |
| Provider_City_04 |
| Provider_City_05 |
| Provider_City_06 |
| Provider_City_07 |
| Provider_City_08 |
| Provider_City_09 |
| Provider_City_10 |
| Provider_City_11 |
| Provider_City_12 |
| Provider_City_13 |
| Provider_City_14 |
| Provider_City_15 |
| Provider_City_16 |
| Provider_City_17 |
| Provider_City_18 |
| Provider_City_19 |
| Provider_City_20 |
| Provider_City_21 |
| Provider_City_22 |
| Provider_City_23 |
| Provider_City_24 |
| Provider_City_25 |
| Provider_City_26 |
| Provider_City_27 |
| Provider_City_28 |
| Provider_City_29 |
| Provider_State_00 |
| Provider_State_01 |
| Provider_State_02 |
| Provider_State_03 |
| Provider_State_04 |
| Provider_State_05 |
| Provider_State_06 |
| Provider_State_07 |
| Provider_State_08 |
| Provider_State_09 |
| Provider_State_10 |
| Provider_State_11 |
| Provider_State_12 |
| Provider_State_13 |
| Provider_State_14 |
| Provider_State_15 |
| Provider_State_16 |
| Provider_State_17 |
| Provider_State_18 |
| Provider_State_19 |
| Provider_State_20 |
| Provider_State_21 |
| Provider_State_22 |
| Provider_State_23 |
| Provider_State_24 |
| Provider_State_25 |
| Provider_State_26 |
| Provider_State_27 |
| Provider_State_28 |
| Provider_State_29 |
| Hospital_Referral_Region_(HRR)_Description_00 |
| Hospital_Referral_Region_(HRR)_Description_01 |
| Hospital_Referral_Region_(HRR)_Description_02 |
| Hospital_Referral_Region_(HRR)_Description_03 |
| Hospital_Referral_Region_(HRR)_Description_04 |
| Hospital_Referral_Region_(HRR)_Description_05 |
| Hospital_Referral_Region_(HRR)_Description_06 |
| Hospital_Referral_Region_(HRR)_Description_07 |
| Hospital_Referral_Region_(HRR)_Description_08 |
| Hospital_Referral_Region_(HRR)_Description_09 |
Parameters
Fitted attributes
| Name | Type | Value |
|---|---|---|
| minmax_cols_ | ndarray[bool](121,) | [False,False,False,...,False,False,False] |
| minmax_scaler_ | NoneType | None |
| n_features_in_ | int | 121 |
| robust_cols_ | ndarray[bool](121,) | [ True, True, True,..., True, True, True] |
| robust_scaler_ | RobustScaler | RobustScaler() |
| zero_cols_ | ndarray[bool](121,) | [False,False,False,...,False,False,False] |
100 of 121 features
| x0 |
| x1 |
| x2 |
| x3 |
| x4 |
| x5 |
| x6 |
| x7 |
| x8 |
| x9 |
| x10 |
| x11 |
| x12 |
| x13 |
| x14 |
| x15 |
| x16 |
| x17 |
| x18 |
| x19 |
| x20 |
| x21 |
| x22 |
| x23 |
| x24 |
| x25 |
| x26 |
| x27 |
| x28 |
| x29 |
| x30 |
| x31 |
| x32 |
| x33 |
| x34 |
| x35 |
| x36 |
| x37 |
| x38 |
| x39 |
| x40 |
| x41 |
| x42 |
| x43 |
| x44 |
| x45 |
| x46 |
| x47 |
| x48 |
| x49 |
| x50 |
| x51 |
| x52 |
| x53 |
| x54 |
| x55 |
| x56 |
| x57 |
| x58 |
| x59 |
| x60 |
| x61 |
| x62 |
| x63 |
| x64 |
| x65 |
| x66 |
| x67 |
| x68 |
| x69 |
| x70 |
| x71 |
| x72 |
| x73 |
| x74 |
| x75 |
| x76 |
| x77 |
| x78 |
| x79 |
| x80 |
| x81 |
| x82 |
| x83 |
| x84 |
| x85 |
| x86 |
| x87 |
| x88 |
| x89 |
| x90 |
| x91 |
| x92 |
| x93 |
| x94 |
| x95 |
| x96 |
| x97 |
| x98 |
| x99 |
Parameters
Fitted attributes
| Name | Type | Value |
|---|---|---|
|
coef_
coef_: ndarray of shape (n_features,) or (n_targets, n_features) Weight vector(s). |
ndarray[float32](121,) | [-1935.55, 646.31, -424.45,..., -25.41, 152.56, -167.28] |
|
intercept_
intercept_: float or ndarray of shape (n_targets,) Independent term in decision function. Set to 0.0 if ``fit_intercept = False``. |
float32 | np.float32(10110.402) |
|
n_features_in_
n_features_in_: int Number of features seen during :term:`fit`. .. versionadded:: 0.24 |
int | 121 |
|
n_iter_
n_iter_: None or ndarray of shape (n_targets,) Actual number of iterations for each target. Available only for 'sag' and 'lsqr' solvers. Other solvers will return None. .. versionadded:: 0.17 |
NoneType | None |
|
solver_
solver_: str The solver that was used at fit time by the computational routines. .. versionadded:: 1.5 |
str | 'ch...ky' |
| DRG_Definition | Provider_City | Provider_State | Hospital_Referral_Region_(HRR)_Description | Total_Discharges | Average_Total_Payments | |
|---|---|---|---|---|---|---|
| 0 | 480 - HIP & FEMUR PROCEDURES EXCEPT MAJOR JOINT W MCC | NASHVILLE | TN | TN - Nashville | 13 | 2.52e+04 |
| 1 | 390 - G.I. OBSTRUCTION W/O CC/MCC | NASHVILLE | TN | TN - Nashville | 12 | 4.05e+03 |
| 2 | 683 - RENAL FAILURE W CC | SPARKS | NV | NV - Reno | 27 | 5.74e+03 |
| 3 | 491 - BACK & NECK PROC EXC SPINAL FUSION W/O CC/MCC | BRONX | NY | NY - Bronx | 11 | 1.20e+04 |
| 4 | 254 - OTHER VASCULAR PROCEDURES W/O CC/MCC | CONCORD | OH | OH - Cleveland | 17 | 8.50e+03 |
| 1,995 | 191 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W CC | MUNSTER | IN | IN - Munster | 153 | 5.83e+03 |
| 1,996 | 683 - RENAL FAILURE W CC | SAINT ALBANS | VT | VT - Burlington | 11 | 9.11e+03 |
| 1,997 | 039 - EXTRACRANIAL PROCEDURES W/O CC/MCC | SIOUX FALLS | SD | SD - Sioux Falls | 67 | 6.70e+03 |
| 1,998 | 069 - TRANSIENT ISCHEMIA | LITTLE ROCK | AR | AR - Little Rock | 85 | 4.29e+03 |
| 1,999 | 603 - CELLULITIS W/O MCC | SELLERSVILLE | PA | PA - Allentown | 50 | 4.96e+03 |
DRG_Definition
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
100 (5.0%)
This column has a high cardinality (> 40).
Provider_City
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
945 (47.2%)
This column has a high cardinality (> 40).
Provider_State
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
51 (2.5%)
This column has a high cardinality (> 40).
Hospital_Referral_Region_(HRR)_Description
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
287 (14.3%)
This column has a high cardinality (> 40).
Total_Discharges
Int64DType- Null values
- 0 (0.0%)
- Unique values
-
183 (9.2%)
This column has a high cardinality (> 40).
- Mean ± Std
- 43.7 ± 53.2
- Median ± IQR
- 27 ± 33
- Min | Max
- 11 | 778
Average_Total_Payments
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
1,995 (99.8%)
This column has a high cardinality (> 40).
- Mean ± Std
- 9.39e+03 ± 6.99e+03
- Median ± IQR
- 7.00e+03 ± 5.70e+03
- Min | Max
- 2.72e+03 | 7.32e+04
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
|
Column
|
Column name
|
dtype
|
Is sorted
|
Null values
|
Unique values
|
Mean
|
Std
|
Min
|
Median
|
Max
|
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | DRG_Definition | StringDtype | False | 0 (0.0%) | 100 (5.0%) | |||||
| 1 | Provider_City | StringDtype | False | 0 (0.0%) | 945 (47.2%) | |||||
| 2 | Provider_State | StringDtype | False | 0 (0.0%) | 51 (2.5%) | |||||
| 3 | Hospital_Referral_Region_(HRR)_Description | StringDtype | False | 0 (0.0%) | 287 (14.3%) | |||||
| 4 | Total_Discharges | Int64DType | False | 0 (0.0%) | 183 (9.2%) | 43.7 | 53.2 | 11 | 27 | 778 |
| 5 | Average_Total_Payments | Float64DType | False | 0 (0.0%) | 1995 (99.8%) | 9.39e+03 | 6.99e+03 | 2.72e+03 | 7.00e+03 | 7.32e+04 |
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
Please enable javascript
The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").
Find SKD009 in the Tips tab below: the Ridge pipeline reports worse-than-baseline
performance on a majority of metrics.
report_ridge.checks.summarize()
No issues were detected in your report.
- [SKD006] Coefficient interpretation. Features are not on the same scale: coefficient magnitudes are not directly comparable as feature importance.
- [SKD009] Model performance vs. HistGradientBoosting baseline. Test scores are significantly worse than a HistGradientBoosting baseline for 4/4 default predictive metrics. Baseline performance on the test set: MAE=1.47e+03, MAPE=0.164, RMSE=2.2e+03, R²=0.876.
- [SKD016] Estimator not tuned. Estimator(s) left at default settings; consider tuning: ['alpha'] for Ridge.
- [SKD003] Inconsistent performance across splits. Not applicable to estimator reports.
- [SKD004] High class imbalance. ML task is not binary classification. Got regression.
- [SKD005] Underrepresented classes. ML task is not multiclass classification. Got regression.
- [SKD007] MDI biased for high-cardinality features. Estimator is not a tree-based model: it does not have a `feature_importances_` attribute.
- [SKD013] Train-test overlap in time series. No datetime column found.
- [SKD014] Hyperparameters at search edge. Estimator is not a BaseSearchCV instance. Got Pipeline.
- [SKD015] Hyperparameters worth tuning. Estimator is not a BaseSearchCV instance. Got Pipeline.
No checks were skipped in fast mode.
No checks were muted.
Mute a check by passing its code to ignore, e.g. .checks.summarize(ignore=['SKD001']).
Revisit feature engineering#
A linear model benefits from spelling out structure that trees would discover from the raw columns:
log1p(Total_Discharges)compresses a skewed volume signal (then drop the raw count to avoid collinearity),extract the numeric DRG code from labels like
"178 - ... W CC",flag severity markers in the text (
W MCC/W CC), which affect payment levels.
Keep everything inside a pipeline so the same transforms run at predict time
on new data. Since this transformation is stateless, i.e., no information
needs to be computed and stored during training, we can safely use a
FunctionTransformer.
We also break down the tabular_pipeline() into its components (vectorization of data,
missing value imputation and scaling) to keep the Pipeline flat.
import numpy as np
from sklearn.impute import SimpleImputer
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import FunctionTransformer
from skrub import SquashingScaler, TableVectorizer
def engineer_features(X):
"""Stateless feature engineering."""
drg = X["DRG_Definition"].str.upper()
return X.drop(columns=["Total_Discharges"]).assign(
log_Total_Discharges=np.log1p(X["Total_Discharges"]),
DRG_Code=(
X["DRG_Definition"].str.extract(r"^(\d+)", expand=False).astype(float)
),
has_MCC=drg.str.contains("W MCC", regex=False).astype(int),
has_CC=(
drg.str.contains("W CC", regex=False)
& ~drg.str.contains("W MCC", regex=False)
).astype(int),
)
ridge_with_fe = make_pipeline(
FunctionTransformer(engineer_features),
TableVectorizer(),
SimpleImputer(add_indicator=True),
SquashingScaler(max_absolute_value=5),
Ridge(),
)
report_ridge_fe = evaluate(ridge_with_fe, X=X, y=y, splitter=splitter)
report_ridge_fe
| Metric | Ridge |
|---|---|
| R² | 0.505097 |
| RMSE | 4379.691473 |
| MAE | 3026.040558 |
| MAPE | 0.383160 |
| Fit time (s) | 0.565683 |
| Predict time (s) | 0.119716 |
No issues were detected in your report.
- [SKD003] Inconsistent performance across splits. Not applicable to estimator reports.
- [SKD004] High class imbalance. ML task is not binary classification. Got regression.
- [SKD005] Underrepresented classes. ML task is not multiclass classification. Got regression.
- [SKD007] MDI biased for high-cardinality features. Estimator is not a tree-based model: it does not have a `feature_importances_` attribute.
- [SKD013] Train-test overlap in time series. No datetime column found.
- [SKD014] Hyperparameters at search edge. Estimator is not a BaseSearchCV instance. Got Pipeline.
- [SKD015] Hyperparameters worth tuning. Estimator is not a BaseSearchCV instance. Got Pipeline.
No checks were muted.
Fast mode is on: expensive checks are skipped unless already cached.
Mute a check by passing its code to ignore, e.g. .checks.summarize(ignore=['SKD001']).
Pipeline(steps=[('functiontransformer',
FunctionTransformer(func=<function engineer_features at 0x7f26d02c2770>)),
('tablevectorizer', TableVectorizer()),
('simpleimputer', SimpleImputer(add_indicator=True)),
('squashingscaler', SquashingScaler(max_absolute_value=5)),
('ridge', Ridge())])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
Fitted attributes
| Name | Type | Value |
|---|---|---|
|
feature_names_in_
feature_names_in_: ndarray of shape (`n_features_in_`,) Names of features seen during :term:`fit`. Only defined if the underlying estimator exposes such an attribute when fit. .. versionadded:: 1.0 |
ndarray[object](5,) | ['DRG_Definition','Provider_City','Provider_State', 'Hospital_Referral_Region_(HRR)_Description','Total_Discharges'] |
|
n_features_in_
n_features_in_: int Number of features seen during :term:`fit`. Only defined if the underlying first estimator in `steps` exposes such an attribute when fit. .. versionadded:: 0.24 |
int | 5 |
Parameters
Fitted attributes
| Name | Type | Value |
|---|---|---|
|
feature_names_in_
feature_names_in_: ndarray of shape (`n_features_in_`,) Names of features seen during :term:`fit`. Defined only when `X` has feature names that are all strings. .. versionadded:: 1.0 |
ndarray[object](5,) | ['DRG_Definition','Provider_City','Provider_State', 'Hospital_Referral_Region_(HRR)_Description','Total_Discharges'] |
|
n_features_in_
n_features_in_: int Number of features seen during :term:`fit`. .. versionadded:: 0.24 |
int | 5 |
Parameters
Fitted attributes
['log_Total_Discharges', 'DRG_Code', 'has_MCC', 'has_CC']
Parameters
Parameters
Parameters
['DRG_Definition', 'Provider_City', 'Provider_State', 'Hospital_Referral_Region_(HRR)_Description']
Parameters
100 of 124 features
| DRG_Definition_00 |
| DRG_Definition_01 |
| DRG_Definition_02 |
| DRG_Definition_03 |
| DRG_Definition_04 |
| DRG_Definition_05 |
| DRG_Definition_06 |
| DRG_Definition_07 |
| DRG_Definition_08 |
| DRG_Definition_09 |
| DRG_Definition_10 |
| DRG_Definition_11 |
| DRG_Definition_12 |
| DRG_Definition_13 |
| DRG_Definition_14 |
| DRG_Definition_15 |
| DRG_Definition_16 |
| DRG_Definition_17 |
| DRG_Definition_18 |
| DRG_Definition_19 |
| DRG_Definition_20 |
| DRG_Definition_21 |
| DRG_Definition_22 |
| DRG_Definition_23 |
| DRG_Definition_24 |
| DRG_Definition_25 |
| DRG_Definition_26 |
| DRG_Definition_27 |
| DRG_Definition_28 |
| DRG_Definition_29 |
| Provider_City_00 |
| Provider_City_01 |
| Provider_City_02 |
| Provider_City_03 |
| Provider_City_04 |
| Provider_City_05 |
| Provider_City_06 |
| Provider_City_07 |
| Provider_City_08 |
| Provider_City_09 |
| Provider_City_10 |
| Provider_City_11 |
| Provider_City_12 |
| Provider_City_13 |
| Provider_City_14 |
| Provider_City_15 |
| Provider_City_16 |
| Provider_City_17 |
| Provider_City_18 |
| Provider_City_19 |
| Provider_City_20 |
| Provider_City_21 |
| Provider_City_22 |
| Provider_City_23 |
| Provider_City_24 |
| Provider_City_25 |
| Provider_City_26 |
| Provider_City_27 |
| Provider_City_28 |
| Provider_City_29 |
| Provider_State_00 |
| Provider_State_01 |
| Provider_State_02 |
| Provider_State_03 |
| Provider_State_04 |
| Provider_State_05 |
| Provider_State_06 |
| Provider_State_07 |
| Provider_State_08 |
| Provider_State_09 |
| Provider_State_10 |
| Provider_State_11 |
| Provider_State_12 |
| Provider_State_13 |
| Provider_State_14 |
| Provider_State_15 |
| Provider_State_16 |
| Provider_State_17 |
| Provider_State_18 |
| Provider_State_19 |
| Provider_State_20 |
| Provider_State_21 |
| Provider_State_22 |
| Provider_State_23 |
| Provider_State_24 |
| Provider_State_25 |
| Provider_State_26 |
| Provider_State_27 |
| Provider_State_28 |
| Provider_State_29 |
| Hospital_Referral_Region_(HRR)_Description_00 |
| Hospital_Referral_Region_(HRR)_Description_01 |
| Hospital_Referral_Region_(HRR)_Description_02 |
| Hospital_Referral_Region_(HRR)_Description_03 |
| Hospital_Referral_Region_(HRR)_Description_04 |
| Hospital_Referral_Region_(HRR)_Description_05 |
| Hospital_Referral_Region_(HRR)_Description_06 |
| Hospital_Referral_Region_(HRR)_Description_07 |
| Hospital_Referral_Region_(HRR)_Description_08 |
| Hospital_Referral_Region_(HRR)_Description_09 |
Parameters
Fitted attributes
| Name | Type | Value |
|---|---|---|
|
feature_names_in_
feature_names_in_: ndarray of shape (`n_features_in_`,) Names of features seen during :term:`fit`. Defined only when `X` has feature names that are all strings. .. versionadded:: 1.0 |
ndarray[object](124,) | ['DRG_Definition_00','DRG_Definition_01','DRG_Definition_02',..., 'DRG_Code','has_MCC','has_CC'] |
|
indicator_
indicator_: :class:`~sklearn.impute.MissingIndicator` Indicator used to add binary indicators for missing values. `None` if `add_indicator=False`. |
MissingIndicator | MissingIndica..._on_new=False) |
|
n_features_in_
n_features_in_: int Number of features seen during :term:`fit`. .. versionadded:: 0.24 |
int | 124 |
|
statistics_
statistics_: array of shape (n_features,) The imputation fill value for each feature. Computing statistics can result in `np.nan` values. During :meth:`transform`, features corresponding to `np.nan` statistics will be discarded. |
ndarray[float64](124,) | [ 0.27, -0.06, -0.06,...,387.78, 0.23, 0.25] |
100 of 124 features
| DRG_Definition_00 |
| DRG_Definition_01 |
| DRG_Definition_02 |
| DRG_Definition_03 |
| DRG_Definition_04 |
| DRG_Definition_05 |
| DRG_Definition_06 |
| DRG_Definition_07 |
| DRG_Definition_08 |
| DRG_Definition_09 |
| DRG_Definition_10 |
| DRG_Definition_11 |
| DRG_Definition_12 |
| DRG_Definition_13 |
| DRG_Definition_14 |
| DRG_Definition_15 |
| DRG_Definition_16 |
| DRG_Definition_17 |
| DRG_Definition_18 |
| DRG_Definition_19 |
| DRG_Definition_20 |
| DRG_Definition_21 |
| DRG_Definition_22 |
| DRG_Definition_23 |
| DRG_Definition_24 |
| DRG_Definition_25 |
| DRG_Definition_26 |
| DRG_Definition_27 |
| DRG_Definition_28 |
| DRG_Definition_29 |
| Provider_City_00 |
| Provider_City_01 |
| Provider_City_02 |
| Provider_City_03 |
| Provider_City_04 |
| Provider_City_05 |
| Provider_City_06 |
| Provider_City_07 |
| Provider_City_08 |
| Provider_City_09 |
| Provider_City_10 |
| Provider_City_11 |
| Provider_City_12 |
| Provider_City_13 |
| Provider_City_14 |
| Provider_City_15 |
| Provider_City_16 |
| Provider_City_17 |
| Provider_City_18 |
| Provider_City_19 |
| Provider_City_20 |
| Provider_City_21 |
| Provider_City_22 |
| Provider_City_23 |
| Provider_City_24 |
| Provider_City_25 |
| Provider_City_26 |
| Provider_City_27 |
| Provider_City_28 |
| Provider_City_29 |
| Provider_State_00 |
| Provider_State_01 |
| Provider_State_02 |
| Provider_State_03 |
| Provider_State_04 |
| Provider_State_05 |
| Provider_State_06 |
| Provider_State_07 |
| Provider_State_08 |
| Provider_State_09 |
| Provider_State_10 |
| Provider_State_11 |
| Provider_State_12 |
| Provider_State_13 |
| Provider_State_14 |
| Provider_State_15 |
| Provider_State_16 |
| Provider_State_17 |
| Provider_State_18 |
| Provider_State_19 |
| Provider_State_20 |
| Provider_State_21 |
| Provider_State_22 |
| Provider_State_23 |
| Provider_State_24 |
| Provider_State_25 |
| Provider_State_26 |
| Provider_State_27 |
| Provider_State_28 |
| Provider_State_29 |
| Hospital_Referral_Region_(HRR)_Description_00 |
| Hospital_Referral_Region_(HRR)_Description_01 |
| Hospital_Referral_Region_(HRR)_Description_02 |
| Hospital_Referral_Region_(HRR)_Description_03 |
| Hospital_Referral_Region_(HRR)_Description_04 |
| Hospital_Referral_Region_(HRR)_Description_05 |
| Hospital_Referral_Region_(HRR)_Description_06 |
| Hospital_Referral_Region_(HRR)_Description_07 |
| Hospital_Referral_Region_(HRR)_Description_08 |
| Hospital_Referral_Region_(HRR)_Description_09 |
Parameters
Fitted attributes
| Name | Type | Value |
|---|---|---|
| minmax_cols_ | ndarray[bool](124,) | [False,False,False,...,False, True,False] |
| minmax_scaler_ | _MinMaxScaler | _MinMaxScaler() |
| n_features_in_ | int | 124 |
| robust_cols_ | ndarray[bool](124,) | [ True, True, True,..., True,False, True] |
| robust_scaler_ | RobustScaler | RobustScaler() |
| zero_cols_ | ndarray[bool](124,) | [False,False,False,...,False,False,False] |
100 of 124 features
| x0 |
| x1 |
| x2 |
| x3 |
| x4 |
| x5 |
| x6 |
| x7 |
| x8 |
| x9 |
| x10 |
| x11 |
| x12 |
| x13 |
| x14 |
| x15 |
| x16 |
| x17 |
| x18 |
| x19 |
| x20 |
| x21 |
| x22 |
| x23 |
| x24 |
| x25 |
| x26 |
| x27 |
| x28 |
| x29 |
| x30 |
| x31 |
| x32 |
| x33 |
| x34 |
| x35 |
| x36 |
| x37 |
| x38 |
| x39 |
| x40 |
| x41 |
| x42 |
| x43 |
| x44 |
| x45 |
| x46 |
| x47 |
| x48 |
| x49 |
| x50 |
| x51 |
| x52 |
| x53 |
| x54 |
| x55 |
| x56 |
| x57 |
| x58 |
| x59 |
| x60 |
| x61 |
| x62 |
| x63 |
| x64 |
| x65 |
| x66 |
| x67 |
| x68 |
| x69 |
| x70 |
| x71 |
| x72 |
| x73 |
| x74 |
| x75 |
| x76 |
| x77 |
| x78 |
| x79 |
| x80 |
| x81 |
| x82 |
| x83 |
| x84 |
| x85 |
| x86 |
| x87 |
| x88 |
| x89 |
| x90 |
| x91 |
| x92 |
| x93 |
| x94 |
| x95 |
| x96 |
| x97 |
| x98 |
| x99 |
Parameters
Fitted attributes
| Name | Type | Value |
|---|---|---|
|
coef_
coef_: ndarray of shape (n_features,) or (n_targets, n_features) Weight vector(s). |
ndarray[float32](124,) | [-1969.68, 532.69, -220.81,..., 2285.93, 2695.52, -79.31] |
|
intercept_
intercept_: float or ndarray of shape (n_targets,) Independent term in decision function. Set to 0.0 if ``fit_intercept = False``. |
float32 | np.float32(8224.655) |
|
n_features_in_
n_features_in_: int Number of features seen during :term:`fit`. .. versionadded:: 0.24 |
int | 124 |
|
n_iter_
n_iter_: None or ndarray of shape (n_targets,) Actual number of iterations for each target. Available only for 'sag' and 'lsqr' solvers. Other solvers will return None. .. versionadded:: 0.17 |
NoneType | None |
|
solver_
solver_: str The solver that was used at fit time by the computational routines. .. versionadded:: 1.5 |
str | 'ch...ky' |
| DRG_Definition | Provider_City | Provider_State | Hospital_Referral_Region_(HRR)_Description | Total_Discharges | Average_Total_Payments | |
|---|---|---|---|---|---|---|
| 0 | 480 - HIP & FEMUR PROCEDURES EXCEPT MAJOR JOINT W MCC | NASHVILLE | TN | TN - Nashville | 13 | 2.52e+04 |
| 1 | 390 - G.I. OBSTRUCTION W/O CC/MCC | NASHVILLE | TN | TN - Nashville | 12 | 4.05e+03 |
| 2 | 683 - RENAL FAILURE W CC | SPARKS | NV | NV - Reno | 27 | 5.74e+03 |
| 3 | 491 - BACK & NECK PROC EXC SPINAL FUSION W/O CC/MCC | BRONX | NY | NY - Bronx | 11 | 1.20e+04 |
| 4 | 254 - OTHER VASCULAR PROCEDURES W/O CC/MCC | CONCORD | OH | OH - Cleveland | 17 | 8.50e+03 |
| 1,995 | 191 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W CC | MUNSTER | IN | IN - Munster | 153 | 5.83e+03 |
| 1,996 | 683 - RENAL FAILURE W CC | SAINT ALBANS | VT | VT - Burlington | 11 | 9.11e+03 |
| 1,997 | 039 - EXTRACRANIAL PROCEDURES W/O CC/MCC | SIOUX FALLS | SD | SD - Sioux Falls | 67 | 6.70e+03 |
| 1,998 | 069 - TRANSIENT ISCHEMIA | LITTLE ROCK | AR | AR - Little Rock | 85 | 4.29e+03 |
| 1,999 | 603 - CELLULITIS W/O MCC | SELLERSVILLE | PA | PA - Allentown | 50 | 4.96e+03 |
DRG_Definition
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
100 (5.0%)
This column has a high cardinality (> 40).
Provider_City
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
945 (47.2%)
This column has a high cardinality (> 40).
Provider_State
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
51 (2.5%)
This column has a high cardinality (> 40).
Hospital_Referral_Region_(HRR)_Description
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
287 (14.3%)
This column has a high cardinality (> 40).
Total_Discharges
Int64DType- Null values
- 0 (0.0%)
- Unique values
-
183 (9.2%)
This column has a high cardinality (> 40).
- Mean ± Std
- 43.7 ± 53.2
- Median ± IQR
- 27 ± 33
- Min | Max
- 11 | 778
Average_Total_Payments
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
1,995 (99.8%)
This column has a high cardinality (> 40).
- Mean ± Std
- 9.39e+03 ± 6.99e+03
- Median ± IQR
- 7.00e+03 ± 5.70e+03
- Min | Max
- 2.72e+03 | 7.32e+04
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
|
Column
|
Column name
|
dtype
|
Is sorted
|
Null values
|
Unique values
|
Mean
|
Std
|
Min
|
Median
|
Max
|
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | DRG_Definition | StringDtype | False | 0 (0.0%) | 100 (5.0%) | |||||
| 1 | Provider_City | StringDtype | False | 0 (0.0%) | 945 (47.2%) | |||||
| 2 | Provider_State | StringDtype | False | 0 (0.0%) | 51 (2.5%) | |||||
| 3 | Hospital_Referral_Region_(HRR)_Description | StringDtype | False | 0 (0.0%) | 287 (14.3%) | |||||
| 4 | Total_Discharges | Int64DType | False | 0 (0.0%) | 183 (9.2%) | 43.7 | 53.2 | 11 | 27 | 778 |
| 5 | Average_Total_Payments | Float64DType | False | 0 (0.0%) | 1995 (99.8%) | 9.39e+03 | 6.99e+03 | 2.72e+03 | 7.00e+03 | 7.32e+04 |
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
Please enable javascript
The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").
With this feature engineering, we improved the test score.
However, SKD009 still flags the model because it cannot beat the HGB baseline on a majority of scores.
report_ridge_fe.checks.summarize()
No issues were detected in your report.
- [SKD006] Coefficient interpretation. Features are not on the same scale: coefficient magnitudes are not directly comparable as feature importance.
- [SKD009] Model performance vs. HistGradientBoosting baseline. Test scores are significantly worse than a HistGradientBoosting baseline for 4/4 default predictive metrics. Baseline performance on the test set: MAE=1.37e+03, MAPE=0.155, RMSE=2.05e+03, R²=0.892.
- [SKD012] Useless features. Feature(s) ['Total_Discharges'] have permutation importance overlapping with zero and could likely be dropped without degrading performance. Dropping redundant features may also improve model performance.
- [SKD016] Estimator not tuned. Estimator(s) left at default settings; consider tuning: ['alpha'] for Ridge.
- [SKD003] Inconsistent performance across splits. Not applicable to estimator reports.
- [SKD004] High class imbalance. ML task is not binary classification. Got regression.
- [SKD005] Underrepresented classes. ML task is not multiclass classification. Got regression.
- [SKD007] MDI biased for high-cardinality features. Estimator is not a tree-based model: it does not have a `feature_importances_` attribute.
- [SKD013] Train-test overlap in time series. No datetime column found.
- [SKD014] Hyperparameters at search edge. Estimator is not a BaseSearchCV instance. Got Pipeline.
- [SKD015] Hyperparameters worth tuning. Estimator is not a BaseSearchCV instance. Got Pipeline.
No checks were skipped in fast mode.
No checks were muted.
Mute a check by passing its code to ignore, e.g. .checks.summarize(ignore=['SKD001']).
Change model family: try a tree-based model#
If nonlinearity and interactions matter, trees should close much of the gap.
Let’s compare a RandomForestRegressor pipeline to the
engineered Ridge on the same split.
from sklearn.ensemble import RandomForestRegressor
from skore import compare
report_rf = evaluate(
tabular_pipeline(
RandomForestRegressor(
n_estimators=100,
min_samples_leaf=5,
random_state=42,
n_jobs=4,
)
),
X=X,
y=y,
splitter=splitter,
)
report_rf
| Metric | RandomForestRegressor |
|---|---|
| R² | 0.861134 |
| RMSE | 2319.966730 |
| MAE | 1598.113803 |
| MAPE | 0.177348 |
| Fit time (s) | 3.612842 |
| Predict time (s) | 0.139302 |
- [SKD001] Potential overfitting. Significant train/test gaps were found for 3/4 default predictive metrics.
- [SKD008] Highly correlated input features. 1 pair(s) of features have a Spearman correlation above 0.9. Highly correlated features can destabilize linear model coefficients and feature-importance estimates, and may cause collinearity-induced numerical issues.Dropping redundant features may also improve model performance.
- [SKD007] MDI biased for high-cardinality features. High-cardinality features detected: Provider_City_00, Provider_City_01, Provider_City_02 (and 27 more). Mean Decrease in Impurity (MDI) importance is biased toward such features. Consider using permutation importance for a more robust alternative.
- [SKD003] Inconsistent performance across splits. Not applicable to estimator reports.
- [SKD004] High class imbalance. ML task is not binary classification. Got regression.
- [SKD005] Underrepresented classes. ML task is not multiclass classification. Got regression.
- [SKD006] Coefficient interpretation. Estimator is not a linear model: it does not have a `coef_` attribute.
- [SKD013] Train-test overlap in time series. No datetime column found.
- [SKD014] Hyperparameters at search edge. Estimator is not a BaseSearchCV instance. Got Pipeline.
- [SKD015] Hyperparameters worth tuning. Estimator is not a BaseSearchCV instance. Got Pipeline.
No checks were muted.
Fast mode is on: expensive checks are skipped unless already cached.
Mute a check by passing its code to ignore, e.g. .checks.summarize(ignore=['SKD001']).
Pipeline(steps=[('tablevectorizer',
TableVectorizer(low_cardinality=OrdinalEncoder(handle_unknown='use_encoded_value',
unknown_value=-1))),
('randomforestregressor',
RandomForestRegressor(min_samples_leaf=5, n_jobs=4,
random_state=42))])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
Fitted attributes
Parameters
Fitted attributes
['Total_Discharges']
Parameters
Parameters
Parameters
['DRG_Definition', 'Provider_City', 'Provider_State', 'Hospital_Referral_Region_(HRR)_Description']
Parameters
100 of 121 features
| DRG_Definition_00 |
| DRG_Definition_01 |
| DRG_Definition_02 |
| DRG_Definition_03 |
| DRG_Definition_04 |
| DRG_Definition_05 |
| DRG_Definition_06 |
| DRG_Definition_07 |
| DRG_Definition_08 |
| DRG_Definition_09 |
| DRG_Definition_10 |
| DRG_Definition_11 |
| DRG_Definition_12 |
| DRG_Definition_13 |
| DRG_Definition_14 |
| DRG_Definition_15 |
| DRG_Definition_16 |
| DRG_Definition_17 |
| DRG_Definition_18 |
| DRG_Definition_19 |
| DRG_Definition_20 |
| DRG_Definition_21 |
| DRG_Definition_22 |
| DRG_Definition_23 |
| DRG_Definition_24 |
| DRG_Definition_25 |
| DRG_Definition_26 |
| DRG_Definition_27 |
| DRG_Definition_28 |
| DRG_Definition_29 |
| Provider_City_00 |
| Provider_City_01 |
| Provider_City_02 |
| Provider_City_03 |
| Provider_City_04 |
| Provider_City_05 |
| Provider_City_06 |
| Provider_City_07 |
| Provider_City_08 |
| Provider_City_09 |
| Provider_City_10 |
| Provider_City_11 |
| Provider_City_12 |
| Provider_City_13 |
| Provider_City_14 |
| Provider_City_15 |
| Provider_City_16 |
| Provider_City_17 |
| Provider_City_18 |
| Provider_City_19 |
| Provider_City_20 |
| Provider_City_21 |
| Provider_City_22 |
| Provider_City_23 |
| Provider_City_24 |
| Provider_City_25 |
| Provider_City_26 |
| Provider_City_27 |
| Provider_City_28 |
| Provider_City_29 |
| Provider_State_00 |
| Provider_State_01 |
| Provider_State_02 |
| Provider_State_03 |
| Provider_State_04 |
| Provider_State_05 |
| Provider_State_06 |
| Provider_State_07 |
| Provider_State_08 |
| Provider_State_09 |
| Provider_State_10 |
| Provider_State_11 |
| Provider_State_12 |
| Provider_State_13 |
| Provider_State_14 |
| Provider_State_15 |
| Provider_State_16 |
| Provider_State_17 |
| Provider_State_18 |
| Provider_State_19 |
| Provider_State_20 |
| Provider_State_21 |
| Provider_State_22 |
| Provider_State_23 |
| Provider_State_24 |
| Provider_State_25 |
| Provider_State_26 |
| Provider_State_27 |
| Provider_State_28 |
| Provider_State_29 |
| Hospital_Referral_Region_(HRR)_Description_00 |
| Hospital_Referral_Region_(HRR)_Description_01 |
| Hospital_Referral_Region_(HRR)_Description_02 |
| Hospital_Referral_Region_(HRR)_Description_03 |
| Hospital_Referral_Region_(HRR)_Description_04 |
| Hospital_Referral_Region_(HRR)_Description_05 |
| Hospital_Referral_Region_(HRR)_Description_06 |
| Hospital_Referral_Region_(HRR)_Description_07 |
| Hospital_Referral_Region_(HRR)_Description_08 |
| Hospital_Referral_Region_(HRR)_Description_09 |
Parameters
Fitted attributes
| DRG_Definition | Provider_City | Provider_State | Hospital_Referral_Region_(HRR)_Description | Total_Discharges | Average_Total_Payments | |
|---|---|---|---|---|---|---|
| 0 | 480 - HIP & FEMUR PROCEDURES EXCEPT MAJOR JOINT W MCC | NASHVILLE | TN | TN - Nashville | 13 | 2.52e+04 |
| 1 | 390 - G.I. OBSTRUCTION W/O CC/MCC | NASHVILLE | TN | TN - Nashville | 12 | 4.05e+03 |
| 2 | 683 - RENAL FAILURE W CC | SPARKS | NV | NV - Reno | 27 | 5.74e+03 |
| 3 | 491 - BACK & NECK PROC EXC SPINAL FUSION W/O CC/MCC | BRONX | NY | NY - Bronx | 11 | 1.20e+04 |
| 4 | 254 - OTHER VASCULAR PROCEDURES W/O CC/MCC | CONCORD | OH | OH - Cleveland | 17 | 8.50e+03 |
| 1,995 | 191 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W CC | MUNSTER | IN | IN - Munster | 153 | 5.83e+03 |
| 1,996 | 683 - RENAL FAILURE W CC | SAINT ALBANS | VT | VT - Burlington | 11 | 9.11e+03 |
| 1,997 | 039 - EXTRACRANIAL PROCEDURES W/O CC/MCC | SIOUX FALLS | SD | SD - Sioux Falls | 67 | 6.70e+03 |
| 1,998 | 069 - TRANSIENT ISCHEMIA | LITTLE ROCK | AR | AR - Little Rock | 85 | 4.29e+03 |
| 1,999 | 603 - CELLULITIS W/O MCC | SELLERSVILLE | PA | PA - Allentown | 50 | 4.96e+03 |
DRG_Definition
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
100 (5.0%)
This column has a high cardinality (> 40).
Provider_City
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
945 (47.2%)
This column has a high cardinality (> 40).
Provider_State
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
51 (2.5%)
This column has a high cardinality (> 40).
Hospital_Referral_Region_(HRR)_Description
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
287 (14.3%)
This column has a high cardinality (> 40).
Total_Discharges
Int64DType- Null values
- 0 (0.0%)
- Unique values
-
183 (9.2%)
This column has a high cardinality (> 40).
- Mean ± Std
- 43.7 ± 53.2
- Median ± IQR
- 27 ± 33
- Min | Max
- 11 | 778
Average_Total_Payments
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
1,995 (99.8%)
This column has a high cardinality (> 40).
- Mean ± Std
- 9.39e+03 ± 6.99e+03
- Median ± IQR
- 7.00e+03 ± 5.70e+03
- Min | Max
- 2.72e+03 | 7.32e+04
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
|
Column
|
Column name
|
dtype
|
Is sorted
|
Null values
|
Unique values
|
Mean
|
Std
|
Min
|
Median
|
Max
|
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | DRG_Definition | StringDtype | False | 0 (0.0%) | 100 (5.0%) | |||||
| 1 | Provider_City | StringDtype | False | 0 (0.0%) | 945 (47.2%) | |||||
| 2 | Provider_State | StringDtype | False | 0 (0.0%) | 51 (2.5%) | |||||
| 3 | Hospital_Referral_Region_(HRR)_Description | StringDtype | False | 0 (0.0%) | 287 (14.3%) | |||||
| 4 | Total_Discharges | Int64DType | False | 0 (0.0%) | 183 (9.2%) | 43.7 | 53.2 | 11 | 27 | 778 |
| 5 | Average_Total_Payments | Float64DType | False | 0 (0.0%) | 1995 (99.8%) | 9.39e+03 | 6.99e+03 | 2.72e+03 | 7.00e+03 | 7.32e+04 |
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
Please enable javascript
The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").
comparison_families = compare(
{
"ridge_with_fe": report_ridge_fe,
"random_forest": report_rf,
}
)
comparison_families.metrics.summarize().frame()
| estimator | ridge_with_fe | random_forest |
|---|---|---|
| metric | ||
| r2 | 0.505097 | 0.861134 |
| rmse | 4379.691473 | 2319.966730 |
| mae | 3026.040558 | 1598.113803 |
| mape | 0.383160 | 0.177348 |
| fit_time | 0.565683 | 3.612842 |
| predict_time | 0.119716 | 0.139302 |
In this case, we see that we get closer to the gradient boosting baseline but we still have a small gap (SKD009 reports an r2 of around 0.88 for the baseline).
report_rf.checks.summarize()
- [SKD001] Potential overfitting. Significant train/test gaps were found for 3/4 default predictive metrics.
- [SKD008] Highly correlated input features. 1 pair(s) of features have a Spearman correlation above 0.9. Highly correlated features can destabilize linear model coefficients and feature-importance estimates, and may cause collinearity-induced numerical issues.Dropping redundant features may also improve model performance.
- [SKD007] MDI biased for high-cardinality features. High-cardinality features detected: Provider_City_00, Provider_City_01, Provider_City_02 (and 27 more). Mean Decrease in Impurity (MDI) importance is biased toward such features. Consider using permutation importance for a more robust alternative.
- [SKD009] Model performance vs. HistGradientBoosting baseline. Your model is on par with or better than a HistGradientBoosting baseline. Baseline performance on the test set, for reference: MAE=1.52e+03, MAPE=0.171, RMSE=2.24e+03, R²=0.87.
- [SKD011] Golden feature. A model trained on feature(s) ['DRG_Definition_02', 'DRG_Definition_04', 'DRG_Definition_05', 'DRG_Definition_07', 'DRG_Definition_08', 'DRG_Definition_11', 'DRG_Definition_14', 'DRG_Definition_16', 'DRG_Definition_17', 'DRG_Definition_21', 'DRG_Definition_24', 'DRG_Definition_25', 'DRG_Definition_26', 'DRG_Definition_27'] alone has similar performance to a model trained on all the features, on the default predictive metrics. This may signal data leakage or excessive reliance on a single feature.
- [SKD012] Useless features. Feature(s) ['Total_Discharges'] have permutation importance overlapping with zero and could likely be dropped without degrading performance. Dropping redundant features may also improve model performance.
- [SKD003] Inconsistent performance across splits. Not applicable to estimator reports.
- [SKD004] High class imbalance. ML task is not binary classification. Got regression.
- [SKD005] Underrepresented classes. ML task is not multiclass classification. Got regression.
- [SKD006] Coefficient interpretation. Estimator is not a linear model: it does not have a `coef_` attribute.
- [SKD013] Train-test overlap in time series. No datetime column found.
- [SKD014] Hyperparameters at search edge. Estimator is not a BaseSearchCV instance. Got Pipeline.
- [SKD015] Hyperparameters worth tuning. Estimator is not a BaseSearchCV instance. Got Pipeline.
No checks were skipped in fast mode.
No checks were muted.
Mute a check by passing its code to ignore, e.g. .checks.summarize(ignore=['SKD001']).
Switch to HistGradientBoostingRegressor#
skore’s SKD009 performance baseline is itself an HGB pipeline. Matching that family is the natural next step once trees look promising, and we find that we are on par with skore’s baseline.
from sklearn.ensemble import HistGradientBoostingRegressor
report_hgb = evaluate(
tabular_pipeline(HistGradientBoostingRegressor(random_state=42)),
X=X,
y=y,
splitter=splitter,
)
report_hgb
| Metric | HistGradientBoostingRegressor |
|---|---|
| R² | 0.875564 |
| RMSE | 2196.121251 |
| MAE | 1466.021927 |
| MAPE | 0.164379 |
| Fit time (s) | 2.540428 |
| Predict time (s) | 0.269022 |
- [SKD001] Potential overfitting. Significant train/test gaps were found for 4/4 default predictive metrics.
- [SKD016] Estimator not tuned. Estimator(s) left at default settings; consider tuning: ['learning_rate', 'max_leaf_nodes'] for HistGradientBoostingRegressor.
- [SKD003] Inconsistent performance across splits. Not applicable to estimator reports.
- [SKD004] High class imbalance. ML task is not binary classification. Got regression.
- [SKD005] Underrepresented classes. ML task is not multiclass classification. Got regression.
- [SKD006] Coefficient interpretation. Estimator is not a linear model: it does not have a `coef_` attribute.
- [SKD007] MDI biased for high-cardinality features. Estimator is not a tree-based model: it does not have a `feature_importances_` attribute.
- [SKD013] Train-test overlap in time series. No datetime column found.
- [SKD014] Hyperparameters at search edge. Estimator is not a BaseSearchCV instance. Got Pipeline.
- [SKD015] Hyperparameters worth tuning. Estimator is not a BaseSearchCV instance. Got Pipeline.
No checks were muted.
Fast mode is on: expensive checks are skipped unless already cached.
Mute a check by passing its code to ignore, e.g. .checks.summarize(ignore=['SKD001']).
Pipeline(steps=[('tablevectorizer',
TableVectorizer(low_cardinality=ToCategorical())),
('histgradientboostingregressor',
HistGradientBoostingRegressor(random_state=42))])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
Fitted attributes
Parameters
Fitted attributes
['Total_Discharges']
Parameters
Parameters
Parameters
['DRG_Definition', 'Provider_City', 'Provider_State', 'Hospital_Referral_Region_(HRR)_Description']
Parameters
100 of 121 features
| DRG_Definition_00 |
| DRG_Definition_01 |
| DRG_Definition_02 |
| DRG_Definition_03 |
| DRG_Definition_04 |
| DRG_Definition_05 |
| DRG_Definition_06 |
| DRG_Definition_07 |
| DRG_Definition_08 |
| DRG_Definition_09 |
| DRG_Definition_10 |
| DRG_Definition_11 |
| DRG_Definition_12 |
| DRG_Definition_13 |
| DRG_Definition_14 |
| DRG_Definition_15 |
| DRG_Definition_16 |
| DRG_Definition_17 |
| DRG_Definition_18 |
| DRG_Definition_19 |
| DRG_Definition_20 |
| DRG_Definition_21 |
| DRG_Definition_22 |
| DRG_Definition_23 |
| DRG_Definition_24 |
| DRG_Definition_25 |
| DRG_Definition_26 |
| DRG_Definition_27 |
| DRG_Definition_28 |
| DRG_Definition_29 |
| Provider_City_00 |
| Provider_City_01 |
| Provider_City_02 |
| Provider_City_03 |
| Provider_City_04 |
| Provider_City_05 |
| Provider_City_06 |
| Provider_City_07 |
| Provider_City_08 |
| Provider_City_09 |
| Provider_City_10 |
| Provider_City_11 |
| Provider_City_12 |
| Provider_City_13 |
| Provider_City_14 |
| Provider_City_15 |
| Provider_City_16 |
| Provider_City_17 |
| Provider_City_18 |
| Provider_City_19 |
| Provider_City_20 |
| Provider_City_21 |
| Provider_City_22 |
| Provider_City_23 |
| Provider_City_24 |
| Provider_City_25 |
| Provider_City_26 |
| Provider_City_27 |
| Provider_City_28 |
| Provider_City_29 |
| Provider_State_00 |
| Provider_State_01 |
| Provider_State_02 |
| Provider_State_03 |
| Provider_State_04 |
| Provider_State_05 |
| Provider_State_06 |
| Provider_State_07 |
| Provider_State_08 |
| Provider_State_09 |
| Provider_State_10 |
| Provider_State_11 |
| Provider_State_12 |
| Provider_State_13 |
| Provider_State_14 |
| Provider_State_15 |
| Provider_State_16 |
| Provider_State_17 |
| Provider_State_18 |
| Provider_State_19 |
| Provider_State_20 |
| Provider_State_21 |
| Provider_State_22 |
| Provider_State_23 |
| Provider_State_24 |
| Provider_State_25 |
| Provider_State_26 |
| Provider_State_27 |
| Provider_State_28 |
| Provider_State_29 |
| Hospital_Referral_Region_(HRR)_Description_00 |
| Hospital_Referral_Region_(HRR)_Description_01 |
| Hospital_Referral_Region_(HRR)_Description_02 |
| Hospital_Referral_Region_(HRR)_Description_03 |
| Hospital_Referral_Region_(HRR)_Description_04 |
| Hospital_Referral_Region_(HRR)_Description_05 |
| Hospital_Referral_Region_(HRR)_Description_06 |
| Hospital_Referral_Region_(HRR)_Description_07 |
| Hospital_Referral_Region_(HRR)_Description_08 |
| Hospital_Referral_Region_(HRR)_Description_09 |
Parameters
Fitted attributes
| DRG_Definition | Provider_City | Provider_State | Hospital_Referral_Region_(HRR)_Description | Total_Discharges | Average_Total_Payments | |
|---|---|---|---|---|---|---|
| 0 | 480 - HIP & FEMUR PROCEDURES EXCEPT MAJOR JOINT W MCC | NASHVILLE | TN | TN - Nashville | 13 | 2.52e+04 |
| 1 | 390 - G.I. OBSTRUCTION W/O CC/MCC | NASHVILLE | TN | TN - Nashville | 12 | 4.05e+03 |
| 2 | 683 - RENAL FAILURE W CC | SPARKS | NV | NV - Reno | 27 | 5.74e+03 |
| 3 | 491 - BACK & NECK PROC EXC SPINAL FUSION W/O CC/MCC | BRONX | NY | NY - Bronx | 11 | 1.20e+04 |
| 4 | 254 - OTHER VASCULAR PROCEDURES W/O CC/MCC | CONCORD | OH | OH - Cleveland | 17 | 8.50e+03 |
| 1,995 | 191 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W CC | MUNSTER | IN | IN - Munster | 153 | 5.83e+03 |
| 1,996 | 683 - RENAL FAILURE W CC | SAINT ALBANS | VT | VT - Burlington | 11 | 9.11e+03 |
| 1,997 | 039 - EXTRACRANIAL PROCEDURES W/O CC/MCC | SIOUX FALLS | SD | SD - Sioux Falls | 67 | 6.70e+03 |
| 1,998 | 069 - TRANSIENT ISCHEMIA | LITTLE ROCK | AR | AR - Little Rock | 85 | 4.29e+03 |
| 1,999 | 603 - CELLULITIS W/O MCC | SELLERSVILLE | PA | PA - Allentown | 50 | 4.96e+03 |
DRG_Definition
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
100 (5.0%)
This column has a high cardinality (> 40).
Provider_City
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
945 (47.2%)
This column has a high cardinality (> 40).
Provider_State
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
51 (2.5%)
This column has a high cardinality (> 40).
Hospital_Referral_Region_(HRR)_Description
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
287 (14.3%)
This column has a high cardinality (> 40).
Total_Discharges
Int64DType- Null values
- 0 (0.0%)
- Unique values
-
183 (9.2%)
This column has a high cardinality (> 40).
- Mean ± Std
- 43.7 ± 53.2
- Median ± IQR
- 27 ± 33
- Min | Max
- 11 | 778
Average_Total_Payments
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
1,995 (99.8%)
This column has a high cardinality (> 40).
- Mean ± Std
- 9.39e+03 ± 6.99e+03
- Median ± IQR
- 7.00e+03 ± 5.70e+03
- Min | Max
- 2.72e+03 | 7.32e+04
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
|
Column
|
Column name
|
dtype
|
Is sorted
|
Null values
|
Unique values
|
Mean
|
Std
|
Min
|
Median
|
Max
|
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | DRG_Definition | StringDtype | False | 0 (0.0%) | 100 (5.0%) | |||||
| 1 | Provider_City | StringDtype | False | 0 (0.0%) | 945 (47.2%) | |||||
| 2 | Provider_State | StringDtype | False | 0 (0.0%) | 51 (2.5%) | |||||
| 3 | Hospital_Referral_Region_(HRR)_Description | StringDtype | False | 0 (0.0%) | 287 (14.3%) | |||||
| 4 | Total_Discharges | Int64DType | False | 0 (0.0%) | 183 (9.2%) | 43.7 | 53.2 | 11 | 27 | 778 |
| 5 | Average_Total_Payments | Float64DType | False | 0 (0.0%) | 1995 (99.8%) | 9.39e+03 | 6.99e+03 | 2.72e+03 | 7.00e+03 | 7.32e+04 |
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
Please enable javascript
The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").
report_hgb.checks.summarize()
- [SKD001] Potential overfitting. Significant train/test gaps were found for 4/4 default predictive metrics.
- [SKD009] Model performance vs. HistGradientBoosting baseline. Test scores are significantly worse than a HistGradientBoosting baseline for 3/4 default predictive metrics. Baseline performance on the test set: MAE=1.37e+03, MAPE=0.154, RMSE=2.01e+03, R²=0.896.
- [SKD012] Useless features. Feature(s) ['Total_Discharges'] have permutation importance overlapping with zero and could likely be dropped without degrading performance. Dropping redundant features may also improve model performance.
- [SKD016] Estimator not tuned. Estimator(s) left at default settings; consider tuning: ['learning_rate', 'max_leaf_nodes'] for HistGradientBoostingRegressor.
- [SKD003] Inconsistent performance across splits. Not applicable to estimator reports.
- [SKD004] High class imbalance. ML task is not binary classification. Got regression.
- [SKD005] Underrepresented classes. ML task is not multiclass classification. Got regression.
- [SKD006] Coefficient interpretation. Estimator is not a linear model: it does not have a `coef_` attribute.
- [SKD007] MDI biased for high-cardinality features. Estimator is not a tree-based model: it does not have a `feature_importances_` attribute.
- [SKD013] Train-test overlap in time series. No datetime column found.
- [SKD014] Hyperparameters at search edge. Estimator is not a BaseSearchCV instance. Got Pipeline.
- [SKD015] Hyperparameters worth tuning. Estimator is not a BaseSearchCV instance. Got Pipeline.
No checks were skipped in fast mode.
No checks were muted.
Mute a check by passing its code to ignore, e.g. .checks.summarize(ignore=['SKD001']).
Combine levers: features, HGB, and a log target#
Let’s go a little further in our modelling efforts in order to beat that performant baseline. For that, let us stack the previous techniques we used:
the engineered features,
an HGB with tuned parameters,
TransformedTargetRegressorwithlog1p/expm1, because payment totals are heavy-tailed.
In practice you would usually tune these knobs with
RandomizedSearchCV or
GridSearchCV from scikit-learn. To keep the
example short and reproducible, we pin one search outcome that beats the baseline
on this split.
from sklearn.compose import TransformedTargetRegressor
from skrub import ToCategorical
tuned = TransformedTargetRegressor(
regressor=make_pipeline(
FunctionTransformer(engineer_features),
TableVectorizer(low_cardinality=ToCategorical()),
HistGradientBoostingRegressor(
learning_rate=0.05,
max_iter=500,
max_depth=5,
max_leaf_nodes=63,
min_samples_leaf=10,
l2_regularization=0.1,
random_state=42,
),
),
func=np.log1p,
inverse_func=np.expm1,
)
report_tuned = evaluate(tuned, X=X, y=y, splitter=splitter)
report_tuned
| Metric | TransformedTargetRegressor |
|---|---|
| R² | 0.914409 |
| RMSE | 1821.365625 |
| MAE | 1193.135226 |
| MAPE | 0.127016 |
| Fit time (s) | 2.877205 |
| Predict time (s) | 0.154415 |
- [SKD001] Potential overfitting. Significant train/test gaps were found for 3/4 default predictive metrics.
No tips were emitted for your report.
- [SKD002] Potential underfitting.
- [SKD003] Inconsistent performance across splits. Not applicable to estimator reports.
- [SKD004] High class imbalance. ML task is not binary classification. Got regression.
- [SKD005] Underrepresented classes. ML task is not multiclass classification. Got regression.
- [SKD006] Coefficient interpretation. Estimator is not a linear model: it does not have a `coef_` attribute.
- [SKD007] MDI biased for high-cardinality features. Estimator is not a tree-based model: it does not have a `feature_importances_` attribute.
- [SKD008] Highly correlated input features. Expected train data to have between 2 and 1000 features; got 1.
- [SKD013] Train-test overlap in time series. No datetime column found.
- [SKD014] Hyperparameters at search edge. Estimator is not a BaseSearchCV instance. Got TransformedTargetRegressor.
- [SKD015] Hyperparameters worth tuning. Estimator is not a BaseSearchCV instance. Got TransformedTargetRegressor.
- [SKD016] Estimator not tuned. No parameter to recommend.
No checks were muted.
Fast mode is on: expensive checks are skipped unless already cached.
Mute a check by passing its code to ignore, e.g. .checks.summarize(ignore=['SKD001']).
TransformedTargetRegressor(func=<ufunc 'log1p'>, inverse_func=<ufunc 'expm1'>,
regressor=Pipeline(steps=[('functiontransformer',
FunctionTransformer(func=<function engineer_features at 0x7f26d02c2770>)),
('tablevectorizer',
TableVectorizer(low_cardinality=ToCategorical())),
('histgradientboostingregressor',
HistGradientBoostingRegressor(l2_regularization=0.1,
learning_rate=0.05,
max_depth=5,
max_iter=500,
max_leaf_nodes=63,
min_samples_leaf=10,
random_state=42))]))In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
Fitted attributes
| Name | Type | Value |
|---|---|---|
|
feature_names_in_
feature_names_in_: ndarray of shape (`n_features_in_`,) Names of features seen during :term:`fit`. Defined only when `X` has feature names that are all strings. .. versionadded:: 1.0 |
ndarray[object](5,) | ['DRG_Definition','Provider_City','Provider_State', 'Hospital_Referral_Region_(HRR)_Description','Total_Discharges'] |
|
n_features_in_
n_features_in_: int Number of features seen during :term:`fit`. Only defined if the underlying regressor exposes such an attribute when fit. .. versionadded:: 0.24 |
int | 5 |
|
regressor_
regressor_: object Fitted regressor. |
Pipeline | Pipeline(step...m_state=42))]) |
|
transformer_
transformer_: object Transformer used in :meth:`fit` and :meth:`predict`. |
FunctionTransformer | FunctionTrans...validate=True) |
Parameters
Fitted attributes
| Name | Type | Value |
|---|---|---|
|
feature_names_in_
feature_names_in_: ndarray of shape (`n_features_in_`,) Names of features seen during :term:`fit`. Only defined if the underlying estimator exposes such an attribute when fit. .. versionadded:: 1.0 |
ndarray[object](5,) | ['DRG_Definition','Provider_City','Provider_State', 'Hospital_Referral_Region_(HRR)_Description','Total_Discharges'] |
|
n_features_in_
n_features_in_: int Number of features seen during :term:`fit`. Only defined if the underlying first estimator in `steps` exposes such an attribute when fit. .. versionadded:: 0.24 |
int | 5 |
Parameters
Fitted attributes
| Name | Type | Value |
|---|---|---|
|
feature_names_in_
feature_names_in_: ndarray of shape (`n_features_in_`,) Names of features seen during :term:`fit`. Defined only when `X` has feature names that are all strings. .. versionadded:: 1.0 |
ndarray[object](5,) | ['DRG_Definition','Provider_City','Provider_State', 'Hospital_Referral_Region_(HRR)_Description','Total_Discharges'] |
|
n_features_in_
n_features_in_: int Number of features seen during :term:`fit`. .. versionadded:: 0.24 |
int | 5 |
Parameters
Fitted attributes
['log_Total_Discharges', 'DRG_Code', 'has_MCC', 'has_CC']
Parameters
Parameters
Parameters
['DRG_Definition', 'Provider_City', 'Provider_State', 'Hospital_Referral_Region_(HRR)_Description']
Parameters
100 of 124 features
| DRG_Definition_00 |
| DRG_Definition_01 |
| DRG_Definition_02 |
| DRG_Definition_03 |
| DRG_Definition_04 |
| DRG_Definition_05 |
| DRG_Definition_06 |
| DRG_Definition_07 |
| DRG_Definition_08 |
| DRG_Definition_09 |
| DRG_Definition_10 |
| DRG_Definition_11 |
| DRG_Definition_12 |
| DRG_Definition_13 |
| DRG_Definition_14 |
| DRG_Definition_15 |
| DRG_Definition_16 |
| DRG_Definition_17 |
| DRG_Definition_18 |
| DRG_Definition_19 |
| DRG_Definition_20 |
| DRG_Definition_21 |
| DRG_Definition_22 |
| DRG_Definition_23 |
| DRG_Definition_24 |
| DRG_Definition_25 |
| DRG_Definition_26 |
| DRG_Definition_27 |
| DRG_Definition_28 |
| DRG_Definition_29 |
| Provider_City_00 |
| Provider_City_01 |
| Provider_City_02 |
| Provider_City_03 |
| Provider_City_04 |
| Provider_City_05 |
| Provider_City_06 |
| Provider_City_07 |
| Provider_City_08 |
| Provider_City_09 |
| Provider_City_10 |
| Provider_City_11 |
| Provider_City_12 |
| Provider_City_13 |
| Provider_City_14 |
| Provider_City_15 |
| Provider_City_16 |
| Provider_City_17 |
| Provider_City_18 |
| Provider_City_19 |
| Provider_City_20 |
| Provider_City_21 |
| Provider_City_22 |
| Provider_City_23 |
| Provider_City_24 |
| Provider_City_25 |
| Provider_City_26 |
| Provider_City_27 |
| Provider_City_28 |
| Provider_City_29 |
| Provider_State_00 |
| Provider_State_01 |
| Provider_State_02 |
| Provider_State_03 |
| Provider_State_04 |
| Provider_State_05 |
| Provider_State_06 |
| Provider_State_07 |
| Provider_State_08 |
| Provider_State_09 |
| Provider_State_10 |
| Provider_State_11 |
| Provider_State_12 |
| Provider_State_13 |
| Provider_State_14 |
| Provider_State_15 |
| Provider_State_16 |
| Provider_State_17 |
| Provider_State_18 |
| Provider_State_19 |
| Provider_State_20 |
| Provider_State_21 |
| Provider_State_22 |
| Provider_State_23 |
| Provider_State_24 |
| Provider_State_25 |
| Provider_State_26 |
| Provider_State_27 |
| Provider_State_28 |
| Provider_State_29 |
| Hospital_Referral_Region_(HRR)_Description_00 |
| Hospital_Referral_Region_(HRR)_Description_01 |
| Hospital_Referral_Region_(HRR)_Description_02 |
| Hospital_Referral_Region_(HRR)_Description_03 |
| Hospital_Referral_Region_(HRR)_Description_04 |
| Hospital_Referral_Region_(HRR)_Description_05 |
| Hospital_Referral_Region_(HRR)_Description_06 |
| Hospital_Referral_Region_(HRR)_Description_07 |
| Hospital_Referral_Region_(HRR)_Description_08 |
| Hospital_Referral_Region_(HRR)_Description_09 |
Parameters
Fitted attributes
| DRG_Definition | Provider_City | Provider_State | Hospital_Referral_Region_(HRR)_Description | Total_Discharges | Average_Total_Payments | |
|---|---|---|---|---|---|---|
| 0 | 480 - HIP & FEMUR PROCEDURES EXCEPT MAJOR JOINT W MCC | NASHVILLE | TN | TN - Nashville | 13 | 2.52e+04 |
| 1 | 390 - G.I. OBSTRUCTION W/O CC/MCC | NASHVILLE | TN | TN - Nashville | 12 | 4.05e+03 |
| 2 | 683 - RENAL FAILURE W CC | SPARKS | NV | NV - Reno | 27 | 5.74e+03 |
| 3 | 491 - BACK & NECK PROC EXC SPINAL FUSION W/O CC/MCC | BRONX | NY | NY - Bronx | 11 | 1.20e+04 |
| 4 | 254 - OTHER VASCULAR PROCEDURES W/O CC/MCC | CONCORD | OH | OH - Cleveland | 17 | 8.50e+03 |
| 1,995 | 191 - CHRONIC OBSTRUCTIVE PULMONARY DISEASE W CC | MUNSTER | IN | IN - Munster | 153 | 5.83e+03 |
| 1,996 | 683 - RENAL FAILURE W CC | SAINT ALBANS | VT | VT - Burlington | 11 | 9.11e+03 |
| 1,997 | 039 - EXTRACRANIAL PROCEDURES W/O CC/MCC | SIOUX FALLS | SD | SD - Sioux Falls | 67 | 6.70e+03 |
| 1,998 | 069 - TRANSIENT ISCHEMIA | LITTLE ROCK | AR | AR - Little Rock | 85 | 4.29e+03 |
| 1,999 | 603 - CELLULITIS W/O MCC | SELLERSVILLE | PA | PA - Allentown | 50 | 4.96e+03 |
DRG_Definition
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
100 (5.0%)
This column has a high cardinality (> 40).
Provider_City
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
945 (47.2%)
This column has a high cardinality (> 40).
Provider_State
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
51 (2.5%)
This column has a high cardinality (> 40).
Hospital_Referral_Region_(HRR)_Description
StringDtype- Null values
- 0 (0.0%)
- Unique values
-
287 (14.3%)
This column has a high cardinality (> 40).
Total_Discharges
Int64DType- Null values
- 0 (0.0%)
- Unique values
-
183 (9.2%)
This column has a high cardinality (> 40).
- Mean ± Std
- 43.7 ± 53.2
- Median ± IQR
- 27 ± 33
- Min | Max
- 11 | 778
Average_Total_Payments
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
1,995 (99.8%)
This column has a high cardinality (> 40).
- Mean ± Std
- 9.39e+03 ± 6.99e+03
- Median ± IQR
- 7.00e+03 ± 5.70e+03
- Min | Max
- 2.72e+03 | 7.32e+04
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
|
Column
|
Column name
|
dtype
|
Is sorted
|
Null values
|
Unique values
|
Mean
|
Std
|
Min
|
Median
|
Max
|
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | DRG_Definition | StringDtype | False | 0 (0.0%) | 100 (5.0%) | |||||
| 1 | Provider_City | StringDtype | False | 0 (0.0%) | 945 (47.2%) | |||||
| 2 | Provider_State | StringDtype | False | 0 (0.0%) | 51 (2.5%) | |||||
| 3 | Hospital_Referral_Region_(HRR)_Description | StringDtype | False | 0 (0.0%) | 287 (14.3%) | |||||
| 4 | Total_Discharges | Int64DType | False | 0 (0.0%) | 183 (9.2%) | 43.7 | 53.2 | 11 | 27 | 778 |
| 5 | Average_Total_Payments | Float64DType | False | 0 (0.0%) | 1995 (99.8%) | 9.39e+03 | 6.99e+03 | 2.72e+03 | 7.00e+03 | 7.32e+04 |
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
Please enable javascript
The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").
Our model is now significantly better than an HGB baseline, and SKD009 is still reporting baseline scores for reference.
report_tuned.checks.summarize()
- [SKD001] Potential overfitting. Significant train/test gaps were found for 3/4 default predictive metrics.
- [SKD009] Model performance vs. HistGradientBoosting baseline. Your model is on par with or better than a HistGradientBoosting baseline. Baseline performance on the test set, for reference: MAE=1.43e+03, MAPE=0.156, RMSE=2.12e+03, R²=0.884.
- [SKD012] Useless features. Feature(s) ['Total_Discharges'] have permutation importance overlapping with zero and could likely be dropped without degrading performance. Dropping redundant features may also improve model performance.
- [SKD003] Inconsistent performance across splits. Not applicable to estimator reports.
- [SKD004] High class imbalance. ML task is not binary classification. Got regression.
- [SKD005] Underrepresented classes. ML task is not multiclass classification. Got regression.
- [SKD006] Coefficient interpretation. Estimator is not a linear model: it does not have a `coef_` attribute.
- [SKD007] MDI biased for high-cardinality features. Estimator is not a tree-based model: it does not have a `feature_importances_` attribute.
- [SKD008] Highly correlated input features. Expected train data to have between 2 and 1000 features; got 1.
- [SKD011] Golden feature. Failed to create report from single feature.
- [SKD013] Train-test overlap in time series. No datetime column found.
- [SKD014] Hyperparameters at search edge. Estimator is not a BaseSearchCV instance. Got TransformedTargetRegressor.
- [SKD015] Hyperparameters worth tuning. Estimator is not a BaseSearchCV instance. Got TransformedTargetRegressor.
- [SKD016] Estimator not tuned. No parameter to recommend.
No checks were skipped in fast mode.
No checks were muted.
Mute a check by passing its code to ignore, e.g. .checks.summarize(ignore=['SKD001']).
Conclusion#
SKD009 informs you when your model is beaten by a simple but strong baseline. We showed different approaches to address it: feature and target engineering, changing model family and tuning hyperparameters to finally clear well past the baseline.
Total running time of the script: (1 minutes 54.319 seconds)