-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linear make prediction #256
Conversation
libmultilabel/linear/linear.py
Outdated
top_k_ind = np.argpartition(x, -top_k)[:, -top_k:] | ||
pred_result = np.zeros(x.shape) | ||
np.put_along_axis(pred_result, top_k_ind, 1, -1) | ||
pred_result[pred_result != 1] = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why line 588 as pred_result is initialized as the zero matrix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inverse_transform
has to take predictions in binary labels, so I first set pred_result to zero matrix and set the top k labels to 1. I realized that line 558 is redundant and removed it.
libmultilabel/linear/linear.py
Outdated
top_k_ind = np.argpartition(preds, -top_k)[:, -top_k:] | ||
pred_result = np.zeros(preds.shape) | ||
np.put_along_axis(pred_result, top_k_ind, 1, -1) | ||
return preprocessor.binarizer.inverse_transform(pred_result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where do we have this binarizer.inverse_transform defined??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we’re using sklearn’s MultiLabelBinarizer, I used this:
https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MultiLabelBinarizer.html
Co-authored-by: Jie-Jyun Liu <jiejyunliu@gmail.com>
c59d9d5
to
fc74eb0
Compare
…iLabel into Linear-make-prediction
@Sinacam review |
libmultilabel/linear/linear.py
Outdated
Returns: | ||
list of lists which contain top k labels. | ||
""" | ||
top_k_ind = np.argpartition(preds, -top_k)[:, -top_k:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
top_k_ind
is sorted ascending this way. top_k_ind = np.argpartition(preds, -top_k)[:, :top_k:-1]
sorts descending.
LGTM |
What does this PR do?
as title.
Test CLI & API (
bash tests/autotest.sh
)Test quickstart & API (
bash tests/docs/test_examples.sh
)Check API Document