## predictorpublic

# Predictor

`Predictor`

automates the process of predicting future values in a set and evaluating this prediction models. `Predictor`

doesn't predict the values for you but rather sets up a few tools to help you test and run your prediction functions. The base functions are `guess`

and `evaluate`

. `Predictor`

also comes with a set of standard numeric datasets including but not limited to the s-curve, parabola, and Fibonacci sets. These can be found under the static `datasets`

namespace.

## Install

```
npm install predictor
```

## Usage

`var predictor = ; var { return datasetdatasetlength-1+distance;} var sCurvePredictor = predictordatasetss_curve guesser predictorevaluatorsstandard; var evaluation = sCurvePredictor; console;`

## Predictor Object

### new predictor(dataset, guesser, evaluator)

Creates a new predictor object.

- dataset: the array of data the guesser is trying to predict.
- guesser(distance, dataset): a function that guesses the array value of the dataset at x distance out;
- distance: is the number of iterations out the guesser is trying to predict.
- dataset: all historical data points up to and including the predict from point.

- evaluator(guess, answer): returns a numeric representation of how accurate the guess was.
- guess: a result of guesser
- answer: the actually value from the dataset at the same location guesser tried to predict.

### obj.guess(opt)

Guesses a value based on the supplied options.

Options

- dataset: full dataset. Should included all datapoints up to the guess from point and can include more. Defaults to dataset provided in the initializer.
- from: Where in the dataset to guess from. Defaults to the end of the dataset.
- to: Where in the dataset to guess. Will have no effect if
`distance`

is provided. - distance: how far from the from point to guess. If not provided will default to the value of
`to`

minus`from`

. If`to`

is undefined, distance will default to 1. - guesser: a guesser function. Defaults to the one provided in the initializer.

### obj.evaluate();

Evaluates a guesser function based on the supplied options. Returns an object of observations included the average evaluation, a list of guesses resulting in NaN and a record of each iteration through the dataset, guess, answer and evaluation.

Options

- dataset: Full dataset. Should included all datapoints up to the guess from point and can include more. Defaults to dataset provided in the initializer.
- distance: How far from the from point to guess. If not provided will default 1.
- guesser: a guesser function. Defaults to the one provided in the initializer.
- evaluator: an evaluator function. Defaults to the one provided in the initializer.

## Static Values

### predictor.datasets

A collection of predefined numeric sets.

- predictor.datasets.S_CURVE:
- predictor.datasets.PARABOLA:
- predictor.datasets.FIBONACCI:

### predictor.evaluators

A collection of predefined evaluators

- predictor.evaluators.standard: evaluates the guess as a percentage away from the answer. 0 is a perfect score. 100 means the guess is as far from the answer as the answer is from 0.