Skip to content

Commit

Permalink
remove unused confidence_deviation properties (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikml authored Feb 7, 2024
1 parent 718a898 commit 1422a0e
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions nannyml/performance_estimation/confidence_based/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ def __init__(
self.lower_threshold_value_limit: Optional[float] = lower_threshold_value_limit
self.upper_threshold_value_limit: Optional[float] = upper_threshold_value_limit

self.confidence_deviation: Optional[float] = None

self.uncalibrated_y_pred_proba = f'uncalibrated_{self.y_pred_proba}'

self.confidence_upper_bound: Optional[float] = 1.0
Expand Down Expand Up @@ -163,9 +161,6 @@ def fit(self, reference_data: pd.DataFrame):

reference_chunks = self.chunker.split(reference_data)

# Calculate confidence bands
self.confidence_deviation = self._confidence_deviation(reference_chunks)

# Calculate alert thresholds
reference_chunk_results = np.asarray([self._realized_performance(chunk.data) for chunk in reference_chunks])
self.lower_threshold_value, self.upper_threshold_value = calculate_threshold_values(
Expand Down Expand Up @@ -196,9 +191,6 @@ def _sampling_error(self, data: pd.DataFrame) -> float:
f"'{self.__class__.__name__}' is a subclass of Metric and it must implement the _sampling_error method"
)

def _confidence_deviation(self, reference_chunks: List[Chunk]):
return np.std([self._estimate(chunk.data) for chunk in reference_chunks])

@abc.abstractmethod
def _realized_performance(self, data: pd.DataFrame) -> float:
raise NotImplementedError(
Expand Down Expand Up @@ -2151,9 +2143,6 @@ def fit(self, reference_data: pd.DataFrame): # override the superclass fit meth

self.alert_thresholds = self._multiclass_confusion_matrix_alert_thresholds(reference_chunks)

# Calculate confidence bands
self.confidence_deviations = self._multiclass_confusion_matrix_confidence_deviations(reference_chunks)

# Delegate to confusion matrix subclass
self._fit(reference_data) # could probably put _fit functionality here since overide fit method

Expand Down Expand Up @@ -2211,22 +2200,6 @@ def _multi_class_confusion_matrix_realized_performance(self, data: pd.DataFrame)

return cm

def _multiclass_confusion_matrix_confidence_deviations(
self,
reference_chunks: List[Chunk],
) -> Dict[str, float]:
confidence_deviations = {}

num_classes = len(self.classes)

for i in range(num_classes):
for j in range(num_classes):
confidence_deviations[f'true_{self.classes[i]}_pred_{self.classes[j]}'] = np.std(
[self._get_multiclass_confusion_matrix_estimate(chunk.data)[i, j] for chunk in reference_chunks]
)

return confidence_deviations

def _get_multiclass_confusion_matrix_estimate(self, chunk_data: pd.DataFrame) -> np.ndarray:
if isinstance(self.y_pred_proba, str):
raise ValueError(
Expand Down

0 comments on commit 1422a0e

Please sign in to comment.