API Reference - Models - NegativeBinomialRegression

NegativeBinomialRegression is a supervised machine learning model that predicts discrete count values (e.g. 1, 2, 3, 4). It uses iterative calculations to find the best model parameters.

Stored Model Parameters

Contains a matrix.

  • ModelParameters[I][J]: Value of matrix at row I and column J. The rows are the features.

Constructors

new()

Create new model object. If any of the arguments are nil, default argument values for that argument will be used.

NegativeBinomialRegression.new(maximumNumberOfIterations: integer, learningRate: number): ModelObject

Parameters:

  • maximumNumberOfIterations: How many times should the model needed to be trained.

  • learningRate: The speed at which the model learns. Recommended that the value is set between 0 to 1.

  • dispersion: Controls the model’s variance, allowing it to model count data with more variability. [Default: 0.5]

    • At high values, it makes the negative binomial distribution closer to Poisson.

    • A smaller dispersion increases variance, capturing extra spread in data common in biology, ecology, or health.

Returns:

  • ModelObject: The generated model object.

Functions

setOptimizer()

Set optimizer for the model by inputting the optimizer object.

NegativeBinomialRegression:setOptimizer(Optimizer: OptimizerObject)

Parameters:

  • Optimizer: The optimizer object to be used.

setRegularizer()

Set a regularization for the model by inputting the optimizer object.

NegativeBinomialRegression:setRegularizer(Regularizer: RegularizerObject)

Parameters:

  • setRegularizer: The regularizer to be used.

train()

Train the model.

NegativeBinomialRegression:train(featureMatrix: Matrix, labelVector: Matrix): number[]

Parameters:

  • featureMatrix: Matrix containing all data.

  • labelVector: A (n x 1) matrix containing values related to featureMatrix.

Returns:

  • costArray: An array containing cost values.

predict()

Predict the value for a given data.

NegativeBinomialRegression:predict(featureMatrix: Matrix): Matrix

Parameters:

  • featureMatrix: Matrix containing data.

Returns:

  • predictedVector: A vector containing values that are predicted by the model.

Inherited From


This site uses Just the Docs, a documentation theme for Jekyll.