Transform between iterable of iterables and a multilabel format.
Although a list of sets or tuples is a very intuitive format for multilabel
data, it is unwieldy to process. This transformer converts between this
intuitive format and the supported multilabel format: a (samples x classes)
binary matrix indicating the presence of a class label.
The method works on simple estimators as well as on nested objects
(such as Pipeline). The latter have
parameters of the form <component>__<parameter> so that it’s
possible to update each component of a nested object.
Parameters:
**params : dict
Estimator parameters.
Returns:
self : estimator instance
Estimator instance.
transform(y)
Transform the given label sets.
Parameters:
y : iterable of iterables
A set of labels (any orderable and hashable object) for each
sample. If the classes parameter is set, y will not be
iterated.
Returns:
y_indicator : array or CSR matrix, shape (n_samples, n_classes)
A matrix such that y_indicator[i,j]=1 iff classes_[j] is in
y[i], and 0 otherwise.