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.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new TweedieRegressor(opts?: object): TweedieRegressor;
Parameters
Name | 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) . Default Value 1 |
opts.fit_intercept? | boolean | Specifies if a constant (a.k.a. bias or intercept) should be added to the linear predictor (X @ coef + intercept ). Default Value true |
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: Default Value 'auto' |
opts.max_iter? | number | The maximal number of iterations for the solver. Values must be in the range \[1, inf) . Default Value 100 |
opts.power? | number | The power determines the underlying target distribution according to the following table: Default Value 0 |
opts.solver? | "lbfgs" | "newton-cholesky" | Algorithm to use in the optimization problem: Default Value 'lbfgs' |
opts.tol? | number | Stopping criterion. For the lbfgs solver, the iteration will stop when max{|g\_j|, j \= 1, ..., d} <= tol where g\_j is the j-th component of the gradient (derivative) of the objective function. Values must be in the range (0.0, inf) . Default Value 0.0001 |
opts.verbose? | number | For the lbfgs solver set verbose to any positive number for verbosity. Values must be in the range \[0, inf) . Default Value 0 |
opts.warm_start? | boolean | If set to true , reuse the solution of the previous call to fit as initialization for coef\_ and intercept\_ . Default Value false |
Returns
Defined in: generated/linear_model/TweedieRegressor.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/linear_model/TweedieRegressor.ts:156 (opens in a new tab)
fit()
Fit a Generalized Linear Model.
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/linear_model/TweedieRegressor.ts:173 (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/linear_model/TweedieRegressor.ts:224 (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/linear_model/TweedieRegressor.ts:106 (opens in a new tab)
predict()
Predict using GLM with feature matrix X.
Signature
predict(opts: object): Promise<any[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Samples. |
Returns
Promise
<any
[]>
Defined in: generated/linear_model/TweedieRegressor.ts:261 (opens in a new tab)
score()
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).
Signature
score(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Test samples. |
opts.sample_weight? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | True values of target. |
Returns
Promise
<number
>
Defined in: generated/linear_model/TweedieRegressor.ts:300 (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/linear_model/TweedieRegressor.ts:353 (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/linear_model/TweedieRegressor.ts:395 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/linear_model/TweedieRegressor.ts:23 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/linear_model/TweedieRegressor.ts:22 (opens in a new tab)
_py
PythonBridge
Defined in: generated/linear_model/TweedieRegressor.ts:21 (opens in a new tab)
id
string
Defined in: generated/linear_model/TweedieRegressor.ts:18 (opens in a new tab)
opts
any
Defined in: generated/linear_model/TweedieRegressor.ts:19 (opens in a new tab)
Accessors
coef_
Estimated coefficients for the linear predictor (X @ coef\_ + intercept\_
) in the GLM.
Signature
coef_(): Promise<any[]>;
Returns
Promise
<any
[]>
Defined in: generated/linear_model/TweedieRegressor.ts:433 (opens in a new tab)
feature_names_in_
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Signature
feature_names_in_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/linear_model/TweedieRegressor.ts:541 (opens in a new tab)
intercept_
Intercept (a.k.a. bias) added to linear predictor.
Signature
intercept_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/linear_model/TweedieRegressor.ts:460 (opens in a new tab)
n_features_in_
Number of features seen during fit.
Signature
n_features_in_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/linear_model/TweedieRegressor.ts:514 (opens in a new tab)
n_iter_
Actual number of iterations used in the solver.
Signature
n_iter_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/linear_model/TweedieRegressor.ts:487 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/linear_model/TweedieRegressor.ts:93 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/linear_model/TweedieRegressor.ts:97 (opens in a new tab)