New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pw-lda

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pw-lda

Linear discriminant analysis

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-52.38%
Maintainers
1
Weekly downloads
 
Created
Source

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. The returned projection will be less than 0 for class 1, equal to 0 if exactly inbetween, and greater than 0 for class 2.

var LDA = require('pw-lda');

var class1 = [
	[0, 0],
	[1, 2],
	[2, 2],
	[1.5, 0.5]
];

var class2 = [
	[8, 8],
	[9, 10],
	[7, 8],
	[9, 9]
];

var classifier = new LDA(class1, class2);

var unknownPoints = [
	[-1, 0],
	[1.5, 2],
	[3, 3],
	[5, 5],
	[7, 9],
	[10, 12]
];

var predictions = [];

for(var i = 0; i < unknownPoints.length; i++){
	var projection = classifier.project(unknownPoints[i]);
	predictions.push(Math.sign(projection));
}

console.log(predictions); // [ -1, -1, -1, 1, 1, 1 ]

Documentation

Documentation is available at http://pwstegman.me/pw-lda/

Keywords

FAQs

Package last updated on 02 Aug 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc