# ml-pca

> Principal component analysis

Latest version **4.1.1** (published 2022-11-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install ml-pca
pnpm add ml-pca
yarn add ml-pca
bun add ml-pca
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.1 |
| Published | 2022-11-11 |
| First published | 2015-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 53.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 104 |
| Author | Jefferson Hernández |
| Maintainers | stropitek, targos, lpatiny, mljs-bot, maasencioh, jeffersonh44, andcastillo |
| Keywords | pca, principal, component, analysis, dimensionality, reduction, data, mining, datamining, machine, learning |

## Links

- npm: https://www.npmjs.com/package/ml-pca
- Repository: https://github.com/mljs/pca
- Issues: https://github.com/mljs/pca/issues
- npm.io page: https://npm.io/package/ml-pca

## Dependencies (1)

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

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 4.1.1 (latest) — 2022-11-11
- 3.0.0-0 (next) — 2019-04-25
- 4.0.2 — 2021-04-12
- 4.0.1 — 2019-10-19
- 4.0.0 — 2019-07-21
- 3.0.0 — 2019-04-25
- 2.1.0 — 2017-07-24
- 2.0.0 — 2017-07-21
- 1.1.2 — 2016-08-16
- 1.1.1 — 2016-06-02
- 1.1.0 — 2016-05-31
- 1.0.0 — 2016-05-31
- 0.1.1 — 2015-11-19
- 0.1.0 — 2015-09-23
- 0.0.3 — 2015-07-23
- … 2 more at https://npm.io/package/ml-pca/versions

## README

# ml-pca

Principal component analysis (PCA).

<h3 align="center">

  <a href="https://www.zakodium.com">
    <img src="https://www.zakodium.com/brand/zakodium-logo-white.svg" width="50" alt="Zakodium logo" />
  </a>

  <p>
    Maintained by <a href="https://www.zakodium.com">Zakodium</a>
  </p>

[![NPM version][npm-image]][npm-url]
[![build status][ci-image]][ci-url]
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7314532.svg)](https://doi.org/10.5281/zenodo.7314532)
[![npm download][download-image]][download-url]

</h3>

## Installation

`$ npm install ml-pca`

## Usage

```js
const { PCA } = require('ml-pca');
const dataset = require('ml-dataset-iris').getNumbers();
// dataset is a two-dimensional array where rows represent the samples and columns the features
const pca = new PCA(dataset);
console.log(pca.getExplainedVariance());
/*
[ 0.9246187232017269,
  0.05306648311706785,
  0.017102609807929704,
  0.005212183873275558 ]
*/
const newPoints = [
  [4.9, 3.2, 1.2, 0.4],
  [5.4, 3.3, 1.4, 0.9],
];
console.log(pca.predict(newPoints)); // project new points into the PCA space
/*
[
  [ -2.830722471866897,
    0.01139060953209596,
    0.0030369648815961603,
    -0.2817812120420965 ],
  [ -2.308002707614927,
    -0.3175048770719249,
    0.059976053412802766,
    -0.688413413360567 ]]
*/
```

## [API Documentation](https://mljs.github.io/pca/)

## License

[MIT](./LICENSE)

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

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