validmind 2.4.13__py3-none-any.whl → 2.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- validmind/__version__.py +1 -1
- validmind/tests/__types__.py +4 -0
- validmind/tests/model_validation/sklearn/ClassifierPerformance.py +15 -6
- validmind/tests/model_validation/sklearn/ClusterPerformance.py +2 -2
- validmind/tests/model_validation/sklearn/MinimumROCAUCScore.py +10 -3
- validmind/tests/model_validation/sklearn/OverfitDiagnosis.py +349 -291
- validmind/tests/model_validation/sklearn/PrecisionRecallCurve.py +1 -1
- validmind/tests/model_validation/sklearn/RobustnessDiagnosis.py +36 -37
- validmind/tests/ongoing_monitoring/FeatureDrift.py +182 -0
- validmind/tests/ongoing_monitoring/PredictionAcrossEachFeature.py +76 -0
- validmind/tests/ongoing_monitoring/PredictionCorrelation.py +91 -0
- validmind/tests/ongoing_monitoring/TargetPredictionDistributionPlot.py +57 -0
- validmind/unit_metrics/classification/sklearn/ROC_AUC.py +22 -1
- validmind/utils.py +1 -1
- validmind/vm_models/dataset/dataset.py +2 -1
- {validmind-2.4.13.dist-info → validmind-2.5.1.dist-info}/METADATA +1 -1
- {validmind-2.4.13.dist-info → validmind-2.5.1.dist-info}/RECORD +20 -16
- {validmind-2.4.13.dist-info → validmind-2.5.1.dist-info}/LICENSE +0 -0
- {validmind-2.4.13.dist-info → validmind-2.5.1.dist-info}/WHEEL +0 -0
- {validmind-2.4.13.dist-info → validmind-2.5.1.dist-info}/entry_points.txt +0 -0
validmind/__version__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "2.
|
1
|
+
__version__ = "2.5.1"
|
validmind/tests/__types__.py
CHANGED
@@ -113,6 +113,10 @@ TestID = Literal[
|
|
113
113
|
"validmind.model_validation.statsmodels.GINITable",
|
114
114
|
"validmind.model_validation.statsmodels.RegressionModelForecastPlot",
|
115
115
|
"validmind.model_validation.statsmodels.DurbinWatsonTest",
|
116
|
+
"validmind.ongoing_monitoring.PredictionCorrelation",
|
117
|
+
"validmind.ongoing_monitoring.PredictionAcrossEachFeature",
|
118
|
+
"validmind.ongoing_monitoring.FeatureDrift",
|
119
|
+
"validmind.ongoing_monitoring.TargetPredictionDistributionPlot",
|
116
120
|
"validmind.data_validation.MissingValuesRisk",
|
117
121
|
"validmind.data_validation.IQROutliersTable",
|
118
122
|
"validmind.data_validation.BivariateFeaturesBarPlots",
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
from dataclasses import dataclass
|
6
6
|
|
7
|
-
|
7
|
+
import numpy as np
|
8
8
|
from sklearn.metrics import classification_report, roc_auc_score
|
9
9
|
from sklearn.preprocessing import LabelBinarizer
|
10
10
|
|
@@ -71,7 +71,7 @@ class ClassifierPerformance(Metric):
|
|
71
71
|
When building a multi-class summary we need to calculate weighted average,
|
72
72
|
macro average and per class metrics.
|
73
73
|
"""
|
74
|
-
classes = {str(i) for i in unique(self.inputs.dataset.y)}
|
74
|
+
classes = {str(i) for i in np.unique(self.inputs.dataset.y)}
|
75
75
|
pr_f1_table = [
|
76
76
|
{
|
77
77
|
"Class": class_name,
|
@@ -126,9 +126,18 @@ class ClassifierPerformance(Metric):
|
|
126
126
|
output_dict=True,
|
127
127
|
zero_division=0,
|
128
128
|
)
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
)
|
129
|
+
|
130
|
+
y_true = self.inputs.dataset.y
|
131
|
+
|
132
|
+
if len(np.unique(y_true)) > 2:
|
133
|
+
y_pred = self.inputs.dataset.y_pred(self.inputs.model)
|
134
|
+
y_true = y_true.astype(y_pred.dtype)
|
135
|
+
roc_auc = self.multiclass_roc_auc_score(y_true, y_pred)
|
136
|
+
else:
|
137
|
+
y_prob = self.inputs.dataset.y_prob(self.inputs.model)
|
138
|
+
y_true = y_true.astype(y_prob.dtype).flatten()
|
139
|
+
roc_auc = roc_auc_score(y_true, y_prob)
|
140
|
+
|
141
|
+
report["roc_auc"] = roc_auc
|
133
142
|
|
134
143
|
return self.cache_results(report)
|
@@ -57,7 +57,7 @@ class ClusterPerformance(Metric):
|
|
57
57
|
"model_performance",
|
58
58
|
]
|
59
59
|
|
60
|
-
def
|
60
|
+
def cluster_performance_metrics(
|
61
61
|
self, y_true_train, y_pred_train, y_true_test, y_pred_test, samples, metric_info
|
62
62
|
):
|
63
63
|
y_true_train = y_true_train.astype(y_pred_train.dtype).flatten()
|
@@ -107,7 +107,7 @@ class ClusterPerformance(Metric):
|
|
107
107
|
y_true_test = y_true_test.astype(class_pred_test.dtype)
|
108
108
|
|
109
109
|
samples = ["train", "test"]
|
110
|
-
results = self.
|
110
|
+
results = self.cluster_performance_metrics(
|
111
111
|
y_true_train,
|
112
112
|
class_pred_train,
|
113
113
|
y_true_test,
|
@@ -5,6 +5,7 @@
|
|
5
5
|
from dataclasses import dataclass
|
6
6
|
from typing import List
|
7
7
|
|
8
|
+
import numpy as np
|
8
9
|
import pandas as pd
|
9
10
|
from sklearn import metrics, preprocessing
|
10
11
|
|
@@ -99,9 +100,15 @@ class MinimumROCAUCScore(ThresholdTest):
|
|
99
100
|
|
100
101
|
def run(self):
|
101
102
|
y_true = self.inputs.dataset.y
|
102
|
-
|
103
|
-
|
104
|
-
|
103
|
+
|
104
|
+
if len(np.unique(y_true)) > 2:
|
105
|
+
class_pred = self.inputs.dataset.y_pred(self.inputs.model)
|
106
|
+
y_true = y_true.astype(class_pred.dtype)
|
107
|
+
roc_auc = self.multiclass_roc_auc_score(y_true, class_pred)
|
108
|
+
else:
|
109
|
+
y_prob = self.inputs.dataset.y_prob(self.inputs.model)
|
110
|
+
y_true = y_true.astype(y_prob.dtype).flatten()
|
111
|
+
roc_auc = metrics.roc_auc_score(y_true, y_prob)
|
105
112
|
|
106
113
|
passed = roc_auc > self.params["min_threshold"]
|
107
114
|
results = [
|