Skip to content

deepbox

Conventions & Limits

Defaults that differ from NumPy, pandas, scikit-learn and PyTorch, and what Deepbox 1.x does not do yet.

Defaults that differ from the Python libraries

Deepbox follows the Python libraries closely, with a few exceptions. These defaults are kept in 1.x for compatibility and may change in 2.0. When you need to match a reference library, pass the option in the last column.

APIDeepbox defaultReference library
tensor() default dtypefloat32NumPy: float64. PyTorch: float32.
gelu, GELUtanh approximationPyTorch: exact (approximate: "none")
mapepercentagescikit-learn returns a fraction. Use meanAbsolutePercentageError for that.
PowerTransformer standardizefalsescikit-learn: true
DataFrame.ewm adjust and biasfalse and truepandas: true and false
DataFrame.groupBykeys in first-appearance order, missing keys keptpandas: sorted, missing dropped. Pass { sort: true, dropna: true }.
DataFrame.valueCountsmissing values countedpandas: dropped
Series.str.replace regextruepandas: false
InstanceNorm affinetruePyTorch: false
Upsample alignCorners (bilinear)truePyTorch: false
RNN, LSTM, GRU batchFirsttruePyTorch: false
RMSNorm eps1e-5PyTorch: machine epsilon of the dtype
FullTransformer final LayerNormnonePyTorch nn.Transformer: yes. Pass { finalNorm: true }.
DecisionTree*, RandomForest* maxDepth10scikit-learn: unlimited
LinearSVC loss"hinge"scikit-learn: squared hinge
LinearSVR epsilon0.1scikit-learn: 0
GaussianMixture covarianceType"diag"scikit-learn: "full"
KernelRidge gamma1.0scikit-learn: 1 / nFeatures
calibrationCurve nBins10scikit-learn: 5
Averaged metrics without average"binary" for two classes, "weighted" for morescikit-learn: "binary", and an error for multiclass input
solveTriangular lowertrueSciPy: upper (lower=False)
corrcoef on a matrixrows are observationsNumPy: rows are variables (rowvar=True)
expon and gamma scalea rateSciPy: scale = 1 / rate
imshow row 0bottom of the y axismatplotlib: top. Pass { origin: "upper" }.
clip(t, min, max) with min > maxthrows InvalidParameterErrorNumPy and PyTorch: return max

Naming differences

  • Fitted values are getters without scikit-learn's trailing underscore: model.coef, model.intercept, kmeans.labels, pca.components.
  • Options are camelCase (nEstimators, randomState, maxDepth), and optimizers take flat options such as beta1 and beta2 instead of a betas tuple.
  • crossValScore, crossValidate and GridSearchCV take a number of folds as cv, not a splitter object. Splitters in deepbox/preprocess return arrays of { trainIndex, testIndex }.
  • Seeded random streams are reproducible inside Deepbox. They are not bit-identical to NumPy or PyTorch.

Known limits

  • complex64 and complex128 appear in the DType type, but tensors cannot be created with them yet. FFT functions return { real, imag } tensors.
  • WebGPU and WASM accelerate a subset of operations. The rest throw a DeviceError on WebGPU. See Devices & Execution.
  • Deepbox is plain TypeScript. Operations bound by BLAS, such as large matrix multiplies and decompositions, are slower than NumPy with LAPACK.
  • eig supports real eigenvalues only, and the linalg functions work on 2-D matrices.
  • WorkerPool runs its chunks in order on the calling thread, so it adds no parallelism. sparseSolve expands the matrix into a dense workspace, so memory grows as O(N^2).
  • Dates are local-time JavaScript Date values, and there is no time zone support.

Errors

Every module throws subclasses of DeepboxError: ShapeError, DTypeError, InvalidParameterError, NotFittedError, DeviceError, ConvergenceError and others. Catch the specific class you care about, and use instanceof DeepboxError to catch them all.

errors.ts
import { DeepboxError, ShapeError } from "deepbox/core";import { add, tensor } from "deepbox/ndarray"; try {  add(tensor([1, 2, 3]), tensor([1, 2]));} catch (error) {  console.log(error instanceof ShapeError, error instanceof DeepboxError);}