mojolearn.MultiOutputClassifier#
- class mojolearn.MultiOutputClassifier(estimator, *, n_jobs=None)#
Fit 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])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.
The GPU backend this estimator runs on.
- fit(X, Y, sample_weight=None)#
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
- predict(X)#
Predict every output’s labels.
- Returns:
array of shape (n_samples, n_outputs) – For numeric labels, int64 when every output’s labels are integers, else float64.
- predict_proba(X)#
Every output’s class probabilities.
- Returns:
list of arrays – One float64 array of shape (n_samples, n_classes_j) per output, its columns in the order of
classes_[j].
- numeric_mode_used()#
The numeric mode this estimator runs in.
- Returns:
str –
'identical'or'fast', read from the compiled binary the estimator uses, not from the argument it was given.
- set_params(**params)#
Set constructor parameters. The estimator is rebuilt through its constructor, so every constructor check runs again and any fitted state is dropped, as a new setting invalidates it.
- vendor_used()#
The GPU backend this estimator runs on.
- Returns:
str –
'metal','cuda'or'hip', read from the compiled binary the estimator uses.