npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsmachinelearning

v1.0.1

Published

Popular algorithms of machine learning are made available

Downloads

4

Readme

MLJavaScript

All popular Machine Learning algorithms are made available in this repository.

Prerequisites

Node.js, matrix_deep_clone, jsnumpy.

Installing

$ npm install jsmachinelearning

Algorithms.

Multiple Linear Regression.

> var MLAlgorithms = require('jsmachinelearning');

> var model = new MLAlgorithms.MultipleLinearRegression();

> x = [
  [1, 2],
  [4, 2],
  [6, 3],
  [2, 3],
  [5, 1]
]
> y=[1,2,3,2,5];

> model.fit(x,y);

> var k = model.predict([ [1, 2], [4, 2] ])

> console.log(k);
  [ 0.2285865948088468, 1.8311543879819048 ]

NOTE : MultipleLinearRegression function provides a model using which we can train on data with more then one feature vector. In the above example we are having two feature vector in X. It can also be used to predict the value for the unknown data.

Simple Linear Regression

> var model = new MLAlgorithms.SimpleLinearRegression();

> x = [2,3,4,5,6];

> y = [1,2,3,2,5];

> model.fit(x,y)

> k = model.predict([2,4,5]);

> console.log(k);
  [ 1, 2.6, 3.4 ];

NOTE : SimpleLinearRegression provides a model for training on data with single feature vector. It can also predict value for unknown sample.

Additional Methods

Train test split

> var data = [
  [1, 43, 2],
  [3, 32, 4],
  [5, 13, 6],
  [7, 44, 8]
]

> var [train, test] = mlAlgorithms.train_test_split(data, train_ratio = 0.5);

> console.log(train);
[
  [1, 43, 2],
  [3, 32, 4]
]

> console.log(test);
[
  [7, 44, 8],
  [5, 13, 6]
]

NOTE: train_test_split function divides the data in the train_ratio mentioned. The default value for train_ratio is 0.75 i.e. 75 percent of the data becomes training and 25 percent data becomes test data. The data is not selected in sequential order but instead it is randomized so that proper predication can be made based on the data.

Separate feature and target data

> var data = [
  [1, 43, 2],
  [3, 32, 4],
  [5, 13, 6],
  [7, 44, 8]
]

> var [x, y] = mlAlgorithms.get_X_And_Y(data);

> console.log(x);
[
  [1, 43],
  [3, 32],
  [5, 13],
  [7, 44]
]

> console.log(y);
[2, 4, 6, 8]

NOTE : get_X_And_Y function returns feature vector and target variable Separated. The function assumes the last column of the data has target variable and first n-1 column has feature vector.

Authors

License

This project is licensed under the MIT License