Detecting drifts
Avoiding drifts altogether in all our models is not possible, but we can aim to detect them early on and eliminate them. Here, we are going to practice drift detection with alibi_detect
and evidently
in Python.
Practicing with alibi_detect for drift detection
One of the widely-used Python libraries for drift detection that we want to practice with is alibi_detect
. We will first import the necessary Python functions and classes and generate a synthetic dataset with 10 features and 10,000 samples using make_classification
from scikit-learn
:
import numpy as npimport pandas as pd import lightgbm as lgb from alibi_detect.cd import KSDrift from sklearn.datasets import make_classification from sklearn.model_selection import train_test_split from sklearn.metrics import balanced_accuracy_score as bacc # Generate synthetic data X, y = make_classification(n_samples=10000, n_features=10, n_classes=2, random_state=42)
Then, we split the data...