mojolearn.MultiOutputClassifier#
- class mojolearn.MultiOutputClassifier(estimator, *, n_jobs=None)[source]#
Bases:
_TreesWrapperBaseFit one classifier per label column.
Follows scikit-learn’s
MultiOutputClassifier:fitclonesestimatoronce per column ofY, encodes that column’s labels and fits the clone on them;predictstacks the decoded predictions andpredict_probareturns a list with one probability array per output. The columns fit one after another.- Parameters:
estimator (estimator) – A mojolearn classifier; it is cloned, never fitted in place.
n_jobs (None) – Only None is accepted; any other value raises
NotImplementedError.
- Variables:
Examples
>>> import numpy as np, mojolearn >>> rng = np.random.default_rng(0) >>> X = rng.random((1000, 8), dtype=np.float32) >>> Y = np.stack([X[:, 0] > 0.5, X[:, 1] > 0.5], axis=1).astype(np.int64) >>> model = mojolearn.MultiOutputClassifier(mojolearn.DecisionTreeClassifier()).fit(X, Y) >>> model.predict(X[:5]).shape (5, 2)
Methods
fit(X, Y[, sample_weight])Fit one clone of
estimatorper label column ofY.get_params([deep])numeric_mode_used()The numeric mode this estimator runs in.
predict(X)Predict every output's labels.
Every output's class probabilities.
set_params(**params)Set constructor parameters.
vendor_used()The GPU backend this estimator runs on.
- fit(X, Y, sample_weight=None)[source]#
Fit one clone of
estimatorper label column ofY.- Parameters:
X (array of shape (n_samples, n_features)) – Training data, converted to float32.
Y (array of shape (n_samples, n_outputs)) – Class labels, one column per output. A row count that differs from
XraisesValueError.sample_weight (array of shape (n_samples,), default None) – Passed to every clone’s
fitwhen given.
- Returns:
self