quantificationlib.metrics.ordinal module¶
Score functions and loss functions for ordinal quantification problems
- emd(p_true, p_pred)[source]¶
Return the EMD distance between two sets of prevalences
- Parameters:
p_true (array-like, shape (n_classes, 1)) –
p_pred (array-like, shape (n_classes, 1)) –
- Returns:
emd – The EMD distance between p_true and p_pred
- Return type:
float
- emd_distances(A, B)[source]¶
Return the EMD distances between the rows of A and B
- Parameters:
A (array-like, shape (n_samples_1, n_features)) –
B (array-like, shape (n_samples_2, n_features)) –
columns (A and B should have the same number of) –
- Returns:
distances
- Return type:
array, shape (n_samples_1, n_samples_2)
- emd_score(p_true, p_pred)[source]¶
Scoring metric based on EMD distance
- Parameters:
p_true (array-like, shape (n_classes, 1)) –
p_pred (array-like, shape (n_classes, 1)) –
- Returns:
emds – The EMD score
- Return type:
float
References
Castaño, A., González, P., González, J. A., & Del Coz, J. J. (2022). Matching Distributions Algorithms Based on the Earth Mover’s Distance for Ordinal Quantification. IEEE Transactions on Neural Networks and Learning Systems.