Class: TweedieRegressor
Generalized Linear Model with a Tweedie distribution.
This estimator can be used to model different GLMs depending on the power
parameter, which determines the underlying distribution.
Read more in the User Guide.
Constructors
new TweedieRegressor()
new TweedieRegressor(
opts
?):TweedieRegressor
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.alpha ? | number | Constant that multiplies the L2 penalty term and determines the regularization strength. alpha \= 0 is equivalent to unpenalized GLMs. In this case, the design matrix X must have full column rank (no collinearities). Values of alpha must be in the range \[0.0, inf) . |
opts.fit_intercept ? | boolean | Specifies if a constant (a.k.a. bias or intercept) should be added to the linear predictor (X @ coef + intercept ). |
opts.link ? | "auto" | "log" | "identity" | The link function of the GLM, i.e. mapping from linear predictor X @ coeff + intercept to prediction y_pred . Option ‘auto’ sets the link depending on the chosen power parameter as follows: |
opts.max_iter ? | number | The maximal number of iterations for the solver. Values must be in the range \[1, inf) . |
opts.power ? | number | The power determines the underlying target distribution according to the following table: |
opts.solver ? | "lbfgs" | "newton-cholesky" | Algorithm to use in the optimization problem: |
opts.tol ? | number | Stopping criterion. For the lbfgs solver, the iteration will stop when `max{ |
opts.verbose ? | number | For the lbfgs solver set verbose to any positive number for verbosity. Values must be in the range \[0, inf) . |
opts.warm_start ? | boolean | If set to true , reuse the solution of the previous call to fit as initialization for coef_ and intercept_ . |
Returns TweedieRegressor
Defined in generated/linear_model/TweedieRegressor.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/linear_model/TweedieRegressor.ts:23 |
_isInitialized | boolean | false | generated/linear_model/TweedieRegressor.ts:22 |
_py | PythonBridge | undefined | generated/linear_model/TweedieRegressor.ts:21 |
id | string | undefined | generated/linear_model/TweedieRegressor.ts:18 |
opts | any | undefined | generated/linear_model/TweedieRegressor.ts:19 |
Accessors
coef_
Get Signature
get coef_():
Promise
<any
[]>
Estimated coefficients for the linear predictor (X @ coef_ + intercept_
) in the GLM.
Returns Promise
<any
[]>
Defined in generated/linear_model/TweedieRegressor.ts:408
feature_names_in_
Get Signature
get feature_names_in_():
Promise
<ArrayLike
>
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Returns Promise
<ArrayLike
>
Defined in generated/linear_model/TweedieRegressor.ts:516
intercept_
Get Signature
get intercept_():
Promise
<number
>
Intercept (a.k.a. bias) added to linear predictor.
Returns Promise
<number
>
Defined in generated/linear_model/TweedieRegressor.ts:435
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/linear_model/TweedieRegressor.ts:489
n_iter_
Get Signature
get n_iter_():
Promise
<number
>
Actual number of iterations used in the solver.
Returns Promise
<number
>
Defined in generated/linear_model/TweedieRegressor.ts:462
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/linear_model/TweedieRegressor.ts:93
Methods
dispose()
dispose():
Promise
<void
>
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Returns Promise
<void
>
Defined in generated/linear_model/TweedieRegressor.ts:147
fit()
fit(
opts
):Promise
<any
>
Fit a Generalized Linear Model.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample weights. |
opts.X ? | ArrayLike | Training data. |
opts.y ? | ArrayLike | Target values. |
Returns Promise
<any
>
Defined in generated/linear_model/TweedieRegressor.ts:164
get_metadata_routing()
get_metadata_routing(
opts
):Promise
<any
>
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRequest encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/linear_model/TweedieRegressor.ts:210
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/linear_model/TweedieRegressor.ts:106
predict()
predict(
opts
):Promise
<any
[]>
Predict using GLM with feature matrix X.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | Samples. |
Returns Promise
<any
[]>
Defined in generated/linear_model/TweedieRegressor.ts:246
score()
score(
opts
):Promise
<number
>
Compute D^2, the percentage of deviance explained.
D^2 is a generalization of the coefficient of determination R^2. R^2 uses squared error and D^2 uses the deviance of this GLM, see the User Guide.
D^2 is defined as \(D^2 = 1-\frac{D(y_{true},y_{pred})}{D_{null}}\), \(D_{null}\) is the null deviance, i.e. the deviance of a model with intercept alone, which corresponds to \(y_{pred} = \bar{y}\). The mean \(\bar{y}\) is averaged by sample_weight. Best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse).
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample weights. |
opts.X ? | ArrayLike | Test samples. |
opts.y ? | ArrayLike | True values of target. |
Returns Promise
<number
>
Defined in generated/linear_model/TweedieRegressor.ts:284
set_fit_request()
set_fit_request(
opts
):Promise
<any
>
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:
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in fit . |
Returns Promise
<any
>
Defined in generated/linear_model/TweedieRegressor.ts:332
set_score_request()
set_score_request(
opts
):Promise
<any
>
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:
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in score . |
Returns Promise
<any
>