<jupyter_start><jupyter_text>Breast Cancer Data<jupyter_code>dataset = datasets.load_breast_cancer()
X = pd.DataFrame(dataset.data, columns = dataset.feature_names)
y = dataset.target
X.head()<jupyter_output><empty_output><jupyter_text>Build XGBoost model<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=2021)
clf = XGBClassifier(n_estimators=1000,
                    booster="gbtree",
                    objective="binary:logistic",
                    learning_rate=0.05,
                    max_depth=6,
                    use_label_encoder=False,
                    seed=2021)
clf.fit(X=X_train, y=y_train, eval_set=[(X_test, y_test)], early_stopping_rounds=20, verbose=10)<jupyter_output>[21:25:24] WARNING: /Users/travis/build/dmlc/xgboost/src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.
[0]	validation_0-logloss:0.65349
[10]	validation_0-logloss:0.39963
[20]	validation_0-logloss:0.28059
[30]	validation_0-logloss:0.21149
[40]	validation_0-logloss:0.16765
[50]	validation_0-logloss:0.14519
[60]	validation_0-logloss:0.13101
[70]	validation_0-logloss:0.12157
[80]	validation_0-logloss:0.11758
[90]	validation_0-logloss:0.11513
[100]	validation_0-logloss:0.11288
[110]	validation_0-logloss:0.11233
[120]	validation_0-logloss:0.11187
[130]	validation_0-logloss:0.11200
[140]	validation_0-logloss:0.11186
[145]	validation_0-logloss:0.11185<jupyter_text>Analyze data drift with OutputDriftDetectorThe experiment is done with a random split so we should not detect a data drift  prediction_type='proba'<jupyter_code>output_drift_detector = OutputDriftDetector(task='classification', prediction_type='proba')
clf.predict_proba(X_train)
output_drift_detector.fit(clf.predict_proba(X_train), clf.predict_proba(X_test),
                           y_train, y_test)
output_drift_detector.plot_prediction_drift()
output_drift_detector.get_prediction_drift()
output_drift_detector.plot_target_drift()
output_drift_detector.get_target_drift()
output_drift_detector.get_performance_metrics_drift()<jupyter_output><empty_output><jupyter_text>prediction_type='label'<jupyter_code>output_drift_detector2 = OutputDriftDetector(task='classification', prediction_type='label')
output_drift_detector2.fit(clf.predict(X_train), clf.predict(X_test),
                            y_train, y_test)
output_drift_detector2.plot_prediction_drift()
output_drift_detector2.get_prediction_drift()
output_drift_detector2.plot_target_drift()
output_drift_detector2.get_target_drift()
output_drift_detector2.get_performance_metrics_drift()<jupyter_output><empty_output><jupyter_text>prediction_type='raw'<jupyter_code>output_drift_detector3 = OutputDriftDetector(task='classification', prediction_type='raw')
output_drift_detector3.fit(clf.predict(X_train, output_margin=True), clf.predict(X_test, output_margin=True),
                            y_train, y_test)
output_drift_detector3.plot_prediction_drift()
output_drift_detector3.get_prediction_drift()
output_drift_detector3.plot_target_drift()
output_drift_detector3.get_target_drift()
output_drift_detector3.get_performance_metrics_drift()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10294117647058823, 'fraction_numerical': 0.05942376950780312, 'mean_word_length': 6.489887640449438, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '248033', 'license': 'MIT', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1232, 'n_words': 154, 'path': 'Chapter7/concept_drift_explainer/breast_cancer_OutputDriftDetector.ipynb', 'repo_name': 'PacktPublishing/Designing-Models-for-Responsible-AI', 'size': '3332'}