Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Linear discriminant analysis in JavaScript
npm install pw-lda
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 = require('pw-lda');
// Example with 2 classes
let class1 = [
[0, 0],
[1, 2],
[2, 2],
[1.5, 0.5]
];
let class2 = [
[8, 8],
[9, 10],
[7, 8],
[9, 9]
];
let classifier = new LDA(class1, class2);
let unknownPoints = [
[-1, 0],
[1.5, 2],
[3, 3],
[5, 5],
[7, 9],
[10, 12]
];
let predictions = [];
for(let i = 0; i < unknownPoints.length; i++){
predictions.push(classifier.classify(unknownPoints[i]));
}
console.log(predictions); // [ 0, 0, 0, 1, 1, 1 ]
// Extending to a multiclass example
let class3 = [
[-1, 10],
[0, 12],
[1, 11],
[0.5, 9]
];
unknownPoints = unknownPoints.concat([
[0, 11],
[-1, 8],
[1, 9]
]);
classifier = new LDA(class1, class2, class3);
predictions = [];
for(let i = 0; i < unknownPoints.length; i++){
predictions.push(classifier.classify(unknownPoints[i]));
}
console.log(predictions); // [ 0, 0, 0, 1, 1, 1, 2, 2, 2 ]
Documentation is available at http://pwstegman.me/pw-lda/
FAQs
Linear discriminant analysis
We found that pw-lda demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.