mojolearn.MultiOutputRegressor#
- class mojolearn.MultiOutputRegressor(estimator, *, n_jobs=None)[source]#
Bases:
_TreesWrapperBaseFit one regressor per target column.
Follows scikit-learn’s
MultiOutputRegressor:fitclonesestimatoronce per column ofYand fits each clone on that column;predictstacks their predictions. The columns fit one after another.- Parameters:
estimator (estimator) – A mojolearn regressor; 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] + X[:, 1], X[:, 2] - X[:, 3]], axis=1) >>> model = mojolearn.MultiOutputRegressor(mojolearn.Ridge()).fit(X, Y) >>> model.predict(X[:5]).shape (5, 2)
Methods
fit(X, Y[, sample_weight])Fit one clone of
estimatorper column ofY.get_params([deep])numeric_mode_used()The numeric mode this estimator runs in.
predict(X)Every target's prediction, one column per output.
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 column ofY.- Parameters:
X (array of shape (n_samples, n_features)) – Training data, converted to float32.
Y (array of shape (n_samples, n_outputs)) – Numeric targets, converted to float32. 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