linear_model.LogisticRegression
Usage
import { LogisticRegression } from 'machinelearn/linear_model';
import { HeartDisease } from 'machinelearn/datasets';
(async function() {
  const { data, targets } = await heartDisease.load();
  const { xTest, xTrain, yTest } = train_test_split(data, targets);
  const lr = new LogisticRegression();
  lr.fit(xTrain, yTrain);
  lr.predict(yTest);
});
Constructors
Methods
Constructors
constructor
⊕ LogisticRegression(__namedParameters: `object`)
Defined in linear_model/logistic_regression.ts:42
Parameters:
| Param | Type | Default | Description | 
|---|---|---|---|
| options.learning_rate | number | 0.001 | |
| options.num_iterations | number | 4000 | 
Returns: LogisticRegression
Methods
λ fit
Fit the model according to the given training data.
Defined in linear_model/logistic_regression.ts:63
Parameters:
| Param | Type | Default | Description | 
|---|---|---|---|
| X | number[] or number[][] | null | A matrix of samples | 
| y | number[] | null | A matrix of targets | 
Returns:
void
λ fromJSON
Restore the model from a checkpoint
Defined in linear_model/logistic_regression.ts:114
Parameters:
| Param | Type | Default | Description | 
|---|---|---|---|
| options.learning_rate | number | null | |
| options.weights | number[] | null | 
Returns:
void
λ predict
Predict class labels for samples in X.
Defined in linear_model/logistic_regression.ts:83
Parameters:
| Param | Type | Default | Description | 
|---|---|---|---|
| X | number[] or number[][] | null | A matrix of test data | 
Returns:
number[]
λ toJSON
Get the model details in JSON format
Defined in linear_model/logistic_regression.ts:95
Returns:
| Param | Type | Description | 
|---|---|---|
| learning_rate | number | Model learning rate | 
| weights | number[] | Model training weights |