# ml-logistic-regression

> Logistic regression

Latest version **2.0.0** (published 2020-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install ml-logistic-regression
pnpm add ml-logistic-regression
yarn add ml-logistic-regression
bun add ml-logistic-regression
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-05-03 |
| First published | 2017-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | jajoe |
| Maintainers | jeffersonh44, jwist, lpatiny, maasencioh, stropitek, targos |
| Keywords | machine learning, logistic regression, classification, classifier |

## Links

- npm: https://www.npmjs.com/package/ml-logistic-regression
- Repository: https://github.com/mljs/logistic-regression
- Homepage: https://github.com/mljs/logistic-regression#readme
- Issues: https://github.com/mljs/logistic-regression/issues
- npm.io page: https://npm.io/package/ml-logistic-regression

## Dependencies (1)

- [ml-matrix](https://npm.io/package/ml-matrix.md) ^6.5.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2020-05-03
- 1.0.2 — 2017-07-21
- 1.0.1 — 2017-07-21
- 1.0.0 — 2017-07-21

## README

# logistic-regression

[![NPM version][npm-image]][npm-url]
[![build status][ci-image]][ci-url]
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]

This is an implementation of the logistic regression. When there are more than 2 classes, the method used is the _One VS All_.

## Installation

`$ npm i ml-logistic-regression`

## Usage

```js
const { Matrix } = require('ml-matrix');

// Our training set (X,Y).
const X = new Matrix([[0, -1], [1, 0], [1, 1], [1, -1], [2, 0], [2, 1], [2, -1], [3, 2], [0, 4], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [1, 10], [1, 12], [2, 10], [2, 11], [2, 14], [3, 11]]);
const Y = Matrix.columnVector([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]);

// The test set (Xtest, Ytest).
const Xtest = new Matrix([
  [0, -2],
  [1, 0.5],
  [1.5, -1],
  [1, 2.5],
  [2, 3.5],
  [1.5, 4],
  [1, 10.5],
  [2.5, 10.5],
  [2, 11.5],
]);
const Ytest = Matrix.columnVector([0, 0, 0, 1, 1, 1, 2, 2, 2]);

// We will train our model.
const logreg = new LogisticRegression({ numSteps: 1000, learningRate: 5e-3 });
logreg.train(X, Y);

// We try to predict the test set.
const finalResults = logreg.predict(Xtest);

// Now, you can compare finalResults with the Ytest, which is what you wanted to have.
```

## License

[MIT](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/ml-logistic-regression.svg
[npm-url]: https://npmjs.org/package/ml-logistic-regression
[ci-image]: https://github.com/mljs/logistic-regression/workflows/Node.js%20CI/badge.svg?branch=master
[ci-url]: https://github.com/mljs/logistic-regression/actions?query=workflow%3A%22Node.js+CI%22
[codecov-image]: https://img.shields.io/codecov/c/github/mljs/logistic-regression.svg
[codecov-url]: https://codecov.io/gh/mljs/logistic-regression
[download-image]: https://img.shields.io/npm/dm/ml-logistic-regression.svg
[download-url]: https://npmjs.org/package/ml-logistic-regression

---
_Source: https://npm.io/package/ml-logistic-regression · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
