DummyRegressor
Regressor that makes predictions using simple rules.
This regressor is useful as a simple baseline to compare with other (real) regressors. Do not use it for real problems.
Read more in the User Guide.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new DummyRegressor(opts?: object): DummyRegressor;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.constant? | number | ArrayLike | The explicit constant as predicted by the “constant” strategy. This parameter is useful only for the “constant” strategy. |
opts.quantile? | number | The quantile to predict using the “quantile” strategy. A quantile of 0.5 corresponds to the median, while 0.0 to the minimum and 1.0 to the maximum. |
opts.strategy? | "quantile" | "constant" | "mean" | "median" | Strategy to use to generate predictions. Default Value 'mean' |
Returns
Defined in: generated/dummy/DummyRegressor.ts:25 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/dummy/DummyRegressor.ts:23 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/dummy/DummyRegressor.ts:22 (opens in a new tab)
_py
PythonBridge
Defined in: generated/dummy/DummyRegressor.ts:21 (opens in a new tab)
id
string
Defined in: generated/dummy/DummyRegressor.ts:18 (opens in a new tab)
opts
any
Defined in: generated/dummy/DummyRegressor.ts:19 (opens in a new tab)
Accessors
constant_
Mean or median or quantile of the training targets or constant value given by the user.
Signature
constant_(): Promise<ArrayLike[]>;
Returns
Promise
<ArrayLike
[]>
Defined in: generated/dummy/DummyRegressor.ts:257 (opens in a new tab)
n_outputs_
Number of outputs.
Signature
n_outputs_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/dummy/DummyRegressor.ts:282 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/dummy/DummyRegressor.ts:47 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/dummy/DummyRegressor.ts:51 (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/dummy/DummyRegressor.ts:102 (opens in a new tab)
fit()
Fit the random regressor.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Training data. |
opts.sample_weight? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | Target values. |
Returns
Promise
<any
>
Defined in: generated/dummy/DummyRegressor.ts:119 (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/dummy/DummyRegressor.ts:60 (opens in a new tab)
predict()
Perform classification on test vectors X.
Signature
predict(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Test data. |
opts.return_std? | boolean | Whether to return the standard deviation of posterior prediction. All zeros in this case. Default Value false |
Returns
Promise
<ArrayLike
>
Defined in: generated/dummy/DummyRegressor.ts:166 (opens in a new tab)
score()
Return the coefficient of determination R^2 of the prediction.
The coefficient R^2 is defined as (1 \- 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. Passing undefined as test samples gives the same result as passing real test samples, since DummyRegressor operates independently of the sampled observations. |
opts.sample_weight? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | True values for X. |
Returns
Promise
<number
>
Defined in: generated/dummy/DummyRegressor.ts:210 (opens in a new tab)