XAIDrift.get_report

XAIDrift.get_report()

Restituisce il report sul drift dell’importanza delle feature.

Questa funzione restituisce un DataFrame che contiene il report sul drift dell’importanza delle feature, ordinato in ordine crescente in base all’importanza delle feature nel modello storico. Il report include le informazioni sull’importanza delle feature nel modello corrente e storico, nonché eventuali drift rilevati in base al confronto tra i due e warning relativi.

Returns:

Report con l’importanza delle feature nel modello corrente e storico, e l’eventuale drift rilevato con i relativi warning.

Return type:

pd.DataFrame

Note

  • Se chiamato dopo il metodo get_drift il report presenterà anche informazioni sul drift tra il valore corrente e quello storico ed eventuli warning basati su di esso.

Dati utilizzati per gli esempi:

>>> df_esempio_corr
feature_num feature_cat pred_clf
0 1 A 0
1 3 B 1
2 1 A 0
3 1 B 0
4 1 B 0
5 3 A 1
6 1 B 0
7 1 B 0
8 1 B 0
9 3 A 1
>>> df_esempio_stor
feature_num feature_cat pred_clf
0 1 A 0
1 2 B 1
2 3 A 0
3 4 C 0
4 5 B 0
5 6 A 0
6 7 C 0
7 8 A 1
8 9 B 1
9 10 C 0

Esempio:

>>> Xai = XAI(model_input='custom', model=modelLR)
>>> Xai.fit(df_esempio_corr.drop(columns=['pred_clf']),df_esempio_corr['pred_clf'], standardize=True)
>>> importance_corr=Xai.get_feature_importance(feat_imp_mode='coef')
>>> importance_corr
{'type': 'coef',
 'feat_importance': {'feature_num': 0.8989692717116683,
  'feature_cat': 0.1010307282883317}}
>>> Xai.fit(df_esempio_stor.drop(columns=['pred_clf']),df_esempio_stor['pred_clf'], standardize=True)
>>> importance_stor=Xai.get_feature_importance(feat_imp_mode='coef')
>>> importance_stor
{'type': 'coef',
 'feat_importance': {'feature_num': 0.5098198313687213,
  'feature_cat': 0.4901801686312786}}
>>> from model_monitoring.XAI_drift import XAIDrift
>>> XaiD = XAIDrift(importance_corr,importance_stor)
>>> XaiD.get_report()
feature curr_score stor_score
1 feature_cat 0.101031 0.49018
0 feature_num 0.898969 0.50982
>>> XaiD.get_drift()
>>> XaiD.get_report()
control_type feature curr_score stor_score value relative_warning
1 feature drift perc feature_cat 0.101031 0.49018 -79.389062 Red Alert
0 feature drift perc feature_num 0.898969 0.50982 76.330777 Red Alert
2 psi xai score xai_psi NaN NaN 0.835325 Red Alert