## Index

### Interfaces

- ArrayCalculation
- ArraySort

### Type aliases

- InputComponents
- ScaledTransforms

### Variables

- avg
- mean
- sd
- sum

### Functions

- MADMeanRatio
- MinMaxScaler
- MinMaxScalerTransforms
- StandardScaler
- StandardScalerTransforms
- adjustedCoefficentOfDetermination
- approximateZPercentile
- coefficientOfCorrelation
- coefficientOfDetermination
- forecastErrors
- getSafePropertyName
- max
- meanAbsoluteDeviation
- meanAbsolutePercentageError
- meanForecastError
- meanSquaredError
- min
- pivotArrays
- pivotVector
- rSquared
- scale
- squaredDifference
- standardError
- standardScore
- trackingSignal

### Object literals

- util

## Type aliases

### InputComponents

InputComponents: { average?: undefined | number; maximum?: undefined | number; minimum?: undefined | number; standard_dev?: undefined | number }

- Defined in util.ts:260

#### Type declaration

- ##### Optional average?: undefined | number

- ##### Optional maximum?: undefined | number

- ##### Optional minimum?: undefined | number

- ##### Optional standard_dev?: undefined | number

### ScaledTransforms

ScaledTransforms: { components: InputComponents; descale: (x: number) => number; scale: (x: number) => number; values: number[] }

- Defined in util.ts:267

#### Type declaration

- ##### components: InputComponents

- ##### descale: (x: number) => number

  - - (x: number): number

    - #### Parameters

      - ##### x: number

      #### Returns number

- ##### scale: (x: number) => number

  - - (x: number): number

    - #### Parameters

      - ##### x: number

      #### Returns number

- ##### values: number[]

## Variables

### Const avg

avg: ArrayCalculation = ArrayStat.mean

- Defined in util.ts:12

### Const mean

mean: ArrayCalculation = avg

- Defined in util.ts:13

### Const sd

sd: ArrayCalculation = ArrayStat.standardDeviation

- Defined in util.ts:18

### Const sum

sum: ArrayCalculation = ArrayStat.sum

- Defined in util.ts:14

## Functions

### MADMeanRatio

- MADMeanRatio(actuals: number[], estimates: number[]): number

- - Defined in util.ts:523

  MAD over Mean Ratio - The MAD/Mean ratio is an alternative to the MAPE that is better suited to intermittent and low-volume data. As stated previously, percentage errors cannot be calculated when the actual equals zero and can take on extreme values when dealing with low-volume data. These issues become magnified when you start to average MAPEs over multiple time series. The MAD/Mean ratio tries to overcome this problem by dividing the MAD by the Mean—essentially rescaling the error to make it comparable across time series of varying scales

  memberof

    util

  see

    https://www.forecastpro.com/Trends/forecasting101August2011.html

  example

    const actuals = [ 45, 38, 43, 39 ]; const estimates = [ 41, 43, 41, 42 ]; const MMR = ms.util.MADMeanRatio(actuals, estimates); MAPE.toFixed(2) // => 0.08

  #### Parameters

  - ##### actuals: number[]

    numerical samples

  - ##### estimates: number[]

    estimates values

  #### Returns number

  MMR

### Const MinMaxScaler

- MinMaxScaler(z: number[]): number[]

- - Defined in util.ts:328

  Transforms features by scaling each feature to a given range. This estimator scales and translates each feature individually such that it is in the given range on the training set, i.e. between zero and one.

  memberof

    util

  #### Parameters

  - ##### z: number[]

    array of integers or floats

  #### Returns number[]

### MinMaxScalerTransforms

- MinMaxScalerTransforms(vector?: never[], nan_value?: number, return_nan?: boolean, inputComponents?: InputComponents): ScaledTransforms

- - Defined in util.ts:334

  This function returns two functions that can mix max scale new inputs and reverse scale new outputs

  #### Parameters

  - ##### Default value vector: never[] = []

  - ##### Default value nan_value: number = -1

  - ##### Default value return_nan: boolean = false

  - ##### Default value inputComponents: InputComponents = {}

  #### Returns ScaledTransforms

  - {scale[ Function ], descale[ Function ]}

### Const StandardScaler

- StandardScaler(z: number[]): number[]

- - Defined in util.ts:258

  Standardize features by removing the mean and scaling to unit variance

  Centering and scaling happen independently on each feature by computing the relevant statistics on the samples in the training set. Mean and standard deviation are then stored to be used on later data using the transform method.

  Standardization of a dataset is a common requirement for many machine learning estimators: they might behave badly if the individual feature do not more or less look like standard normally distributed data (e.g. Gaussian with 0 mean and unit variance)

  memberof

    util

  #### Parameters

  - ##### z: number[]

    array of integers or floats

  #### Returns number[]

### StandardScalerTransforms

- StandardScalerTransforms(vector?: never[], nan_value?: number, return_nan?: boolean, inputComponents?: InputComponents): ScaledTransforms

- - Defined in util.ts:278

  This function returns two functions that can standard scale new inputs and reverse scale new outputs

  #### Parameters

  - ##### Default value vector: never[] = []

  - ##### Default value nan_value: number = -1

  - ##### Default value return_nan: boolean = false

  - ##### Default value inputComponents: InputComponents = {}

  #### Returns ScaledTransforms

  - {scale[ Function ], descale[ Function ]}

### adjustedCoefficentOfDetermination

- adjustedCoefficentOfDetermination(options: { actuals: number[]; estimates: number[]; independentVariables: number; rSquared: number; sampleSize: number }): number

- - Defined in util.ts:136

  You can use the adjusted coefficient of determination to determine how well a multiple regression equation “fits” the sample data. The adjusted coefficient of determination is closely related to the coefficient of determination (also known as R2) that you use to test the results of a simple regression equation.

  example

    const adjr2 = ms.util.adjustedCoefficentOfDetermination({ rSquared: 0.944346527, sampleSize: 8, independentVariables: 2, }); r2.toFixed(3) // => 0.922

  memberof

    util

  see

    http://www.dummies.com/education/math/business-statistics/how-to-calculate-the-adjusted-coefficient-of-determination/

  #### Parameters

  - ##### options: { actuals: number[]; estimates: number[]; independentVariables: number; rSquared: number; sampleSize: number }

    - ##### actuals: number[]

    - ##### estimates: number[]

    - ##### independentVariables: number

      the number of independent variables in the regression equation

    - ##### rSquared: number

    - ##### sampleSize: number

  #### Returns number

  adjusted r^2 for multiple linear regression

### approximateZPercentile

- approximateZPercentile(z: number, alpha?: boolean): number

- - Defined in util.ts:386

  Converts z-score into the probability

  memberof

    util

  see

    https://stackoverflow.com/questions/36575743/how-do-i-convert-probability-into-z-score

  #### Parameters

  - ##### z: number

    Number of standard deviations from the mean.

  - ##### Default value alpha: boolean = true

  #### Returns number

  p - p-value

### coefficientOfCorrelation

- coefficientOfCorrelation(actuals?: number[], estimates?: number[]): number

- - Defined in util.ts:160

  The coefficent of Correlation is given by R decides how well the given data fits a line or a curve.

  example

    const actuals = [ 39, 42, 67, 76, ]; const estimates = [ 44, 40, 60, 84, ]; const R = ms.util.coefficientOfCorrelation(actuals, estimates); R.toFixed(4) // => 0.9408

  memberof

    util

  see

    https://calculator.tutorvista.com/r-squared-calculator.html

  #### Parameters

  - ##### Default value actuals: number[] = []

    numerical samples

  - ##### Default value estimates: number[] = []

    estimates values

  #### Returns number

  R

### coefficientOfDetermination

- coefficientOfDetermination(actuals?: number[], estimates?: number[]): number

- - Defined in util.ts:81

  In statistics, the coefficient of determination, denoted R2 or r2 and pronounced "R squared", is the proportion of the variance in the dependent variable that is predictable from the independent variable(s). Compares distance of estimated values to the mean. {\bar {y}}={\frac {1}{n}}\sum {i=1}^{n}y{i}

  example

    const actuals = [ 2, 4, 5, 4, 5, ]; const estimates = [ 2.8, 3.4, 4, 4.6, 5.2, ]; const r2 = ms.util.coefficientOfDetermination(actuals, estimates); r2.toFixed(1) // => 0.6

  memberof

    util

  see

    https://en.wikipedia.org/wiki/Coefficient_of_determination http://statisticsbyjim.com/regression/standard-error-regression-vs-r-squared/

  #### Parameters

  - ##### Default value actuals: number[] = []

    numerical samples

  - ##### Default value estimates: number[] = []

    estimates values

  #### Returns number

  r^2

### forecastErrors

- forecastErrors(actuals: number[], estimates: number[]): number[]

- - Defined in util.ts:435

  The errors (residuals) from acutals and estimates

  memberof

    util

  example

    const actuals = [ 45, 38, 43, 39 ]; const estimates = [ 41, 43, 41, 42 ]; const errors = ms.util.forecastErrors(actuals, estimates); // => [ 4, -5, 2, -3 ]

  #### Parameters

  - ##### actuals: number[]

    numerical samples

  - ##### estimates: number[]

    estimates values

  #### Returns number[]

  errors (residuals)

### getSafePropertyName

- getSafePropertyName(name: string): string

- - Defined in util.ts:420

  returns a safe column name / url slug from a string

  #### Parameters

  - ##### name: string

  #### Returns string

### Const max

- max(a: number[]): number

- - Defined in util.ts:16

  #### Parameters

  - ##### a: number[]

  #### Returns number

### meanAbsoluteDeviation

- meanAbsoluteDeviation(actuals: number[], estimates: number[]): number

- - Defined in util.ts:469

  Mean Absolute Deviation (MAD) indicates the absolute size of the errors

  memberof

    util

  see

    https://scm.ncsu.edu/scm-articles/article/measuring-forecast-accuracy-approaches-to-forecasting-a-tutorial

  example

    const actuals = [ 45, 38, 43, 39 ]; const estimates = [ 41, 43, 41, 42 ]; const MAD = ms.util.meanAbsoluteDeviation(actuals, estimates); // => 3.5

  #### Parameters

  - ##### actuals: number[]

    numerical samples

  - ##### estimates: number[]

    estimates values

  #### Returns number

  MAD

### meanAbsolutePercentageError

- meanAbsolutePercentageError(actuals: number[], estimates: number[]): number

- - Defined in util.ts:542

  MAPE (Mean Absolute Percent Error) measures the size of the error in percentage terms

  memberof

    util

  see

    https://www.forecastpro.com/Trends/forecasting101August2011.html

  example

    const actuals = [ 45, 38, 43, 39 ]; const estimates = [ 41, 43, 41, 42 ]; const MAPE = ms.util.meanAbsolutePercentageError(actuals, estimates); MAPE.toFixed(2) // => 0.86

  #### Parameters

  - ##### actuals: number[]

    numerical samples

  - ##### estimates: number[]

    estimates values

  #### Returns number

  MAPE

### meanForecastError

- meanForecastError(actuals: number[], estimates: number[]): number

- - Defined in util.ts:452

  The bias of forecast accuracy

  memberof

    util

  see

    https://scm.ncsu.edu/scm-articles/article/measuring-forecast-accuracy-approaches-to-forecasting-a-tutorial

  example

    const actuals = [ 45, 38, 43, 39 ]; const estimates = [ 41, 43, 41, 42 ]; const MFE = ms.util.meanForecastError(actuals, estimates); // => -0.5

  #### Parameters

  - ##### actuals: number[]

    numerical samples

  - ##### estimates: number[]

    estimates values

  #### Returns number

  MFE (bias)

### meanSquaredError

- meanSquaredError(actuals: number[], estimates: number[]): number

- - Defined in util.ts:505

  The standard error of the estimate is a measure of the accuracy of predictions made with a regression line. Compares the estimate to the actual value

  memberof

    util

  see

    http://onlinestatbook.com/2/regression/accuracy.html

  example

    const actuals = [ 45, 38, 43, 39 ]; const estimates = [ 41, 43, 41, 42 ]; const MSE = ms.util.meanSquaredError(actuals, estimates); // => 13.5

  #### Parameters

  - ##### actuals: number[]

    numerical samples

  - ##### estimates: number[]

    estimates values

  #### Returns number

  MSE

### Const min

- min(a: number[]): number

- - Defined in util.ts:17

  #### Parameters

  - ##### a: number[]

  #### Returns number

### pivotArrays

- pivotArrays(arrays?: Matrix): Matrix

- - Defined in util.ts:235

  returns a matrix of values by combining arrays into a matrix

  memberof

    util

  example

    const arrays = [ [ 1, 1, 3, 3 ], [ 2, 2, 3, 3 ], [ 3, 3, 4, 3 ], ]; pivotArrays(arrays); //=> // [ // [1, 2, 3,], // [1, 2, 3,], // [3, 3, 4,], // [3, 3, 3,], // ];

  #### Parameters

  - ##### Default value arrays: Matrix = []

  #### Returns Matrix

  a matrix of column values

### pivotVector

- pivotVector(vectors?: Array<any>[]): Matrix

- - Defined in util.ts:205

  returns an array of vectors as an array of arrays

  example

    const vectors = [ [1,2,3], [1,2,3], [3,3,4], [3,3,3] ]; const arrays = pivotVector(vectors); // => [ [1,2,3,3], [2,2,3,3], [3,3,4,3] ];

  memberof

    util

  #### Parameters

  - ##### Default value vectors: Array<any>[] = []

  #### Returns Matrix

### rSquared

- rSquared(actuals?: number[], estimates?: number[]): number

- - Defined in util.ts:193

  The coefficent of determination is given by r^2 decides how well the given data fits a line or a curve.

  #### Parameters

  - ##### Default value actuals: number[] = []

  - ##### Default value estimates: number[] = []

  #### Returns number

  r^2

### Const scale

- scale(a: number[], d: number): number[]

- - Defined in util.ts:15

  #### Parameters

  - ##### a: number[]

  - ##### d: number

  #### Returns number[]

### squaredDifference

- squaredDifference(left: number[], right: number[]): number[]

- - Defined in util.ts:28

  Returns an array of the squared different of two arrays

  memberof

    util

  #### Parameters

  - ##### left: number[]

  - ##### right: number[]

  #### Returns number[]

  Squared difference of left minus right array

### standardError

- standardError(actuals?: number[], estimates?: number[]): number

- - Defined in util.ts:48

  The standard error of the estimate is a measure of the accuracy of predictions made with a regression line. Compares the estimate to the actual value

  memberof

    util

  see

    http://onlinestatbook.com/2/regression/accuracy.html

  example

    const actuals = [ 2, 4, 5, 4, 5, ]; const estimates = [ 2.8, 3.4, 4, 4.6, 5.2, ]; const SE = ms.util.standardError(actuals, estimates); SE.toFixed(2) // => 0.89

  #### Parameters

  - ##### Default value actuals: number[] = []

    numerical samples

  - ##### Default value estimates: number[] = []

    estimates values

  #### Returns number

  Standard Error of the Estimate

### standardScore

- standardScore(observations?: number[]): number[]

- - Defined in util.ts:61

  Calculates the z score of each value in the sample, relative to the sample mean and standard deviation.

  memberof

    util

  see

    https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.mstats.zscore.html

  #### Parameters

  - ##### Default value observations: number[] = []

    An array like object containing the sample data.

  #### Returns number[]

  The z-scores, standardized by mean and standard deviation of input array

### trackingSignal

- trackingSignal(actuals: number[], estimates: number[]): number

- - Defined in util.ts:487

  Tracking Signal - Used to pinpoint forecasting models that need adjustment

  memberof

    util

  see

    https://scm.ncsu.edu/scm-articles/article/measuring-forecast-accuracy-approaches-to-forecasting-a-tutorial

  example

    const actuals = [ 45, 38, 43, 39 ]; const estimates = [ 41, 43, 41, 42 ]; const trackingSignal = ms.util.trackingSignal(actuals, estimates); trackingSignal.toFixed(2) // => -0.57

  #### Parameters

  - ##### actuals: number[]

    numerical samples

  - ##### estimates: number[]

    estimates values

  #### Returns number

  trackingSignal

## Object literals

### Const util

util: object

- Defined in util.ts:551

namespace

### MAD

MAD: meanAbsoluteDeviation = meanAbsoluteDeviation

- Defined in util.ts:587

### MADMeanRatio

MADMeanRatio: MADMeanRatio

- Defined in util.ts:592

### MAPE

MAPE: meanAbsolutePercentageError = meanAbsolutePercentageError

- Defined in util.ts:595

### MFE

MFE: meanForecastError = meanForecastError

- Defined in util.ts:585

### MMR

MMR: MADMeanRatio = MADMeanRatio

- Defined in util.ts:593

### MSE

MSE: meanSquaredError = meanSquaredError

- Defined in util.ts:591

### MinMaxScaler

MinMaxScaler: MinMaxScaler

- Defined in util.ts:563

### MinMaxScalerTransforms

MinMaxScalerTransforms: MinMaxScalerTransforms

- Defined in util.ts:564

### StandardScaler

StandardScaler: StandardScaler

- Defined in util.ts:561

### StandardScalerTransforms

StandardScalerTransforms: StandardScalerTransforms

- Defined in util.ts:562

### TS

TS: trackingSignal = trackingSignal

- Defined in util.ts:589

### adjustedCoefficentOfDetermination

adjustedCoefficentOfDetermination: adjustedCoefficentOfDetermination

- Defined in util.ts:573

### adjustedRSquared

adjustedRSquared: adjustedCoefficentOfDetermination = adjustedCoefficentOfDetermination

- Defined in util.ts:575

### approximateZPercentile

approximateZPercentile: approximateZPercentile

- Defined in util.ts:580

### avg

avg: ArrayCalculation

- Defined in util.ts:555

### coefficientOfCorrelation

coefficientOfCorrelation: coefficientOfCorrelation

- Defined in util.ts:570

### coefficientOfDetermination

coefficientOfDetermination: coefficientOfDetermination

- Defined in util.ts:569

### forecastErrors

forecastErrors: forecastErrors

- Defined in util.ts:583

### getSafePropertyName

getSafePropertyName: getSafePropertyName

- Defined in util.ts:582

### max

max: ArraySort

- Defined in util.ts:558

### mean

mean: ArrayCalculation = avg

- Defined in util.ts:556

### meanAbsoluteDeviation

meanAbsoluteDeviation: meanAbsoluteDeviation

- Defined in util.ts:586

### meanAbsolutePercentageError

meanAbsolutePercentageError: meanAbsolutePercentageError

- Defined in util.ts:594

### meanForecastError

meanForecastError: meanForecastError

- Defined in util.ts:584

### meanSquaredError

meanSquaredError: meanSquaredError

- Defined in util.ts:590

### min

min: ArraySort

- Defined in util.ts:559

### pivotArrays

pivotArrays: pivotArrays

- Defined in util.ts:577

### pivotVector

pivotVector: pivotVector

- Defined in util.ts:576

### r

r: coefficientOfCorrelation = coefficientOfCorrelation

- Defined in util.ts:571

### rBarSquared

rBarSquared: adjustedCoefficentOfDetermination = adjustedCoefficentOfDetermination

- Defined in util.ts:574

### rSquared

rSquared: rSquared

- Defined in util.ts:572

### range

range: range

- Defined in util.ts:552

### rangeRight

rangeRight: rangeRight

- Defined in util.ts:553

### scale

scale: scale

- Defined in util.ts:554

### sd

sd: ArrayCalculation

- Defined in util.ts:560

### squaredDifference

squaredDifference: squaredDifference

- Defined in util.ts:567

### standardError

standardError: standardError

- Defined in util.ts:568

### standardScore

standardScore: standardScore

- Defined in util.ts:578

### sum

sum: ArrayCalculation

- Defined in util.ts:557

### trackingSignal

trackingSignal: trackingSignal

- Defined in util.ts:588

### zScore

zScore: standardScore = standardScore

- Defined in util.ts:579

### ExpScaler

- ExpScaler(z: number[]): number[]

- - Defined in util.ts:566

  #### Parameters

  - ##### z: number[]

  #### Returns number[]

### LogScaler

- LogScaler(z: number[]): number[]

- - Defined in util.ts:565

  #### Parameters

  - ##### z: number[]

  #### Returns number[]