{"_id":"@dheuv/xgboost-wasm","_rev":"2-5dbfad8ecb2aaaae827bb28301c4eb33","name":"@dheuv/xgboost-wasm","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@dheuv/xgboost-wasm","version":"1.0.0","_id":"@dheuv/xgboost-wasm@1.0.0","maintainers":[{"name":"dheuv","email":"Dhruvdukle@yahoo.com"}],"dist":{"shasum":"fb5a870454d0ce76411a0d6f7a8d3f0c209276d9","tarball":"https://registry.npmjs.org/@dheuv/xgboost-wasm/-/xgboost-wasm-1.0.0.tgz","fileCount":9,"integrity":"sha512-hFmOGLfear1kaErJ9G/nPG4w93OPFwepqu3msxq82ihS5HPxX6IH8kQTRWw9vuUfKV27j4gdLy6zSAaqQcliWg==","signatures":[{"sig":"MEQCIEyAapkPcGFIOIfv+/A+juLTcQBnfB0MODeklWwcpjORAiA7JKGxj0GWwNl735P29aWylQgqI5m2GuKmjKtTL+zNBA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3485797},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.mjs","gitHead":"4efdd7623222f6e3475218a390c41d507964d83c","scripts":{"test":"vitest","build":"npm run build:cpp && npm run build:js","build:js":"rollup -c","build:cpp":"./scripts/build_wasm.sh"},"_npmUser":{"name":"dheuv","email":"Dhruvdukle@yahoo.com"},"_npmVersion":"11.6.0","description":"XGBoost WebAssembly library for Node.js and Browser","directories":{},"_nodeVersion":"24.8.0","dependencies":{"tslib":"^2.8.1"},"_hasShrinkwrap":false,"devDependencies":{"rollup":"^4.0.0","vitest":"^0.34.0","typescript":"^5.0.0","@rollup/plugin-terser":"^0.4.0","@rollup/plugin-commonjs":"^25.0.0","@rollup/plugin-typescript":"^11.0.0","@rollup/plugin-node-resolve":"^15.0.0"},"_npmOperationalInternal":{"tmp":"tmp/xgboost-wasm_1.0.0_1771863169726_0.9635052265145931","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@dheuv/xgboost-wasm","version":"1.0.1","description":"XGBoost WebAssembly library for Node.js and Browser","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","scripts":{"build:cpp":"./scripts/build_wasm.sh","build:js":"rollup -c","build":"npm run build:cpp && npm run build:js","test":"vitest"},"devDependencies":{"@rollup/plugin-commonjs":"^25.0.0","@rollup/plugin-node-resolve":"^15.0.0","@rollup/plugin-terser":"^0.4.0","@rollup/plugin-typescript":"^11.0.0","rollup":"^4.0.0","typescript":"^5.0.0","vitest":"^0.34.0"},"dependencies":{"tslib":"^2.8.1","ws":"^8.18.0"},"_id":"@dheuv/xgboost-wasm@1.0.1","gitHead":"2f542588b0efaa23bfa7d20f66aba66aa27421c2","_nodeVersion":"24.8.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-GFtWkZyLm5ykj3Km1ELykkTaH1OuqKkj11h5UnG0AmqfjzyTUp1mPRsLqC5A3wZ7dW6wDcSaqelU8lAu1OrFpg==","shasum":"c307ccf7f126d654916cc7e19d33c35a8861e230","tarball":"https://registry.npmjs.org/@dheuv/xgboost-wasm/-/xgboost-wasm-1.0.1.tgz","fileCount":9,"unpackedSize":3756492,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHKDaO1zADZQKHetno2ANHk7x2m9xolv9BZe7xUvAfugAiAJc9GIIUsChHxQ6XxdfnfHOOXPY8Otc4Y7KikvC6TP1w=="}]},"_npmUser":{"name":"dheuv","email":"Dhruvdukle@yahoo.com"},"directories":{},"maintainers":[{"name":"dheuv","email":"Dhruvdukle@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/xgboost-wasm_1.0.1_1771869771771_0.6476839838014281"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-23T16:12:49.614Z","modified":"2026-02-23T18:02:52.114Z","1.0.0":"2026-02-23T16:12:49.938Z","1.0.1":"2026-02-23T18:02:51.999Z"},"description":"XGBoost WebAssembly library for Node.js and Browser","maintainers":[{"name":"dheuv","email":"Dhruvdukle@yahoo.com"}],"readme":"# @dheuv/xgboost-wasm\n\nXGBoost WebAssembly library for Node.js and the Browser.\n\n## Features\n- **Full XGBoost Support**: Train and predict using the state-of-the-art Gradient Boosting framework.\n- **Cross-Platform**: Runs in modern browsers and Node.js environments.\n- **High Performance**: Compiled with Emscripten with `-O3` optimizations.\n- **TypeScript First**: Full Type definitions included.\n\n## Installation\n\n```bash\nnpm install @dheuv/xgboost-wasm\n```\n\n## Quick Start (XOR Example)\n\n```typescript\nimport { XGBoost } from '@dheuv/xgboost-wasm';\n\nasync function run() {\n    // Initialize the WASM module\n    const xgboost = await XGBoost.create();\n\n    // Prepare data (Input features and target labels)\n    const data = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]);\n    const labels = new Float32Array([0, 1, 1, 0]);\n\n    // Create a DMatrix\n    const dtrain = xgboost.createDMatrix(data, 4, 2, NaN, labels);\n\n    // Set training parameters\n    const params = {\n        'objective': 'binary:logistic',\n        'eval_metric': 'logloss',\n        'max_depth': '3',\n        'eta': '0.1',\n        'min_child_weight': '0',\n        'num_feature': '2' // Required in WASM raw interface\n    };\n\n    // Train the model\n    const booster = await xgboost.train(dtrain, params, 50);\n\n    // Make predictions\n    const dtest = xgboost.createDMatrix(data, 4, 2);\n    const predictions = JSON.parse(booster.predict(dtest));\n    \n    console.log('Predictions:', predictions);\n}\n\nrun();\n```\n\n## API Reference\n\n### `XGBoost`\nThe main entry point for the library.\n\n- `static async create(overrides?: any): Promise<XGBoost>`: Initializes and returns an instance of the XGBoost class.\n- `createDMatrix(data: Float32Array, nrow: number, ncol: number, missing?: number, labels?: Float32Array): DMatrix`: Creates a DMatrix from a Float32Array.\n- `async train(dtrain: DMatrix, params: Record<string, string>, nround: number): Promise<Booster>`: Trains a booster with the given parameters.\n- `version(): string`: Returns the XGBoost version.\n\n### `Booster`\nA trained XGBoost model.\n\n- `predict(dmat: DMatrix, option?: number, ntree_limit?: number): string`: Makes predictions on a DMatrix. Returns a JSON string of results.\n- `saveModel(path: string): void`: Saves the model to a path (Node.js only or virtual FS).\n- `loadModel(path: string): void`: Loads a model from a path.\n\n### `DMatrix`\nData matrix used by XGBoost.\n\n- `getNumRow(): number`: Returns the number of rows.\n- `getNumCol(): number`: Returns the number of columns.\n\n## Build Instructions\n\nIf you want to build the library from source:\n\n1. Install [Emscripten](https://emscripten.org/).\n2. Run the build script:\n```bash\nnpm run build\n```\n\n## Limitations\n- **Memory**: Default initial memory is 64MB, grows automatically. Max memory is constrained by WASM limits.\n- **Single Threaded**: This WASM build currently runs in single-threaded mode (no OpenMP).\n- **Stack Size**: Increased to 5MB to accommodate deep trees and complex training.\n\n## License\nApache-2.0\n","readmeFilename":"README.md"}