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-learnDocumentation
Table of Contents
- Learner
- ConfusionMatrix
- addEntry
- setEntry
- getEntry
- getTotal
- getTP
- getFP
- getFN
- getTN
- getDiagonal
- getTrue
- getFalse
- getPositive
- getNegative
- getPredPositive
- getPredNegative
- getAccuracy
- getMicroAccuracy
- getMacroAccuracy
- getTotalPositiveRate
- getMicroRecall
- getMacroRecall
- getPositivePredictiveValue
- getPositivePredictiveValue
- getMicroPrecision
- getMacroPrecision
- getMicroF1
- getMacroF1
- getFalseNegativeRate
- getMicroMissRate
- getMacroMissRate
- getFalsePositiveRate
- getMicroFallOut
- getMacroFallOut
- getTrueNegativeRate
- getMicroSpecificity
- getMacroSpecificity
- getPrevalence
- getMicroPrevalence
- getMacroPrevalence
- toString
- getShortStats
- getStats
- fromData
Learner
NodeJS Classification-based learner.
train
Parameters
eval
Returns Object Statistics from a confusion matrix
serializeClassifier
Returns string Serialized classifier
serializeAndSaveClassifier
Parameters
filestring Filename (optional, default'classifier.json')
Returns Promise<(string | Error)> Serialized classifier
deserializeClassifier
Parameters
serializedClassifierstring .
Returns Object Deserialized classifier
loadAndDeserializeClassifier
Parameters
filestring Filename (optional, default'classifier.json')
Returns Promise<(string | Error)> Deserialized classifier
classify
Parameters
data{input: any, output: any} Data to classify
crossValidate
Parameters
numOfFoldsnumber Cross-validation folds (optional, default5)verboseLevelnumber Verbosity (optional, default0)logboolean Pre-training logging (optional, defaultfalse)
Returns {microAvg: Object, macroAvg: Object} Averages
backClassify
Parameters
categorystring 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
Returns number Updated entry
setEntry
Parameters
getEntry
Parameters
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
categorystring 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
categorystring 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
categorystring Class/category considered as positive
Returns number False Negatives
getTN
Number of elements that aren't in the category class correctly predicted.
Parameters
categorystring 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
categorystring 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
categorystring 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
categorystring 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
categorystring Class/category considered as positive
Returns number TN + FP
getAccuracy
Prediction accuracy for category.
Parameters
categorystring 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
categorystring 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
categorystring Class/category considered as positive
Returns number TP / (TP + FP)
getPositivePredictiveValue
Prediction F1 score for category.
Parameters
categorystring 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
categorystring 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
categorystring 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
categorystring 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
categorystring 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
optObject Options (optional, default{})
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
actualArray<string> Actual classespredictionsArray<string> Predicted classesclassesArray<string> Classes/categories to use (optional, default[])
Returns ConfusionMatrix Filled confusion matrix
Contributors
Maximilian Berkmann 💻 📖 🤔 🚧 📦 🚇 ⚠️ 🛡️ |
This project follows the all-contributors specification. Contributions of any kind welcome!