Sign In

ml-toolkit-ts

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry
This package has malicious versions linked to the ongoing "Mini Shai-Hulud" supply chain attack.

Affected versions:

1.0.41.0.5
View campaign page

ml-toolkit-ts

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

ml-toolkit-ts

A TypeScript toolkit for machine learning inference and operations.

Run your XGBoost models trained with ElectronML directly in TypeScript/JavaScript!

Installation

Install everything:

npm install ml-toolkit-ts

Or install specific packages:

npm install @ml-toolkit-ts/xgboost
npm install @ml-toolkit-ts/preprocessing

Usage

1. Load your inference package

Use the JSON file you created with ElectronML.

// Type definition for inference package
interface InferencePackage {
  model: any;                                    
  preprocessing_metadata: any;                   
  feature_names: string[];                       
  class_mapping: Record<number, string>;         
  isRegression: boolean;                         
}

// Browser: using async/await
async function loadModel() {
  const inferencePackage = await fetch('model/inference_package.json')
    .then(response => response.json());
    // Use inferencePackage...
}

// Node.js
import * as fs from 'fs';
const inferencePackage = JSON.parse(
  fs.readFileSync('model/inference_package.json', 'utf-8')
);

2. Initialize predictor and preprocessor

// Using the complete package
import { XGBoostPredictor, DataPreprocessor } from 'ml-toolkit-ts';

// Or import specific packages
import { XGBoostPredictor } from '@ml-toolkit-ts/xgboost';
import { DataPreprocessor } from '@ml-toolkit-ts/preprocessing';


const predictor = new XGBoostPredictor(JSON.stringify(inferencePackage.model));
const preprocessor = new DataPreprocessor(JSON.stringify(inferencePackage.preprocessing_metadata));

3. Make predictions

For classification:

const inputValues = {
  age: "25",
  income: "50000",
  category: "A"
};

const transformedFeatures = preprocessor.transform(inputValues);
const predictedClass = predictor.predict(transformedFeatures);
const probabilities = predictor.predict_proba(transformedFeatures);

console.log('Predicted class:', inferencePackage.class_mapping[predictedClass]);
console.log('Probabilities:', probabilities);
// Output:
// Predicted class: high_risk
// Probabilities: [0.15, 0.85]  // 15% low_risk, 85% high_risk

For regression:

const inputValues = {
  sqft: "1500",
  bedrooms: "3",
  location: "urban"
};

const transformedFeatures = preprocessor.transform(inputValues);
const prediction = predictor.predict(transformedFeatures);

console.log('Predicted price:', prediction);
// Output:
// Predicted price: 450000

FAQs

Package last updated on 11 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts