[英]2D matrix for labelbinarizer
There is one behavior of labelbinarizer labelbinarizer有一种行为
import numpy as np
from sklearn import preprocessing
lb = preprocessing.LabelBinarizer()
lb.fit(np.array([[0, 1, 1], [1, 0, 0]]))
lb.classes_
The output is array([0, 1, 2])
. 输出为
array([0, 1, 2])
。 Why there is a 2 there? 为什么那里有2?
Because you have passed a 2-d label-indicator matrix. 因为您已经传递了二维标签指示器矩阵。
A label indicator matrix is mostly used in multi-label problems where more than one labels can be present for a sample. 标签指示符矩阵主要用于多标签问题,其中一个样本可以包含多个标签。 So how do we represent them:
那么我们如何代表他们:
class 1 class 2 class 3
sample1 0 1 1
sample2 1 0 0
sample3
...
0 means the label is not present and 1 means thats present. 0表示不存在标签,1表示存在。 So for your current supplied matrix how many classes are there?
那么对于您当前提供的矩阵,有多少个类? -- 3
-3
So they are represented using 0,1,2. 因此它们用0,1,2表示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.