Skip to content

Commit

Permalink
add a weight=1.0 in all methods add_result. (Issue scikit-multiflow#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
giba0 committed Nov 3, 2018
1 parent 8782a17 commit 3fb437a
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions src/skmultiflow/metrics/measure_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def reset(self):
self.majority_classifier_correction = FastBuffer(self.window_size)
self.correct_no_change_correction = FastBuffer(self.window_size)

def add_result(self, y_true, y_pred):
def add_result(self, y_true, y_pred, weight=1.0):
""" Updates its statistics with the results of a prediction.
If needed it will remove samples from the observation window.
Expand All @@ -339,7 +339,10 @@ def add_result(self, y_true, y_pred):
y_pred: int
The classifier's prediction
weight: float
Sample's weight
"""
check_weights(weight)
true_y = self._get_target_index(y_true, True)
pred = self._get_target_index(y_pred, True)
old_true = self.true_labels.add_element(np.array([y_true]))
Expand Down Expand Up @@ -592,7 +595,7 @@ def reset(self):
self.exact_match_count = 0
self.j_sum = 0

def add_result(self, y_true, y_pred):
def add_result(self, y_true, y_pred, weight=1.0):
""" Updates its statistics with the results of a prediction.
Adds the result to the MOLConfusionMatrix and update exact_matches and
Expand All @@ -606,7 +609,11 @@ def add_result(self, y_true, y_pred):
y_pred: list or numpy.ndarray
The classifier's prediction
weight: float
Sample's weight
"""
check_weights(weight)
self.last_true_label = y_true
self.last_prediction = y_pred
m = 0
Expand Down Expand Up @@ -779,7 +786,7 @@ def reset(self):
self.true_labels = FastComplexBuffer(self.window_size, self.n_targets)
self.predictions = FastComplexBuffer(self.window_size, self.n_targets)

def add_result(self, y_true, y_pred):
def add_result(self, y_true, y_pred, weight=1.0):
""" Updates its statistics with the results of a prediction.
Adds the result to the MOLConfusionMatrix, and updates the
Expand All @@ -793,7 +800,11 @@ def add_result(self, y_true, y_pred):
y_pred: list or numpy.ndarray
The classifier's prediction
weight: float
Sample's weight
"""
check_weights(weight)
self.last_true_label = y_true
self.last_prediction = y_pred
m = 0
Expand Down Expand Up @@ -916,7 +927,7 @@ def reset(self):
self.last_true_label = None
self.last_prediction = None

def add_result(self, y_true, y_pred):
def add_result(self, y_true, y_pred, weight=1.0):
""" Use the true value and the prediction to update the statistics.
Parameters
Expand All @@ -927,7 +938,11 @@ def add_result(self, y_true, y_pred):
y_pred: float
The predicted value.
weight: float
Sample's weight
"""
check_weights(weight)
self.last_true_label = y_true
self.last_prediction = y_pred

Expand Down Expand Up @@ -1005,7 +1020,7 @@ def reset(self):
self.total_square_error_correction = FastBuffer(self.window_size)
self.average_error_correction = FastBuffer(self.window_size)

def add_result(self, y_true, y_pred):
def add_result(self, y_true, y_pred, weight=1.0):
""" Use the true value and the prediction to update the statistics.
Parameters
Expand All @@ -1016,7 +1031,11 @@ def add_result(self, y_true, y_pred):
y_pred: float
The predicted value.
weight: float
Sample's weight
"""
check_weights(weight)
self.last_true_label = y_true
self.last_prediction = y_pred
self.total_square_error += (y_true - y_pred) * (y_true - y_pred)
Expand Down Expand Up @@ -1102,7 +1121,7 @@ def reset(self):
self.last_true_label = None
self.last_prediction = None

def add_result(self, y, prediction):
def add_result(self, y, prediction, weight=1.0):
""" Use the true value and the prediction to update the statistics.
Parameters
Expand All @@ -1115,7 +1134,12 @@ def add_result(self, y, prediction):
prediction: float or list or np.ndarray
The predicted value(s).
weight: float
Sample's weight
"""
check_weights(weight)
self.last_true_label = y
self.last_prediction = prediction

Expand Down Expand Up @@ -1220,7 +1244,7 @@ def reset(self):
self.total_square_error_correction = FastBuffer(self.window_size)
self.average_error_correction = FastBuffer(self.window_size)

def add_result(self, y, prediction):
def add_result(self, y, prediction, weight=1.0):
""" Use the true value and the prediction to update the statistics.
Parameters
Expand All @@ -1233,7 +1257,12 @@ def add_result(self, y, prediction):
prediction: float or list or np.ndarray
The predicted value(s).
weight: float
Sample's weight
"""
check_weights(weight)
self.last_true_label = y
self.last_prediction = prediction

Expand Down

0 comments on commit 3fb437a

Please sign in to comment.