pw-lda
Linear discriminant analysis in JavaScript
Installation
npm install pw-lda
Getting Started
Two-dimensions are used in the below example, but any number of dimensions may be used.
LDA support both binary and multiclass classification. For multiclass classification, a pairwise voting system is used to extend the binary classifier to multiclass.
const LDA = ; // Example with 2 classes let class1 = 0 0 1 2 2 2 15 05; let class2 = 8 8 9 10 7 8 9 9; let classifier = class1 class2; let unknownPoints = -1 0 15 2 3 3 5 5 7 9 10 12; let predictions = ; forlet i = 0; i < unknownPointslength; i++ predictions; console; // [ 0, 0, 0, 1, 1, 1 ] // Extending to a multiclass example let class3 = -1 10 0 12 1 11 05 9; unknownPoints = unknownPoints; classifier = class1 class2 class3; predictions = ; forlet i = 0; i < unknownPointslength; i++ predictions; console; // [ 0, 0, 0, 1, 1, 1, 2, 2, 2 ]
Documentation
Documentation is available at http://pwstegman.me/pw-lda/