def fit(self, y):
"""Fit simplex coding
Parameters
----------
targets : array, shape = [n_samples,] or [n_samples, n_classes]
Target values. The 2-d array represents the simplex coding for
multilabel classification.
Returns
-------
self : returns an instance of self.
"""
if self.binarizer is None:
self.binarizer_ = LabelBinarizer(neg_label=0, pos_label=1,
sparse_output=True)
self.binarizer_.fit(y)
dimension = self.binarizer_.classes_.size
if dimension > 2:
self.simplex_operator_ = SimplexCoding.code(dimension)
else:
self.simplex_operator_ = ones((1, 1))
return self
评论列表
文章目录