Created
May 2, 2017 05:09
-
-
Save spin-glass/dad8ba9fa8d641875c27c65813aaf8a3 to your computer and use it in GitHub Desktop.
2クラス分類時のone-hot label
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
from sklearn.preprocessing import LabelBinarizer, OneHotEncoder | |
label = ['a', 'b', 'a'] | |
binarized_label = LabelBinarizer().fit_transform(label) # [[1], [2], [2]] | |
# 以下は2クラスの場合のみ必要 | |
one-hot_label = OneHotEncoder().fit_transform(binarized_label).toarray() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment