mojolearn.MultiLabelBinarizer#
- class mojolearn.MultiLabelBinarizer(*, classes=None, sparse_output=False)[source]#
Bases:
_PrepBaseConvert sets of labels to a binary indicator matrix.
Follows scikit-learn’s
MultiLabelBinarizer.yis an iterable of label collections, one per sample.transformreturns an int32 matrix with a 1 where the sample has the class. A label not seen in fit is ignored (scikit-learn also warns). Numeric and string labels are supported.- Parameters:
classes (array-like, default None) – Class labels in the order of the output columns. None uses the sorted union of all labels in fit.
sparse_output (bool, default False) – Must be False; True raises
NotImplementedError.
- Variables:
Notes
inverse_transformreturns a list with one tuple of labels per row.Examples
>>> import mojolearn >>> mlb = mojolearn.MultiLabelBinarizer() >>> mlb.fit_transform([[1, 2], [3], [2, 3]])
Methods
fit(y)Fit to
X, then transformX.get_params([deep])Return the constructor parameters as a dict.
inverse_transform(yt)set_params(**params)Set constructor parameters.
transform(y)