• Stars
    star
    638
  • Rank 70,537 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Algorithms and utils for Machine Learning in JavaScript.

mlhelper

npm npm

Algorithms and utils for Machine Learning in JavaScript based on Node.js. while implementing commonly used machine learning algorithms, This library attempts to provide more abundant ecology, such as matrix and vector operations, file parsing, feature engineering, data visualization, and so on.

QQ Group: 485305514

Installation

$ npm install mlhelper

Documention

Example

Algorithm

const AdaBoost = require('mlhelper/lib/algorithm').AdaBoost;
//or const AdaBoost = require('mlhelper').algorithm.AdaBoost;

const dataSet = [
    [1.0,2.1],
    [2.0,1.1],
    [1.3,1.0],
    [1.0,1.0],
    [2.0,1.0]
]
const labels = [1.0,1.0,-1.0,-1.0,1.0];
let ada = new AdaBoost(dataSet,labels,40);
let result = ada.classify([[1.0,2.1],
    [2.0,1.1],
    [1.3,1.0],
    [1.0,1.0],
    [2.0,1.0]]);
console.log(result); // [ 1, 1, -1, -1, -1 ]

Utils

Matrix:

const Matrix = require('mlhelper/lib/utils').Matrix;

let m1 = new Matrix([
    [1,2,3],
    [3,4,5]
]);

let m2 = new Matrix([
    [2,2,6],
    [3,1,5]
]);

console.log(m2.sub(m1)) // Matrix { arr: [ [ 1, 0, 3 ], [ 0, -3, 0 ] ] }
console.log(m1.mult(m2)) // Matrix { arr: [ [ 2, 4, 18 ], [ 9, 4, 25 ] ] }

Vector:

const Vector = require('mlhelper/lib/utils').Vector;

let v = new Vector([5,10,7,1]);
console.log(v.argSort()) // [ 3, 0, 2, 1 ]

fileParser:

const parser = require('mlhelper/lib/utils').fileParser;

let dt = parser.read_csv(path.join(__dirname,'./train.csv'),{
    index_col: 0,
    delimiter: ',',
    header: 0,
    dataType: 'number'
});
let labels = dt.getClasses();
let dataSet =dt.drop('quality').values;

Feature Engineering

// preprocessing features
const preprocessing = require('mlhelper/lib/utils').features.preprocessing;

// make the features obey the standard normal distribution(Standardization)
let testStandardScaler = preprocessing.standardScaler(dataSet);

let testNormalize = preprocessing.normalize(dataSet);

let testBinarizer = preprocessing.binarizer(dataSet);

// ...

graph tools:

Decision Tree:

charts.drawDT(dt.getTree(),{
    width:600,
    height:400
});

/assets/DT.png

logistic regression

charts.drawLogistic(dataSet,labels,weights);

Contribute

The original purpose of this project is to learn, and now I need more people to participate in this project, and any issue and good advice is welcome.

git clone

git clone https://github.com/laoqiren/mlhelper.git

install dependencies&&devdependecies

npm install

development

npm run dev

test

npm run test

build

npm run build

LICENSE

MIT.

You can use the project for any purpose, except for illegal activities.

More Repositories

1

web-performance

Web性能的方方面面🚀
712
star
2

isomorphic-redux-CNode

😊👻基于react->express->mongo技术栈的同构SPA
JavaScript
119
star
3

yohe

😈 powerful static blog generator
JavaScript
69
star
4

excel-class

a module helping to handle excel based on js-xlsx
JavaScript
20
star
5

vue-express-forum

基于vuejs,express,mongodb的多人论坛webapp😛
JavaScript
14
star
6

Oauth-example

Oauth example imitate Github Oauth App
JavaScript
9
star
7

CNVD-crawler

CNVD-crawler for 创新实践
JavaScript
7
star
8

vue-memo

基于Vuejs的备忘录webapp
JavaScript
3
star
9

product-thinking

Think about products from a programmer's point of view
2
star
10

egg-extra-loader

提供更加方便的loader扩展
JavaScript
2
star
11

CW-haskell

solutions for codewars kata in haskell.
Haskell
2
star
12

socket.io-demo

基于socket.io的聊天系统
JavaScript
1
star
13

life

the life part of my blog www.luoxia.me/life
CSS
1
star
14

Wunderlist-RN

📝奇妙清单RN版😆😚
JavaScript
1
star
15

JSON

json decoder & encoder
JavaScript
1
star
16

secretBox

秘密盒zi powered by Egg.js
JavaScript
1
star
17

SSH-example

java web作业备忘
Java
1
star
18

daily-exc

daily exercise for HW fe member
1
star
19

yohe_site

test for yohe blog generator
HTML
1
star
20

weApp-HW

微信小程序By HW团队
JavaScript
1
star
21

Reactive

Reactive programming with different ways
JavaScript
1
star
22

fullpage

test fullpage
JavaScript
1
star
23

algbox

Providing algorithm ecology for the JavaScript community.
TypeScript
1
star
24

industrial-safety

JavaScript
1
star
25

code

个人主页www.luoxia.me下的技术博客版块:www.luoxia.me/code
CSS
1
star
26

laoqiren.github.io

CSS
1
star
27

notes-service

for notes
JavaScript
1
star
28

laoqiren

personal profile readme
1
star
29

compiler

Compiler principle experiments.
JavaScript
1
star
30

leetcode

1
star
31

security-guard

Providing security guards for Node.js applications.
TypeScript
1
star
32

Regular-types

Type declaration for Regularjs
1
star