VotingRegressor
Prediction voting regressor for unfitted estimators.
A voting regressor is an ensemble meta-estimator that fits several base regressors, each on the whole dataset. Then it averages the individual predictions to form a final prediction.
Read more in the User Guide.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new VotingRegressor(opts?: object): VotingRegressor;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.estimators? | any | Invoking the fit method on the VotingRegressor will fit clones of those original estimators that will be stored in the class attribute self.estimators\_ . An estimator can be set to 'drop' using set\_params . |
opts.n_jobs? | number | The number of jobs to run in parallel for fit . undefined means 1 unless in a joblib.parallel\_backend (opens in a new tab) context. \-1 means using all processors. See Glossary for more details. |
opts.verbose? | boolean | If true , the time elapsed while fitting will be printed as it is completed. Default Value false |
opts.weights? | ArrayLike | Sequence of weights (float or int ) to weight the occurrences of predicted values before averaging. Uses uniform weights if undefined . |
Returns
Defined in: generated/ensemble/VotingRegressor.ts:25 (opens in a new tab)
Methods
dispose()
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Signature
dispose(): Promise<void>;
Returns
Promise
<void
>
Defined in: generated/ensemble/VotingRegressor.ts:109 (opens in a new tab)
fit()
Fit the estimators.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Training vectors, where n\_samples is the number of samples and n\_features is the number of features. |
opts.sample_weight? | ArrayLike | Sample weights. If undefined , then samples are equally weighted. Note that this is supported only if all underlying estimators support sample weights. |
opts.y? | ArrayLike | Target values. |
Returns
Promise
<any
>
Defined in: generated/ensemble/VotingRegressor.ts:126 (opens in a new tab)
fit_transform()
Return class labels or probabilities for each estimator.
Return predictions for X for each estimator.
Signature
fit_transform(opts: object): Promise<any[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Input samples. |
opts.fit_params? | any | Additional fit parameters. |
opts.y? | ArrayLike | Target values (undefined for unsupervised transformations). |
Returns
Promise
<any
[]>
Defined in: generated/ensemble/VotingRegressor.ts:175 (opens in a new tab)
get_feature_names_out()
Get output feature names for transformation.
Signature
get_feature_names_out(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.input_features? | any | Not used, present here for API consistency by convention. |
Returns
Promise
<any
>
Defined in: generated/ensemble/VotingRegressor.ts:222 (opens in a new tab)
get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Signature
get_metadata_routing(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.routing? | any | A MetadataRequest encapsulating routing information. |
Returns
Promise
<any
>
Defined in: generated/ensemble/VotingRegressor.ts:260 (opens in a new tab)
init()
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Signature
init(py: PythonBridge): Promise<void>;
Parameters
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/ensemble/VotingRegressor.ts:65 (opens in a new tab)
predict()
Predict regression target for X.
The predicted regression target of an input sample is computed as the mean predicted regression targets of the estimators in the ensemble.
Signature
predict(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The input samples. |
Returns
Promise
<ArrayLike
>
Defined in: generated/ensemble/VotingRegressor.ts:297 (opens in a new tab)
score()
Return the coefficient of determination of the prediction.
The coefficient of determination \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y\_true \- y\_pred)\*\* 2).sum()
and \(v\) is the total sum of squares ((y\_true \- y\_true.mean()) \*\* 2).sum()
. The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y
, disregarding the input features, would get a \(R^2\) score of 0.0.
Signature
score(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n\_samples, n\_samples\_fitted) , where n\_samples\_fitted is the number of samples used in the fitting for the estimator. |
opts.sample_weight? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | True values for X . |
Returns
Promise
<number
>
Defined in: generated/ensemble/VotingRegressor.ts:332 (opens in a new tab)
set_fit_request()
Request metadata passed to the fit
method.
Note that this method is only relevant if enable\_metadata\_routing=True
(see sklearn.set\_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
Signature
set_fit_request(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight? | string | boolean | Metadata routing for sample\_weight parameter in fit . |
Returns
Promise
<any
>
Defined in: generated/ensemble/VotingRegressor.ts:383 (opens in a new tab)
set_output()
Set output container.
See Introducing the set_output API for an example on how to use the API.
Signature
set_output(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.transform? | "default" | "pandas" | Configure output of transform and fit\_transform . |
Returns
Promise
<any
>
Defined in: generated/ensemble/VotingRegressor.ts:420 (opens in a new tab)
set_score_request()
Request metadata passed to the score
method.
Note that this method is only relevant if enable\_metadata\_routing=True
(see sklearn.set\_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
Signature
set_score_request(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight? | string | boolean | Metadata routing for sample\_weight parameter in score . |
Returns
Promise
<any
>
Defined in: generated/ensemble/VotingRegressor.ts:457 (opens in a new tab)
transform()
Return predictions for X for each estimator.
Signature
transform(opts: object): Promise<ArrayLike[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The input samples. |
Returns
Promise
<ArrayLike
[]>
Defined in: generated/ensemble/VotingRegressor.ts:493 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/ensemble/VotingRegressor.ts:23 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/ensemble/VotingRegressor.ts:22 (opens in a new tab)
_py
PythonBridge
Defined in: generated/ensemble/VotingRegressor.ts:21 (opens in a new tab)
id
string
Defined in: generated/ensemble/VotingRegressor.ts:18 (opens in a new tab)
opts
any
Defined in: generated/ensemble/VotingRegressor.ts:19 (opens in a new tab)
Accessors
estimators_
The collection of fitted sub-estimators as defined in estimators
that are not ‘drop’.
Signature
estimators_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/ensemble/VotingRegressor.ts:526 (opens in a new tab)
feature_names_in_
Names of features seen during fit. Only defined if the underlying estimators expose such an attribute when fit.
Signature
feature_names_in_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/ensemble/VotingRegressor.ts:576 (opens in a new tab)
named_estimators_
Attribute to access any fitted sub-estimators by name.
Signature
named_estimators_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/ensemble/VotingRegressor.ts:551 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/ensemble/VotingRegressor.ts:52 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/ensemble/VotingRegressor.ts:56 (opens in a new tab)