0.3.5 • Published 6 years ago

make_moons v0.3.5

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Make Moons

A small function to generate data similar to sklearn's make_moons, for a presentation on Tensorflow.js and machine learning in Javascript at LibertyJS.

Behind the scenes its generating a sine wave and randomly sampling points between a given range of that sine wave.

Installation

yarn add make_moons

or use npm:

npm install make_moons

Quick Start

> import make_moons from 'make_moons';
> make_moons({ type: 'pos' });
[
  {
    x: 0.5,
    y: 0.5,
  },
  ...
]

Options

type

Accepts a type of either pos or neg. neg is phase shifted by pi / 2.

If not provided, a random value for type will be provided.

> import make_moons from 'make_moons';
> make_moons({ type: 'neg' });

[
  // a "negative" point
  {
    x: 0.5,
    y: -0.5,
  },
]

For samples from both types, call them separately.

> import make_moons from 'make_moons';
> make_moons({ type: 'pos' });

[
  // a "positive" point
  {
    x: 0.5,
    y: 0.5,
  },
]

> make_moons({ type: 'neg' });
[
  // a "negative" point
  {
    x: 0.5,
    y: -0.5,
  },
]

n_samples

The number of samples per type to return. Defaults to 200.

> import make_moons from 'make_moons';
> make_moons({ n_samples: 2 });

[
  {
    x: 0.5,
    y: 0.5,
  },
  {
    x: 1.0,
    y: 0.5,
  },
]

noise

The amount of noise to add to each sample. Noise is added in both the x and y coordinates.

> make_moons({ noise: 0.1 });

[
  {
    x: 0.52,
    y: 0.49,
  },
]

range

An optional parameter to denote a different range than the default. Use this if you'd like the moon to extend beyond [0, 2/3] for pos, or [1/3,1] for neg.

> make_moons({ range: [-1/3, 2/3] });

[
  {
    x: -0.2,
    y: -0.1,
  },
]
0.3.5

6 years ago

0.3.4

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago