mojolearn.VotingRegressor#
- class mojolearn.VotingRegressor(estimators, *, weights=None, n_jobs=None, verbose=False)[source]#
Bases:
_TreesWrapperBaseAverage the predictions of several regressors.
Follows scikit-learn’s
VotingRegressor.fitclones every estimator and fits the clones; the estimators you pass are never fitted in place.predictis the weighted average of the members’ predictions. The members fit one after another.- Parameters:
estimators (list of (str, estimator)) – Named mojolearn regressors. Names must be unique; an entry whose estimator is the string
"drop"is skipped. An empty list, duplicate names, or every entry"drop"raiseValueError.weights (sequence of float, default None) – One weight per active estimator; None weighs them equally. A length that does not match the active estimators raises
ValueErrorinpredict.n_jobs (None) – Only None is accepted; any other value raises
NotImplementedError.verbose (bool, default False) – Only False is accepted; True raises
NotImplementedError.
- Variables:
Examples
>>> import numpy as np, mojolearn >>> rng = np.random.default_rng(0) >>> X = rng.random((1000, 8), dtype=np.float32) >>> y = X @ np.arange(8, dtype=np.float32) >>> model = mojolearn.VotingRegressor( ... [("rf", mojolearn.RandomForestRegressor()), ... ("dt", mojolearn.DecisionTreeRegressor())]).fit(X, y) >>> model.predict(X[:5]).shape (5,)
Methods
fit(X, y[, sample_weight])Fit a clone of every active estimator on
Xandy.get_params([deep])numeric_mode_used()The numeric mode this estimator runs in.
predict(X)Weighted average of the members' predictions.
set_params(**params)Set constructor parameters.
transform(X)Every member's prediction side by side.
vendor_used()The GPU backend this estimator runs on.
- fit(X, y, sample_weight=None)[source]#
Fit a clone of every active estimator on
Xandy.- Parameters:
X (array of shape (n_samples, n_features)) – Training data, converted to float32.
y (array of shape (n_samples,)) – Targets.
sample_weight (array of shape (n_samples,), default None) – Passed to every member’s
fitwhen given.
- Returns:
self