validmind 2.4.13__py3-none-any.whl → 2.5.2__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "2.4.13"
1
+ __version__ = "2.5.2"
@@ -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
- from numpy import unique
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
- report["roc_auc"] = multiclass_roc_auc_score(
130
- self.inputs.dataset.y,
131
- self.inputs.dataset.y_pred(self.inputs.model),
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 cluser_performance_metrics(
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.cluser_performance_metrics(
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
- class_pred = self.inputs.dataset.y_pred(self.inputs.model)
103
- y_true = y_true.astype(class_pred.dtype)
104
- roc_auc = self.multiclass_roc_auc_score(y_true, class_pred)
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 = [