JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q35027F
  • License MIT

ML platform for All Contributors

Package Exports

  • ac-learn

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ac-learn) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ac-learn

Where the All Contributors machine can learn about your contributions.

Install

yarn add ac-learn --save
#or
npm i -D ac-learn

Documentation

Table of Contents

Learner

NodeJS Classification-based learner.

train

Parameters
  • trainSet Array<Object> Training set (optional, default this.trainSet)

eval

Returns Object Statistics from a confusion matrix

serializeClassifier

Returns string Serialized classifier

serializeAndSaveClassifier

Parameters
  • file string Filename (optional, default 'classifier.json')

Returns Promise<(string | Error)> Serialized classifier

deserializeClassifier

Parameters
  • serializedClassifier string .

Returns Object Deserialized classifier

loadAndDeserializeClassifier

Parameters
  • file string Filename (optional, default 'classifier.json')

Returns Promise<(string | Error)> Deserialized classifier

classify

Parameters
  • data {input: any, output: any} Data to classify

Returns Array<string> Classes

crossValidate

Parameters
  • numOfFolds number Cross-validation folds (optional, default 5)
  • verboseLevel number Verbosity (optional, default 0)
  • log boolean Pre-training logging (optional, default false)

Returns {microAvg: Object, macroAvg: Object} Averages

backClassify

Parameters
  • category string Category name.

Returns Array<string> Labels associated with category

toJSON

Returns Object JSON representation

fromJSON

Parameters

Returns Learner Generated learner from json

getCategoryPartition

Returns Object<string, {overall: number, test: number, train: number}> Partitions

getStats

Returns Object Statistics

ConfusionMatrix

Multi-class focused confusion matrix.

addEntry

Parameters
  • actual string Actual class
  • predicted string Predicted class

Returns number Updated entry

setEntry

Parameters

getEntry

Parameters
  • actual string Actual class
  • predicted string Predicted class

Returns number Entry

getTotal

Get the total count of all entries.

Returns number Total count

getTP

Number of elements in the category class correctly predicted.

Parameters
  • category string Class/category considered as positive

Returns number True Positives

getFP

Number of elements that aren't in the category class but predicted as such.

Parameters
  • category string Class/category considered as positive

Returns number False Positives

getFN

Number of elements in the category class but predicted as not being in it.

Parameters
  • category string Class/category considered as positive

Returns number False Negatives

getTN

Number of elements that aren't in the category class correctly predicted.

Parameters
  • category string Class/category considered as positive

Returns number True Negatives

getDiagonal

Diagonal of truth (top-left → bottom-right)

Returns Array<number> Numbers in the diagonal

getTrue

Number of correct (truthful) predictions.

Returns number TP

getFalse

Number of incorrect predictions.

Returns number FP + FN

getPositive

Number of real (actual) "positive" elements (i.e. elements that belong to the category class).

Parameters
  • category string Class/category considered as positive

Returns number TP + FN

getNegative

Number of real (actual) "negative" elements (i.e. elements that don't belong to the category class).

Parameters
  • category string Class/category considered as positive

Returns number TN + FP

getPredPositive

Number of predicted "positive" elements (i.e. elements guessed as belonging to the category class).

Parameters
  • category string Class/category considered as positive

Returns number TP + FN

getPredNegative

Number of predicted "negative" elements (i.e. elements guessed as not belonging to the category class).

Parameters
  • category string Class/category considered as positive

Returns number TN + FP

getAccuracy

Prediction accuracy for category.

Parameters
  • category string Class/category considered as positive

Returns number (TP + TN) / (TP + TN + FP + FN)

getMicroAccuracy

Micro-average of accuracy.

Returns number (TP0 + ... + TPn + TN0 + ... + TNn) / (TP0 + ... + TPn + TN0 + ... + TNn + FP0 + ... + FPn + FN0 + ... + FNn)

getMacroAccuracy

Macro-average of accuracy.

Returns number (A0 + ... An_1) / n

getTotalPositiveRate

Predicition recall.

Parameters
  • category string Class/category considered as positive

Returns number TP / (TP + FN)

getMicroRecall

Micro-average of recall.

Returns number (TP0 + ... + TPn) / (TP0 + ... + TPn + FN0 + ... + FNn)

getMacroRecall

Macro-average of recall.

Returns number (R0 + R1 + ... + Rn-1) / n

getPositivePredictiveValue

Prediction precision for category.

Parameters
  • category string Class/category considered as positive

Returns number TP / (TP + FP)

getPositivePredictiveValue

Prediction F1 score for category.

Parameters
  • category string Class/category considered as positive

Returns number 2 _ (Pr _ R) / (Pr + R)

getMicroPrecision

Micro-average of the precision.

Returns number (TP0 + ... + TPn) / (TP0 + ... + TPn + FP0 + ... FPn)

getMacroPrecision

Macro-average of the precsion.

Returns number (Pr0 + Pr1 + ... + Pr_n-1) / n

getMicroF1

Micro-average of the F1 score.

Returns number 2 _ (TP0 + ... + TPn) / (2 _ (TP0 + ... + TPn) + (FN0 + ... + FNn) + (FP0 + ... + FPn))

getMacroF1

Macro-average of the precision.

Returns number (F0_1 + F1_1 + ... + F_n-1_1) / n

getFalseNegativeRate

Miss rates on predictions for category.

Parameters
  • category string Class/category considered as positive

Returns number FN / (TP + FN)

getMicroMissRate

Micro-average of the miss rate.

Returns number (FN0 + ... + FNn) / (TP0 + ... + TPn + FN0 + ... FNn)

getMacroMissRate

Macro-average of the miss rate.

Returns number (M0 + M1 + ... + Mn) / n

getFalsePositiveRate

Fall out (false alarm) on predictions for category.

Parameters
  • category string Class/category considered as positive

Returns number FP / (FP + TN)

getMicroFallOut

Micro-average of the fall out.

Returns number (FP0 + ... + FPn) / (FP0 + ... + FPn + TN0 + ... TNn)

getMacroFallOut

Macro-average of the fall out.

Returns number (Fo0 + Fo1 + ... + Fo_n) / n

getTrueNegativeRate

Specificity on predictions for category.

Parameters
  • category string Class/category considered as positive

Returns number TN / (FP + TN)

getMicroSpecificity

Micro-average of the specificity.

Returns number (TN0 + ... + TNn) / (FP0 + ... + FPn + TN0 + ... TNn)

getMacroSpecificity

Macro-average of the specificity.

Returns number (S0 + S1 + ... + Sn) / n

getPrevalence

Prevalence on predictions for category.

Parameters
  • category string Class/category considered as positive

Returns number (TP + FN) / (TP + TN + FP + FN)

getMicroPrevalence

Micro-average of the prevalence.

Returns number (TP0 + ... + TPn + FN0 + ... + FNn) / (TP0 + ... + TPn + TN0 + ... + TNn + FP0 + ... + FPn + FN0 + ... + FNn)

getMacroPrevalence

Macro-average of the prevalence.

Returns number (S0 + S1 + ... + Sn) / n

toString

Parameters
  • opt Object Options (optional, default {})
    • opt.split boolean Split the classes in half (→ 2 matrices) (optional, default false)
    • opt.clean boolean Remove empty column/row pairs (optional, default false)
    • opt.colours boolean Colourize cells (optional, default true)
    • opt.maxValue (optional, default 100)

Returns string String representation

getShortStats

Returns string Short statistics (total, true, false, accuracy, precision, recall and f1)

getStats

Returns {total: number, correctPredictions: number, incorrectPredictions: number, classes: Array<string>, microAvg: Object, macroAvg: Object, results: Object} (Long) statistics

fromData

Creates a confusion matrix from the actual and predictions classes.

Parameters

Returns ConfusionMatrix Filled confusion matrix

Contributors

Thanks goes to these wonderful people (emoji key):

Maximilian Berkmann
Maximilian Berkmann

💻 📖 🤔 🚧

This project follows the all-contributors specification. Contributions of any kind welcome!