2D matrix for labelbinarizer
I think the documentation is kind of self-explanatory here. Fit takes in array of size n_samples in which each element is the class of the datum or if the data point belongs to multiple classes, the input would be obviously of size n_samples x n_classes. That is what you gave in as input in your example. Each point can belong to any of the three classes. That is why you have [0, 1, 2] as number of classes. So as mentioned in the documentation if you try

&gt;&gt; lb.transform([0, 1, 2, 0])
[[1 0 0]
 [0 1 0]
 [0 0 1]
 [1 0 0]]


and if you try a class that is non-existent after fit like

&gt;&gt; lb.transform([0, 1, 2, 1000])
[[1 0 0]
 [0 1 0]
 [0 0 1]
 [0 0 0]]


No class named 1000 exists, so multi-targeted conversion for 1000 class case is plainly [0, 0, 0]. Hope this helps.