opfython.math.general¶
General-based mathematical methods.
- opfython.math.general.confusion_matrix(labels: Union[numpy.array, List[int]], preds: Union[numpy.array, List[int]])¶
Calculates the confusion matrix between true and predicted labels.
- Parameters
labels – List or numpy array holding the true labels.
preds – List or numpy array holding the predicted labels.
- Returns
The confusion matrix.
- Return type
(np.array)
- opfython.math.general.logger¶
- opfython.math.general.normalize(array: numpy.array)¶
Normalizes an input array.
- Parameters
array – Array to be normalized.
- Returns
The normalized version (between 0 and 1) of the input array.
- Return type
(np.array)
- opfython.math.general.opf_accuracy(labels: Union[numpy.array, List[int]], preds: Union[numpy.array, List[int]])¶
Calculates the accuracy between true and predicted labels using OPF-style measure.
- Parameters
labels – List or numpy array holding the true labels.
preds – List or numpy array holding the predicted labels.
- Returns
The OPF accuracy measure between 0 and 1.
- Return type
(float)
- opfython.math.general.opf_accuracy_per_label(labels: Union[numpy.array, List[int]], preds: Union[numpy.array, List[int]])¶
Calculates the accuracy per label between true and predicted labels using OPF-style measure.
- Parameters
labels – List or numpy array holding the true labels.
preds – List or numpy array holding the predicted labels.
- Returns
The OPF accuracy measure per label between 0 and 1.
- Return type
(float)
- opfython.math.general.pre_compute_distance(data: numpy.array, output: str, distance: Optional[str] = 'log_squared_euclidean')¶
Pre-computes a matrix of distances based on an input data.
- Parameters
data – Array of samples.
output – File to be saved.
distance – Distance metric to be used.
- opfython.math.general.purity(labels: Union[numpy.array, List[int]], preds: Union[numpy.array, List[int]])¶
Calculates the purity measure of an unsupervised technique.
- Parameters
labels – List or numpy array holding the true labels.
preds – List or numpy array holding the assigned labels by the clusters.
- Returns
The purity measure.
- Return type
(float)