基于JavaScript的机器学习算法和工具库

Github: github.com/laoqiren/ml…

刚兴趣的同学欢迎加QQ群:485305514交流

mlhelper

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
复制代码

Docoumention

Example

Algorithm

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').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').utils.Vector;

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

fileParser:

const parser = require('mlhelper').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').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
});
复制代码

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值