Coder Social home page Coder Social logo

ai-on-browser / ai-on-browser.github.io Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 3.0 21.12 MB

Machine learning and data analysis package implemented in JavaScript and its online demo.

Home Page: https://ai-on-browser.github.io

License: MIT License

CSS 0.14% JavaScript 97.59% HTML 0.05% Shell 0.10% Python 2.11% Dockerfile 0.01%
ai machine-learning data-analysis clustering classification regression interpolation anomaly-detection dimension-reduction feature-selection

ai-on-browser.github.io's Introduction

AI on Browser

npm version Coverage Status Codacy Badge License: MIT

Machine learning and data analysis package implemented in JavaScript and its online demo.

Features

  • Most of the models are completed in a single file and implemented in a simple way.
  • The machine learning part of the code does not use any external libraries, except for the loading part of the ONNX file.
  • All processing in the demo is done in client-side JavaScript.

Links

Caution

  • The code is not practical in terms of speed, memory usage, etc.
  • There is no single compact file, and each model file exists only separately. However, it is possible to use them from the default import as shown in Example.

Install

npm

npm install --save @ai-on-browser/data-analysis-models

HTML

Download from the CDN.

<script type="module">
    import dam from 'https://cdn.jsdelivr.net/npm/@ai-on-browser/[email protected]/lib/index.min.js';
    // Do something
</script>

Examples

Ridge

import dam from '@ai-on-browser/data-analysis-models';

const x = dam.Matrix.randn(100, 3);
const y = x.sum(1);

const model = new dam.models.Ridge(0.1);
model.fit(x.toArray(), y.toArray());

const predict = model.predict(x.toArray());
const error = dam.evaluate.rmse(predict, y.toArray());
console.log(error);

NeuralNetwork

import dam from '@ai-on-browser/data-analysis-models';

const x = dam.Matrix.randn(100, 3);
const y = x.sum(1);

const layers = [
    { type: 'input' },
    { type: 'full', out_size: 5 },
    { type: 'tanh' },
    { type: 'full', out_size: 1 },
];
const model = dam.models.NeuralNetwork.fromObject(layers, 'mse', 'adam');
for (let i = 0; i < 100; i++) {
    model.fit(x.toArray(), y.toArray());
}

const predict = model.predict(x.toArray());
const error = dam.evaluate.rmse(predict, y.toArray());
console.log(error);

Q-learning

import dam from '@ai-on-browser/data-analysis-models';

const env = new dam.rl.CartPoleRLEnvironment();
const agent = new dam.models.QAgent(env, 6);

const n = 1.0e+4;
const totalRewards = []
for (let i = 0; i < n; i++) {
    let curState = env.reset();
    totalRewards[i] = 0;
    while (true) {
        const action = agent.get_action(curState, Math.max(0.01, 1 - i / 2000));
        const { state, reward, done } = env.step(action);
        agent.update(action, curState, state, reward);
        totalRewards[i] += reward;
        curState = state;
        if (done) {
            break;
        }
    }

    if (totalRewards.length >= 10 && totalRewards.slice(-10).reduce((s, v) => s + v, 0) / 10 > 150) {
        console.log(i, totalRewards[totalRewards.length - 1]);
        break;
    }
}

Models (with demo)

task model
clustering (Soft / Kernel / Genetic / Weighted / Bisecting) k-means, k-means++, k-medois, k-medians, x-means, G-means, LBG, ISODATA, Fuzzy c-means, Possibilistic c-means, k-harmonic means, MacQueen, Hartigan-Wong, Elkan, Hamelry, Drake, Yinyang, Agglomerative (complete linkage, single linkage, group average, Ward's, centroid, weighted average, median), DIANA, Monothetic, Mutual kNN, Mean shift, DBSCAN, OPTICS, DTSCAN, HDBSCAN, DENCLUE, DBCLASD, BRIDGE, CLUES, PAM, CLARA, CLARANS, BIRCH, CURE, ROCK, C2P, PLSA, Latent dirichlet allocation, GMM, VBGMM, Affinity propagation, Spectral clustering, Mountain, (Growing) SOM, GTM, (Growing) Neural gas, Growing cell structures, LVQ, ART, SVC, CAST, CHAMELEON, COLL, CLIQUE, PROCLUS, ORCLUS, FINDIT, DOC, FastDOC, DiSH, NMF, Autoencoder
classification (Fisher's) Linear discriminant, Quadratic discriminant, Mixture discriminant, Least squares, (Multiclass / Kernel) Ridge, (Complement / Negation / Universal-set / Selective) Naive Bayes (gaussian), AODE, (Fuzzy / Weighted) k-nearest neighbor, Radius neighbor, Nearest centroid, ENN, ENaN, NNBCA, ADAMENN, DANN, IKNN, Decision tree, Random forest, Extra trees, GBDT, XGBoost, ALMA, (Aggressive) ROMMA, (Bounded) Online gradient descent, (Budgeted online) Passive aggressive, RLS, (Selective-sampling) Second order perceptron, AROW, NAROW, Confidence weighted, CELLIP, IELLIP, Normal herd, Stoptron, (Kernelized) Pegasos, MIRA, Forgetron, Projectron, Projectron++, Banditron, Ballseptron, (Multiclass) BSGD, ILK, SILK, (Multinomial) Logistic regression, (Multinomial) Probit, SVM, Gaussian process, HMM, CRF, Bayesian Network, LVQ, (Average / Multiclass / Voted / Kernelized / Selective-sampling / Margin / Shifting / Budget / Tighter / Tightest) Perceptron, PAUM, RBP, ADALINE, MADALINE, MLP, ELM, LMNN
semi-supervised classification k-nearest neighbor, Radius neighbor, Label propagation, Label spreading, k-means, GMM, S3VM, Ladder network
regression Least squares, Ridge, Lasso, Elastic net, RLS, Bayesian linear, Poisson, Least absolute deviations, Huber, Tukey, Least trimmed squares, Least median squares, Lp norm linear, SMA, Deming, Segmented, LOWESS, LOESS, spline, Naive Bayes, Gaussian process, Principal components, Partial least squares, Projection pursuit, Quantile regression, k-nearest neighbor, Radius neighbor, IDW, Nadaraya Watson, Priestley Chao, Gasser Muller, RBF Network, RVM, Decision tree, Random forest, Extra trees, GBDT, XGBoost, SVR, MLP, ELM, GMR, Isotonic, Ramer Douglas Peucker, Theil-Sen, Passing-Bablok, Repeated median
interpolation Nearest neighbor, IDW, (Spherical) Linear, Brahmagupta, Logarithmic, Cosine, (Inverse) Smoothstep, Cubic, (Centripetal) Catmull-Rom, Hermit, Polynomial, Lagrange, Trigonometric, Spline, RBF Network, Akima, Natural neighbor, Delaunay
learning to rank Ordered logistic, Ordered probit, PRank, OAP-BPM, RankNet
anomaly detection Percentile, MAD, Tukey's fences, Grubbs's test, Thompson test, Tietjen Moore test, Generalized ESD, Hotelling, MT, MCD, k-nearest neighbor, LOF, COF, ODIN, LDOF, INFLO, LOCI, LoOP, RDF, LDF, KDEOS, RDOS, NOF, RKOF, ABOD, PCA, OCSVM, KDE, GMM, Isolation forest, Autoencoder, GAN
dimensionality reduction Random projection, (Dual / Kernel / Incremental / Probabilistic) PCA, GPLVM, LSA, MDS, Linear discriminant analysis, NCA, ICA, Principal curve, Sammon, FastMap, Sliced inverse regression, LLE, HLLE, MLLE, Laplacian eigenmaps, Isomap, LTSA, Diffusion map, SNE, t-SNE, UMAP, SOM, GTM, NMF, MOD, K-SVD, Autoencoder, VAE
feature selection Mutual information, Ridge, Lasso, Elastic net, Decision tree, NCA
transformation Box-Cox, Yeo-Johnson
density estimation Histogram, Average shifted histogram, Polynomial histogram, Maximum likelihood, Kernel density estimation, k-nearest neighbor, Naive Bayes, GMM, HMM
generate MH, Slice sampling, GMM, GBRBM, HMM, VAE, GAN, NICE
smoothing (Linear weighted / Triangular / Cumulative) Moving average, Exponential average, Moving median, KZ filter, Savitzky Golay filter, Hampel filter, Kalman filter, Particle filter, Lowpass filter, Bessel filter, Butterworth filter, Chebyshev filter, Elliptic filter
timeseries prediction Holt winters, AR, ARMA, SDAR, VAR, Kalman filter, MLP, RNN
change point detection Cumulative sum, k-nearest neighbor, LOF, COF, SST, KLIEP, LSIF, uLSIF, LSDD, HMM, Markov switching
segmentation P-Tile, Automatic thresholding, Balanced histogram thresholding, Otsu's method, Sezan, Adaptive thresholding, Bernsen, Niblack, Sauvola, Phansalkar, Split and merge, Statistical Region Merging, Mean shift
denoising NL-means, Hopfield network, RBM, GBRBM
edge detection Roberts cross, Sobel, Prewitt, Laplacian, LoG, Canny, Snakes
word embedding Word2Vec
recommendation association analysis
markov decision process Dynamic programming, Monte carlo, Q learning, SARSA, Policy gradient, DQN, DDQN, A2C, Genetic algorithm
game DQN, DDQN

Models (only in package)

type model
clustering k-modes, k-prototypes, MONA
classification Categorical Naive Bayes, (Selective-sampling) Winnow
semi-supervised classification Semi-supervised Naive Bayes
regression Weighted least squares
interpolation Cubic convolution, Sinc, Lanczos, Bilinear, n-linear, n-cubic
scaling Max absolute scaler, Minmax normalization, Robust scaler, Standardization
density estimation ZINB, ZIP, ZTP
density ratio estimation RuLSIF

Models (meta)

type model
classification Binary ensemble, Probability based, RANSAC
semi-supervised classification Self-training, Co-training
regression RANSAC
change point detection Squared-loss Mutual information

Datas

name description
manual Create 2D or 1D data manually.
text Create text data manually.
function Create from a expression like exp(-(x ^ 2 + y ^ 2) / 2).
camera Images taken with a web camera
capture Images captured from a window
microphone Audio recorded with a microphone
upload Uploaded Text/CSV/Image file
Air passenger Famous 1D time series data
HR Diagram The Hertzsprung-Russell Diagram of the Star Cluster CYG OB1
Titanic Titanic data
UCI Data from UCI Machine Learning Repository
ESL Data from The Elements of Statistical Learning
StatLib Data from StatLib---Datasets Archive
MNIST handwritten digits
e-Stat Data from Statistics Dashboard (https://dashboard.e-stat.go.jp/en/)
Eurostat Data from Eurostat (https://ec.europa.eu/eurostat)
Pokémon Pokémon data (https://pokeapi.co/)

Reinforcement learning environment

name description
grid A simple maze on 2D grid world.
cartpole Stand the pole on the cart.
mountain car Drive the car up the hill.
acrobot Lift the double pendulum.
pendulum Lift the pendulum.
maze A maze on a fine grid plane.
waterball Moving amidst the drift of bait and poison.
blackjack Blackjack game.
draughts Draughts game.
reversi Reversi game.
gomoku Gomoku game.
breaker Breaker game.

NeuralNetwork layers

type name
basic input, output, supervisor, include, const, random, variable, activation
function absolute, acos, acosh, APL, Aranda, asin, asinh, atan, atanh, attention, batch normalization, BDAA, Bent identity, BLU, BReLU, ceil, CELU, cloglog, cloglogm, cos, cosh, CReLU, EELU, (hard) ELiSH, Elliott, ELU, embedding, EReLU, erf, ESwish, exp, FELU, full, floor, FReLU, gaussian, GELU, Hard shrink, Hexpo, identity, ISigmoid, layer normalization, Leaky ReLU, LiSHT, log, loglog, logsigmoid, mish, MPELU, MTLU, negative, NLReLU, PAU, PDELU, PELU, PLU, PReLU, PREU, PSF, pTanh, PTELU, reciprocal, ReLU, RePU, ReSech, REU, rootsig, round, RReLU, RTReLU, SELU, (hard) sigmoid, sign, SiLU, sin, sinh, SLAF, SLU, softmax, softplus, Soft shrink, softsign, sqrt, square, SReLU, SRS, sSigmoid, sTanh, (hard) Swish, TAF, tan, (hard) tanh, tanhExp, tanShrink, Thresholded ReLU
operator add, sub, mult, div, mod, matmul, power, max, min
logical and, bitwise and, bitwise not, bitwise or, bitwise xor, equal, greater, greater or equal, is inf, is nan, left bitshift, less, less or equal, not, or, right bitshift, xor
convolute convolution, (Global) MaxPool, (Global) AveragePool, (Global) LpPool, LRN
recurrent GRU, LSTM, Simple RNN
reduce sum, mean, prod, variance, std, reduce max, reduce min, argmax, softargmax
graph convolutional, SAGE, readout
loss Huber, MSE
other concat, split, detach, clip, dropout, One-hot, reshape, flatten, transpose, reverse, sparce, conditional, function

Contact

Twitter : @mirasunimoni

ai-on-browser.github.io's People

Contributors

ishii-norimi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ai-on-browser.github.io's Issues

[ENH]: Add Genetic k-means

Suggestion feature

Add Genetic k-means

Is this a feature to be added to the GUI or to the package?

GUI, package

[ENH]: More than 3 dimensions for functional data

Suggestion feature

Currently, functional data only create 1, 2 and 3D data.

Use x[dim] (same as least squares model, etc.) and supports 4 dimensions or more.

Is this a feature to be added to the GUI or to the package?

GUI

[ENH]: Improve Matrix class

Suggestion feature

  • copyXXX function to statistic function
  • resize and concat function work as inplace, and implement current behavior by static functions
  • sample function always returns index

Is this a feature to be added to the GUI or to the package?

package

[Bug]: Cannot resize the grid environment.

What happened?

Select Markov Decision Process and grid environment.
Then, when I change the columns or the rows, it returns a default value.

Did it occur on the screen or on the package?

GUI

Version

No response

Fix issue template

What happened?

Issue template feature-request.yml has problem.

And GUI/package selection should be optional.

GUI or package

GUI

Version

No response

Remove init_args from EnsembleBinaryModel

Argument init_args of EnsembleBinaryModel constructor is not required and is confusing.

Like RANSAC, remove init_args and remove all arguments of the constructor of the model being passed.

[ENH]: Make it possible to choose the method of AR model.

Suggestion feature

Currently, AR models are trained with lms (least squares method).

Other methods have already been implemented.
We want to be able to select one.

Is this a feature to be added to the GUI or to the package?

GUI, package

Import path is complex

What happened?

when I import some file (not index.js), the path is bit complex (also IDE show error with TS).

Make sure to export without shifting the hierarchy.

Did it occur on the screen or on the package?

package

Version

0.1.0

[ENH]: Not 255 but 1

Suggestion feature

Some image thresholding methods return an array of 0 or 255.

Maybe 255 is like a magic number, so use 1 instead.

Is this a feature to be added to the GUI or to the package?

package

[ENH]: Test the layer directly

Suggestion feature

Currently the test for layers is Indirect.

Create tests that run the layer directly.

Is this a feature to be added to the GUI or to the package?

package

[ENH]: Add Monothetic Clustering

Suggestion feature

Add Monothetic Clustering.

Not Monothetic Analysis Clustering (MONA)

Is this a feature to be added to the GUI or to the package?

GUI, package

Add STING

Add STING (STatistical INformation Grid-based method) clustering method.

[ENH]: Add HDBSCAN

Suggestion feature

Add HDBSCAN

Is this a feature to be added to the GUI or to the package?

GUI, package

[ENH]: To make it easy to create elements for modeling

Suggestion feature

Modeling uses D3.js directly to create elements.

Most processes are the same, so create a unified process and do not use D3.js directly.

Is this a feature to be added to the GUI or to the package?

GUI

[ENH]: Improve data rendering

Suggestion feature

All process of data rendering should be done in platform.

Is this a feature to be added to the GUI or to the package?

GUI

[ENH]: Improve Markov Switching

Suggestion feature

Constructor parameter d of Markov Switching is not necessary.
Remove it.

And fix small bug.

Is this a feature to be added to the GUI or to the package?

package

[ENH]: Remove dependency of Tree class in IsolationForest.

Suggestion feature

Tree class is bit complicated and IsolationForest only need few function.

Instead of using the Tree class, it is better to simply use an object.

Is this a feature to be added to the GUI or to the package?

package

[Bug]: Fix principal curve

What happened?

Principal curve does not work properly.

This is because it have failed to create an approximate curve.

Did it occur on the screen or on the package?

GUI, package

Version

0.4.0

[ENH]: Add paths-ignore for Github actions

Suggestion feature

Add paths-ignore in some actions like:

paths-ignore:
  - 'README.md'
  - '.gitignore'
  - '.github/**'

Is this a feature to be added to the GUI or to the package?

other

[ENH]: Use DFT in lowpass filter

Suggestion feature

Currently, the low-pass filter uses the FFT, which is a tricky calculation.
Simplify it by using the DFT (except for certain number of data).

Is this a feature to be added to the GUI or to the package?

package

[ENH]: Add Weighted k-means

Suggestion feature

Add Weighted k-means

Is this a feature to be added to the GUI or to the package?

GUI, package

Generalize the genetic algorithm

Currently, genetic algorithms are used only for reinforcement learning and are specialized for that.

Improve the internal implementation as a meta-algorithmic genetic algorithm.

[ENH]: Add Hessian LLE

Suggestion feature

Add Hessian LLE

Is this a feature to be added to the GUI or to the package?

GUI, package

[ENH]: Matrix norm

Suggestion feature

Matrix class only defines element-wise norm.

There are many other definition, so implement it.

Is this a feature to be added to the GUI or to the package?

package

[ENH]: Add DENCLUE

Suggestion feature

Add DENCLUE

Is this a feature to be added to the GUI or to the package?

GUI, package

[ENH]: Theil-Sen estimator

Suggestion feature

Add Theil-Sen estimator

Is this a feature to be added to the GUI or to the package?

GUI, package

Get sizes of random layer dynamically

The random layer needs to specify the number of columns, but it is complicated.
It should be possible to make it the same size as the output of a particular layer.

[ENH]: Add ExtraTrees

Suggestion feature

Add Extremely Randomized Trees(Extra Trees)

Is this a feature to be added to the GUI or to the package?

GUI, package

[ENH]: Add K-SVD

Suggestion feature

Add K-SVD

Is this a feature to be added to the GUI or to the package?

GUI, package

[ENH]: Add Slice sampling

Suggestion feature

Add Slice sampling

Is this a feature to be added to the GUI or to the package?

GUI, package

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.