0.20.0 • Published 2 months ago

@ai-on-browser/data-analysis-models v0.20.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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/data-analysis-models@0.20.0/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)

taskmodel
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, 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, 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, LMNN
semi-supervised classificationk-nearest neighbor, Radius neighbor, Label propagation, Label spreading, k-means, GMM, S3VM, Ladder network
regressionLeast 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, GMR, Isotonic, Ramer Douglas Peucker, Theil-Sen, Passing-Bablok, Repeated median
interpolationNearest 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 rankOrdered logistic, Ordered probit, PRank, OAP-BPM, RankNet
anomaly detectionPercentile, 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 reductionRandom 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 selectionMutual information, Ridge, Lasso, Elastic net, Decision tree, NCA
transformationBox-Cox, Yeo-Johnson
density estimationHistogram, Average shifted histogram, Polynomial histogram, Maximum likelihood, Kernel density estimation, k-nearest neighbor, Naive Bayes, GMM, HMM
generateMH, 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 predictionHolt winters, AR, ARMA, SDAR, VAR, Kalman filter, MLP, RNN
change point detectionCumulative sum, k-nearest neighbor, LOF, COF, SST, KLIEP, LSIF, uLSIF, LSDD, HMM, Markov switching
segmentationP-Tile, Automatic thresholding, Balanced histogram thresholding, Otsu's method, Sezan, Adaptive thresholding, Bernsen, Niblack, Sauvola, Phansalkar, Split and merge, Statistical Region Merging, Mean shift
denoisingNL-means, Hopfield network, RBM, GBRBM
edge detectionRoberts cross, Sobel, Prewitt, Laplacian, LoG, Canny, Snakes
word embeddingWord2Vec
recommendationassociation analysis
markov decision processDynamic programming, Monte carlo, Q learning, SARSA, Policy gradient, DQN, DDQN, A2C, Genetic algorithm
gameDQN, DDQN

Models (only in package)

typemodel
clusteringk-modes, k-prototypes, MONA
classificationCategorical Naive Bayes, (Selective-sampling) Winnow
semi-supervised classificationSemi-supervised Naive Bayes
regressionWeighted least squares
interpolationCubic convolution, Sinc, Lanczos, Bilinear, n-linear, n-cubic
scalingMax absolute scaler, Minmax normalization, Robust scaler, Standardization
density estimationZINB, ZIP, ZTP
density ratio estimationRuLSIF

Models (meta)

typemodel
classificationBinary ensemble, Probability based, RANSAC
semi-supervised classificationSelf-training, Co-training
regressionRANSAC
change point detectionSquared-loss Mutual information

Datas

namedescription
manualCreate 2D or 1D data manually.
textCreate text data manually.
functionCreate from a expression like exp(-(x ^ 2 + y ^ 2) / 2).
cameraImages taken with a web camera
captureImages captured from a window
microphoneAudio recorded with a microphone
uploadUploaded Text/CSV/Image file
Air passengerFamous 1D time series data
HR DiagramThe Hertzsprung-Russell Diagram of the Star Cluster CYG OB1
TitanicTitanic data
UCIData from UCI Machine Learning Repository
ESLData from The Elements of Statistical Learning
StatLibData from StatLib---Datasets Archive
MNISThandwritten digits
e-StatData from Statistics Dashboard (https://dashboard.e-stat.go.jp/en/)
PokémonPokémon data (https://pokeapi.co/)

Reinforcement learning environment

namedescription
gridA simple maze on 2D grid world.
cartpoleStand the pole on the cart.
mountain carDrive the car up the hill.
acrobotLift the double pendulum.
pendulumLift the pendulum.
mazeA maze on a fine grid plane.
waterballMoving amidst the drift of bait and poison.
blackjackBlackjack game.
draughtsDraughts game.
reversiReversi game.
gomokuGomoku game.
breakerBreaker game.

NeuralNetwork layers

typename
basicinput, output, supervisor, include, const, random, variable, activation
functionabsolute, 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
operatoradd, sub, mult, div, mod, matmul, power, max, min
logicaland, 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
convoluteconvolution, (Global) MaxPool, (Global) AveragePool, (Global) LpPool, LRN
recurrentGRU, LSTM, Simple RNN
reducesum, mean, prod, variance, std, reduce max, reduce min, argmax, softargmax
graphconvolutional, SAGE, readout
lossHuber, MSE
otherconcat, split, detach, clip, dropout, One-hot, reshape, flatten, transpose, reverse, sparce, conditional, function

Contact

Twitter : @mirasunimoni

0.20.0

2 months ago

0.19.0

4 months ago

0.18.0

6 months ago

0.17.0

8 months ago

0.16.1

10 months ago

0.16.0

12 months ago

0.15.0

1 year ago

0.14.0

1 year ago

0.13.0

1 year ago

0.12.0

2 years ago

0.11.0

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.7.2

2 years ago

0.8.0

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.5.0

2 years ago

0.6.0

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.19

2 years ago

0.1.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.0.26

2 years ago

0.4.0

2 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.18

2 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago