# neur

> Simple neural network implementation

Latest version **1.0.1** (published 2016-04-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install neur
pnpm add neur
yarn add neur
bun add neur
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-04-23 |
| First published | 2016-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Huy Tran |
| Maintainers | huytd |
| Keywords | machine-learning, neural-network, learning, sigmoid, network, neuron, neural, mind, nn |

## Links

- npm: https://www.npmjs.com/package/neur
- Repository: https://github.com/huytd/neur
- Homepage: https://github.com/huytd/neur#readme
- Issues: https://github.com/huytd/neur/issues
- npm.io page: https://npm.io/package/neur

## Dependencies (5)

- [sample](https://npm.io/package/sample.md) 0.0.2
- [samples](https://npm.io/package/samples.md) 0.0.2
- [sigmoid](https://npm.io/package/sigmoid.md) 0.0.1
- [node-matrix](https://npm.io/package/node-matrix.md) ^0.1.1
- [sigmoid-prime](https://npm.io/package/sigmoid-prime.md) 0.0.1

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-04-23
- 1.0.0 — 2016-04-23

## README

# neur

Simple neural network implementation in JS

## Installation

Install via npm:

```
npm install neur
```

## Usage

**Step 1:** Initialize a network

```js
var Neural = require('neur');
var neural = Neural();
```

or 

```js
var neural = require('neur')();
```

You can config the network by passing the options to the constructor:

```js
var neural = Neural({
  learningRate: 0.7,
  iterations: 10000,
  hiddenUnits: 3
});
```

By default, we have a network with `1` hidden layer which has `3` neurons in total. And it will train the input data `10,000` times.

**Step 2:** Train a network

```js
neural.learn([
  { input: [ <input-values> ], output: [ <output-values> ] },
  ...
]);
```

**Step 3:** Predict

```js
var result = neural.predict([ <predict-input-values> ]);
```

## Examples

### Example 1: Basic using

```js
var Neural = require('neur');

var neural = Neural()
    .learn([
      { input: [0, 0], output: [0] },
      { input: [0, 1], output: [1] },
      { input: [1, 1], output: [1] },
      { input: [1, 0], output: [0] }
  ]);

console.log(neural.predict([1, 0])); // ~0
console.log(neural.predict([1, 1])); // ~1
```

### Example 2: Use Model mapping to train complex data

```js
var Neural = require('neur');

var color = Neural().model({ r: 0, g: 0, b: 0 });
var guess = Neural().model({ black: 0, white: 0 });

var result = Neural()
    .learn([
      {
          input: color.in({ r: 0.03, g: 0.7, b: 0.5 }),
          output: guess.in({ black: 1, white: 0 })
      },
      {
          input: color.in({ r: 0.16, g: 0.09, b: 0.2 }),
          output: guess.in({ black: 0, white: 1 })
      },
      {
          input: color.in({ r: 0.5, g: 0.5, b: 1.0 }),
          output: guess.in({ black: 0, white: 1 })
      }
    ])
    .predict(color.in({ r: 1, g: 0.4, b: 0 }));

console.log(guess.out(result)); // { black: ~0, white: ~1 }
```

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