<commit_before># ml-pca

  [![NPM version][npm-image]][npm-url]
  [![build status][travis-image]][travis-url]
  [![David deps][david-image]][david-url]
  [![npm download][download-image]][download-url]

Principal component analysis (PCA)

## Installation

`$ npm install ml-pca`

## Methods

### new PCA(dataset)

__Arguments__

* `dataset` - Data to get the PCA

__Example__

```js
var dataset = [ ... ];

var pca = new PCA(dataset);
```

### project(dataset, k)

Project the dataset over k dimensions 

__Arguments__

* `dataset` - A Matrix of the dataset.
* `k` - Number of dimensions to be projected.

__Example__

```js
var data = [ ... ];

var projectedData = pca.project(data, k);
```

### getExplainedVariance()

Returns the percentage of variance of each vector of the PCA.

### getEigenvectors()

Get the eigenvectors of the covariance matrix.

### getEigenvalues()

Get the eigenvalues on the diagonal.

### export()

Exports the actual PCA to an Javascript Object.

### load(model)

Returns a new PCA with the given model.

__Arguments__<commit_msg>doc: dependency to ml-matrix package added.<commit_after># ml-pca

  [![NPM version][npm-image]][npm-url]
  [![build status][travis-image]][travis-url]
  [![David deps][david-image]][david-url]
  [![npm download][download-image]][download-url]

Principal component analysis (PCA)

## Installation

`$ npm install ml-pca`

* This package depends on [ml-matrix](https://github.com/mljs/matrix).

## Methods

### new PCA(dataset)

__Arguments__

* `dataset` - Data to get the PCA, must be [ml-matrix](https://github.com/mljs/matrix).

__Example__

```js
var dataset = [ ... ];

var pca = new PCA(dataset);
```

### project(dataset, k)

Project the dataset over k dimensions 

__Arguments__

* `dataset` - A Matrix of the dataset, must me a [ml-matrix](https://github.com/mljs/matrix).
* `k` - Number of dimensions to be projected.

__Example__

```js
var data = [ ... ];

var projectedData = pca.project(data, k);
```

### getExplainedVariance()

Returns the percentage of variance of each vector of the PCA.

### getEigenvectors()

Get the eigenvectors of the covariance matrix.

### getEigenvalues()

Get the eigenvalues on the diagonal.

### export()

Exports the actual PCA to an Javascript Object.

### load(model)

Returns a new PCA with the given model.

__Arguments__
{'fraction_non_alphanumeric': 0.14616373767681098, 'fraction_numerical': 0.0, 'mean_word_length': 4.1866666666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1902049', 'n_tokens_mistral': 814, 'n_tokens_neox': 763, 'n_words': 240}