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

Install Socket

Detect and block malicious and high-risk dependencies

Install

pierce

Machine learning, signal processing, and statistics

1.0.1
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created

pierce

Installation

npm install pierce

Getting Started

I'll be compiling a lot of my commonly used machine learning, signal processing, and statistics JavaScript modules here for easy reference.

var pierce = require('pierce');

// Statistics
var stat = pierce.stat;

var a = [
	[1, 5],
	[3, 2]
];

console.log(stat.cov(a)); // [ [ 2, -3 ], [ -3, 4.5 ] ] (Covariance matrix)
console.log(stat.mean(a)); // [ 2, 3.5 ] (Mean of each column)

// Machine learning
var LDA = pierce.lda;

var class1 = [
	[0, 1],
	[1, 2]
];
 
var class2 = [
	[8, 8],
	[9, 10]
];

var classifier = new LDA(class1, class2);

var unknownPoints = [
    [-1, 0],
    [7, 9]
];

console.log(classifier.project(unknownPoints[0])); // -98 (value less than 0 is class 1)
console.log(classifier.project(unknownPoints[1])); // 20 (value greater than 0 is class 2)

// Signal processing
var CSP = pierce.csp;

var a = [
	[-1, -1],
	[1, 1]
];

var b = [
	[-1, 1],
	[1, -1]
];

var csp = new CSP(a, b);

console.log(csp.project(a, 2)); // [ [ 1.414, 0 ], [ -1.414, 0 ] ]
console.log(csp.project(b, 2)); // [ [ 0, -1.414 ], [ 0, 1.414 ] ]

FAQs

Package last updated on 16 Nov 2017

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