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 🙏

© 2026 – Pkg Stats / Ryan Hefner

argonz-ml

v1.0.0

Published

A lightweight nodejs library for machine learning algorithms

Readme

Machine Learning Library

This is a lightweight JavaScript library for implementing various machine learning algorithms. The library includes the following algorithms:

  1. Linear Regression
  2. Logistic Regression
  3. Support Vector Machine (SVM)
  4. Decision Tree
  5. Random Forest
  6. XGBoost

The library is designed to be modular, easy to use, and extensible. Below is the documentation for installation, usage, and examples.


Table of Contents

  1. Installation
  2. Usage
  3. Model Class
  4. Examples
  5. Running the Code

Installation

To use this library, you need to have Node.js and npm installed. Follow these steps:

  1. Clone the repository or download the source code.

  2. Navigate to the project directory.

  3. Install the required dependencies:

    npm install mathjs
  4. Import the library into your project:

    const { Model } = require('argonz-ml');

Usage

The library provides a unified Model class to instantiate and use any of the supported algorithms. Below are the details for each algorithm.

Linear Regression

  • Description: A linear regression model with Ridge regularization.
  • Options:
    • lambda (default: 0.01): Regularization parameter.
const model = new Model('linear_regression', { lambda: 0.01 });

Logistic Regression

  • Description: A logistic regression model for binary classification.
  • Options:
    • learningRate (default: 0.01): Learning rate for gradient descent.
    • iterations (default: 1000): Number of training iterations.
const model = new Model('logistic_regression', { learningRate: 0.01, iterations: 1000 });

SVM

  • Description: A Support Vector Machine (SVM) for binary classification.
  • Options:
    • learningRate (default: 0.01): Learning rate for gradient descent.
    • lambda (default: 0.1): Regularization parameter.
    • iterations (default: 1000): Number of training iterations.
const model = new Model('svm', { learningRate: 0.01, lambda: 0.1, iterations: 1000 });

Decision Tree

  • Description: A decision tree for classification or regression.
  • Options:
    • maxDepth (default: 5): Maximum depth of the tree.
const model = new Model('decision_tree', { maxDepth: 5 });

Random Forest

  • Description: A random forest ensemble of decision trees.
  • Options:
    • nTrees (default: 10): Number of trees in the forest.
    • maxDepth (default: 5): Maximum depth of each tree.
    • featureSubsetSize (default: sqrt(nFeatures)): Number of features to consider for each split.
const model = new Model('random_forest', { nTrees: 10, maxDepth: 5 });

XGBoost

  • Description: An implementation of the XGBoost algorithm for regression.
  • Options:
    • nTrees (default: 10): Number of trees.
    • learningRate (default: 0.1): Learning rate.
    • maxDepth (default: 3): Maximum depth of each tree.
    • lambda (default: 1.0): Regularization parameter.
const model = new Model('xgboost', { nTrees: 10, learningRate: 0.1, maxDepth: 3, lambda: 1.0 });

Model Class

The Model class provides a unified interface for training, predicting, and evaluating models.

Methods

  1. train(X, y):

    • Trains the model on the input data X and target labels y.
  2. predict(X):

    • Predicts the target values for the input data X.
  3. evaluate(yTrue, yPred):

    • Evaluates the model's performance by comparing true labels yTrue with predicted labels yPred.

Examples

Example 1: Linear Regression

const { Model } = require('argonz-ml');

// Example data
const X = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
    [10, 11, 12]
];
const y = [10, 20, 30, 40];

// Create and train the model
const model = new Model('linear_regression', { lambda: 0.01 });
model.train(X, y);

// Make predictions
const predictions = model.predict(X);

// Evaluate the model
const evaluation = model.evaluate(y, predictions);

console.log("Predictions:", predictions);
console.log("Evaluation:", evaluation);

Example 2: Logistic Regression

const { Model } = require('argonz-ml');

// Example data
const X = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
    [10, 11, 12]
];
const y = [0, 1, 0, 1]; // Binary classification

// Create and train the model
const model = new Model('logistic_regression', { learningRate: 0.01, iterations: 1000 });
model.train(X, y);

// Make predictions
const predictions = model.predict(X);

// Evaluate the model
const evaluation = model.evaluate(y, predictions);

console.log("Predictions:", predictions);
console.log("Evaluation:", evaluation);

Example 3: Random Forest

const { Model } = require('argonz-ml');

// Example data
const X = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
    [10, 11, 12]
];
const y = [0, 1, 0, 1]; // Binary classification

// Create and train the model
const model = new Model('random_forest', { nTrees: 10, maxDepth: 5 });
model.train(X, y);

// Make predictions
const predictions = model.predict(X);

// Evaluate the model
const evaluation = model.evaluate(y, predictions);

console.log("Predictions:", predictions);
console.log("Evaluation:", evaluation);

Running the Code

  1. Save the code in a file, e.g., example.js.

  2. Run the file using Node.js:

    node example.js
  3. You should see the predictions and evaluation metrics printed in the console.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.


Contact

For questions or feedback, please contact Argonz Company.


Enjoy using the Machine Learning Library! 🚀