one-hot-enum
Version:
one hot encoding enumerations
43 lines (30 loc) • 801 B
Markdown
[](https://travis-ci.org/ansteh/one-hot-enum)
one hot encoding enumerations
Using npm:
```js
npm install one-hot-enum
```
In Node.js:
```js
var onehot = require('one-hot-enum');
```
```js
let list = ['one', 'two', 'three', 'one', 'three', 'three', 'two'];
let enumaration = onehot.enumaration(list);
let encoded = onehot.encode(list);
console.log(enumaration);
console.log(encoded);
```
Used to generate one hot encoding on the fly.
```js
let encoder = onehot.encoder([]);
_.forEach(list, value => encoder.add(value));
console.log(encoder.getEncoding());
console.log(encoder.getEncodingMap());
```
MIT © [Andre Stehle](https://github.com/ansteh)