---
title: "Poisson, Gamma, and Tweedie Regression in JavaScript"
description: "Model counts and positive skewed targets with PoissonRegressor, GammaRegressor, and TweedieRegressor in browser or Node.js."
canonical_url: "https://ml.kanaries.net/docs/apis/linear/generalizedLinearModels"
markdown_url: "https://ml.kanaries.net/docs/apis/linear/generalizedLinearModels.md"
---
# Generalized linear models in JavaScript

## Algorithm overview

Generalized linear models connect a linear predictor to non-Gaussian targets. Poisson regression is suited to counts, Gamma regression to positive continuous values, and Tweedie regression spans several variance relationships through its `power` parameter.

## JavaScript implementation

The `@kanaries/ml` implementations use regularized Newton updates and a guarded line search, with log links for positive-mean families.

## Interactive generalized linear model playground

Switch between Poisson, Gamma, and Tweedie regression, tune regularization, and add positive-valued observations. The prediction is refitted live with the chosen `Linear` estimator.

> The HTML version includes an interactive Generalized Linear Models playground powered by @kanaries/ml. You can change the dataset, noise, and model controls; add observations; and inspect live predictions plus train and holdout metrics. The runnable guide and API reference continue below. [Open the HTML page](https://ml.kanaries.net/docs/apis/linear/generalizedLinearModels).

## Quick start

```ts
import { Linear } from '@kanaries/ml';

const model = new Linear.PoissonRegressor({ alpha: 0.1 });
model.fit([[0], [1], [2]], [1, 2, 4]);
console.log(model.predict([[3]]));
```

## Detailed API reference

All three accept `alpha`, `fitIntercept`, `maxIter`, and `tol`. Poisson and Gamma regression use their canonical log link. `TweedieRegressor` additionally accepts `power` (values in `(0, 1)` are undefined) and `link: 'auto' | 'identity' | 'log'`. Fitted models expose `coef`, `intercept`, and `nIter`.
