PoissonRegressor
Generalized Linear Model with a Poisson distribution.
This regressor uses the ‘log’ link function.
Read more in the User Guide.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new PoissonRegressor(opts?: object): PoissonRegressor;
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.max_iter? | number | The maximal number of iterations for the solver. Values must be in the range \[1, inf) . Default Value 100 |
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/PoissonRegressor.ts:25 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/linear_model/PoissonRegressor.ts:23 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/linear_model/PoissonRegressor.ts:22 (opens in a new tab)
_py
PythonBridge
Defined in: generated/linear_model/PoissonRegressor.ts:21 (opens in a new tab)
id
string
Defined in: generated/linear_model/PoissonRegressor.ts:18 (opens in a new tab)
opts
any
Defined in: generated/linear_model/PoissonRegressor.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/PoissonRegressor.ts:294 (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/PoissonRegressor.ts:375 (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/PoissonRegressor.ts:321 (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/PoissonRegressor.ts:348 (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/PoissonRegressor.ts:402 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/linear_model/PoissonRegressor.ts:79 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/linear_model/PoissonRegressor.ts:83 (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/PoissonRegressor.ts:140 (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/PoissonRegressor.ts:157 (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/PoissonRegressor.ts:92 (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/PoissonRegressor.ts:206 (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/PoissonRegressor.ts:245 (opens in a new tab)