Target drift is a change over time in the distribution of a model’s target variable. In credit scoring, it can appear as a change in the proportion of borrowers who default. Monitoring that proportion helps risk teams identify shifts that may affect a model’s performance. section 6.2.2 section 6.0
Target drift differs from feature drift: the former tracks outcomes such as default, while the latter tracks changes in input distributions. A report can monitor both, even when the target remains stable and some features have shifted. section 6.2 section 6.2.2
To check target drift with Evidently:
- Create a reference DataFrame from training features and labels, and a current DataFrame from test features and labels. Put the labels in a target column. section 6.2.1
- Configure ColumnMapping with the target and numeric and categorical features. Run a Report with DataDriftPreset and TargetDriftPreset, then save the result as HTML. section 6.2.1
- Inspect the target panel’s reference and current default rates and its Jensen–Shannon divergence score. Review feature shifts separately and consider their business impact. section 6.2.2
Listing 6.9 Creating and saving the Evidently drift report
from evidently import ColumnMapping
from evidently.report import Report
from evidently.metric_preset import DataDriftPreset, TargetDriftPreset
df_train = X_train.copy() #1
df_train["target"] = y_train.values
df_test = X_test.copy() #2
df_test["target"] = y_test.values
col_map = ColumnMapping( #3
target="target",
numerical_features=X_train.select_dtypes(include="number").columns.tolist(),
categorical_features=X_train.select_dtypes(exclude="number").columns.tolist()
)
combined_report = Report( #4
metrics=[
DataDriftPreset(),
TargetDriftPreset()
]
)
combined_report.run( #5
reference_data=df_train,
current_data=df_test,
column_mapping=col_map
)
combined_report.save_html("combined_drift_report.html") #6
print("Drift report saved to 'combined_drift_report.html'")
The listing implements the combined feature and target drift report, including the target column mapping. section 6.2.1
A rising default rate
If the default rate rises from 26% in the reference data to 31% in current data, the population may be riskier. Risk teams may investigate and consider retraining or recalibrating thresholds. A near-zero target drift score with nearly identical bars instead suggests little change. section 6.2.2
For severe, sustained drift, a champion–challenger comparison can run an updated model alongside the existing one. Archiving HTML reports monthly or quarterly also provides a record for monitoring and compliance reviews. section 6.2.2
