mojolearn.MultiOutputRegressor#
- class mojolearn.MultiOutputRegressor(estimator, *, n_jobs=None)#
Fit 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])The numeric mode this estimator runs in.
predict(X)Every target's prediction, one column per output.
set_params(**params)Set constructor parameters.
The GPU backend this estimator runs on.
- fit(X, Y, sample_weight=None)#
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
- predict(X)#
Every target’s prediction, one column per output.
- Returns:
array of shape (n_samples, n_outputs)
- 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.