qxmt.evaluation.metrics.defaults_classification module#
- class qxmt.evaluation.metrics.defaults_classification.Accuracy(name='accuracy')#
Bases:
BaseMetric
Accuracy metric class.
- Parameters:
BaseMetric (_type_) – Base metric class
name (str)
Examples
>>> import numpy as np >>> from qxmt.evaluation.defaults import Accuracy >>> metric = Accuracy() >>> metric.set_score(np.array([1, 0, 1]), np.array([1, 1, 1])) >>> metric.output_score() accuracy: 0.67
- __init__(name='accuracy')#
Initialize the accuracy metric.
- Parameters:
name (str, optional) – name of accuracy metric. Defaults to “accuracy”.
- Return type:
None
- static evaluate(actual, predicted, **kwargs)#
Evaluate the accuracy score.
- Parameters:
actual (np.ndarray) – numpy array of actual values
predicted (np.ndarray) – numpy array of predicted values
kwargs (Any)
- Returns:
accuracy score
- Return type:
float
- class qxmt.evaluation.metrics.defaults_classification.F1Score(name='f1_score')#
Bases:
BaseMetric
F1 score metric
- Parameters:
BaseMetric (_type_) – Base metric class
name (str)
Examples
>>> import numpy as np >>> from qxmt.evaluation.defaults import F1Score >>> metric = F1Score() >>> metric.set_score(np.array([1, 0, 1]), np.array([1, 1, 1])) >>> metric.output_score() f1_score: 0.8
- __init__(name='f1_score')#
Initialize the F1 score metric.
- Parameters:
name (str, optional) – name of f1-score metric. Defaults to “f1_score”.
- Return type:
None
- static evaluate(actual, predicted, **kwargs)#
Evaluate the F1 score.
- Parameters:
actual (np.ndarray) – numpy array of actual values
predicted (np.ndarray) – numpy array of predicted values
**kwargs (dict) – additional keyword arguments. The following options are supported: - average (str): define averaging method - pos_label (int): positive label for binary classification (default: max value)
- Returns:
F1 score
- Return type:
float
- class qxmt.evaluation.metrics.defaults_classification.Precision(name='precision')#
Bases:
BaseMetric
Precision metric class.
- Parameters:
BaseMetric (_type_) – Base metric class
name (str)
Examples
>>> import numpy as np >>> from qxmt.evaluation.defaults import Precision >>> metric = Precision() >>> metric.set_score(np.array([1, 0, 1]), np.array([1, 1, 1])) >>> metric.output_score() precision: 0.67
- __init__(name='precision')#
Initialize the precision metric.
- Parameters:
name (str, optional) – name of precision metric. Defaults to “precision”.
- Return type:
None
- static evaluate(actual, predicted, **kwargs)#
Evaluate the precision score.
- Parameters:
actual (np.ndarray) – numpy array of actual values
predicted (np.ndarray) – numpy array of predicted values
**kwargs (dict) – additional keyword arguments. The following options are supported: - average (str): define averaging method - pos_label (int): positive label for binary classification (default: max value)
- Returns:
precision score
- Return type:
float
- class qxmt.evaluation.metrics.defaults_classification.Recall(name='recall')#
Bases:
BaseMetric
Recall metric class.
- Parameters:
BaseMetric (_type_) – Base metric class
name (str)
Examples
>>> import numpy as np >>> from qxmt.evaluation.defaults import Recall >>> metric = Recall() >>> metric.set_score(np.array([1, 0, 1]), np.array([1, 1, 1])) >>> metric.output_score() recall: 1.0
- __init__(name='recall')#
Initialize the recall metric.
- Parameters:
name (str, optional) – name of recall metric. Defaults to “recall”.
- Return type:
None
- static evaluate(actual, predicted, **kwargs)#
Evaluate the recall score.
- Parameters:
actual (np.ndarray) – numpy array of actual values
predicted (np.ndarray) – numpy array of predicted values
**kwargs (dict) – additional keyword arguments. The following options are supported: - average (str): define averaging method - pos_label (int): positive label for binary classification (default: max value)
- Returns:
recall score
- Return type:
float
- class qxmt.evaluation.metrics.defaults_classification.TargetAlignmet(name='target_alignment')#
Bases:
BaseMetric
- Parameters:
name (str)
- static evaluate(actual, predicted, **kwargs)#
define evaluation method for each metric.
- Parameters:
actual (np.ndarray) – array of actual value
predicted (np.ndarray) – array of predicted value
**kwargs (dict) – additional arguments
- Returns:
evaluated score
- Return type:
float