-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
membership_matrix()
function to pyss3.util (#5)
This function converts the list of training/test labels (i.e., y_train/y_test) into a membership matrix. This function is useful when working with multi-label classification problems and it is meant to be used only internally by the evaluation module (the ``Evaluation`` class). However, in case users want to perform model evaluations using custom evaluation metrics, they could use this function as shown in the following example, in which the performance will be measured in terms of Hamming loss: ``` from pyss3 import SS3 from pyss3.util import Dataset, membership_matrix from sklearn.metrics import hamming_loss x_train, y_train = Dataset.load_from_files_multilabel(...) x_test, y_test = Dataset.load_from_files_multilabel(...) clf = SS3() clf.train(x_train, y_train) y_pred = clf.predict(x_test, multilabel=True) y_test_mem = membership_matrix(clf, y_test) y_pred_mem = membership_matrix(clf, y_pred) hamming_loss(y_test_mem, y_pred_mem) ``` Documentation available here: https://pyss3.rtfd.io/en/latest/api/index.html#pyss3.util.membership_matrix
- Loading branch information
1 parent
444e9bc
commit 983bc5a
Showing
2 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters