Skip to content

deepbox

Installation

Install Deepbox from npm and import the modules you need.

Requirements

Deepbox needs Node.js 24.13 or newer, as declared in the engines field of its package.json. It is built and tested on Node 24 with a TypeScript ES2024 target. Older Node versions are not supported.

install.sh
npm install deepbox

Import model

Every module has its own subpath export. Import named APIs from the module that owns them. This keeps bundle boundaries explicit and works with tree shaking, because the package declares sideEffects: false.

imports.ts
import { tensor, zeros } from "deepbox/ndarray";import { DataFrame } from "deepbox/dataframe";import { StandardScaler } from "deepbox/preprocess";import { LinearRegression } from "deepbox/ml"; const a = tensor([1, 2, 3]);const b = zeros([2, 2]);const df = new DataFrame({ value: [1, 2, 3] });const scaler = new StandardScaler();const model = new LinearRegression();console.log(a.shape, b.shape, df.shape, scaler, model);

The root package exports each module as a namespace instead of exporting names directly. This is handy for quick scripts.

namespaces.ts
import * as db from "deepbox"; const x = db.ndarray.tensor([1, 2, 3]);const model = new db.ml.LinearRegression();console.log(x.shape, model);

Do not import names from the root

import { tensor } from "deepbox" does not work. The root package has no named exports other than the module namespaces.

TypeScript setup

Deepbox ships declaration files for the root and for every subpath. Use a module resolution mode that understands exports: "moduleResolution": "bundler", "node16" or "nodenext". The classic node mode cannot resolve the subpaths.

ESM and CommonJS builds are both published, so import and require work. The package is declared as type: module.

tsconfig.json
{  "compilerOptions": {    "target": "ES2024",    "module": "ESNext",    "moduleResolution": "bundler",    "strict": true  }}