deepbox
Conventions & Limits
Defaults that differ from NumPy, pandas, scikit-learn and PyTorch, and what Deepbox 1.x does not do yet.
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.
| API | Deepbox default | Reference library |
|---|---|---|
tensor() default dtype | float32 | NumPy: float64. PyTorch: float32. |
gelu, GELU | tanh approximation | PyTorch: exact (approximate: "none") |
mape | percentage | scikit-learn returns a fraction. Use meanAbsolutePercentageError for that. |
PowerTransformer standardize | false | scikit-learn: true |
DataFrame.ewm adjust and bias | false and true | pandas: true and false |
DataFrame.groupBy | keys in first-appearance order, missing keys kept | pandas: sorted, missing dropped. Pass { sort: true, dropna: true }. |
DataFrame.valueCounts | missing values counted | pandas: dropped |
Series.str.replace regex | true | pandas: false |
InstanceNorm affine | true | PyTorch: false |
Upsample alignCorners (bilinear) | true | PyTorch: false |
RNN, LSTM, GRU batchFirst | true | PyTorch: false |
RMSNorm eps | 1e-5 | PyTorch: machine epsilon of the dtype |
FullTransformer final LayerNorm | none | PyTorch nn.Transformer: yes. Pass { finalNorm: true }. |
DecisionTree*, RandomForest* maxDepth | 10 | scikit-learn: unlimited |
LinearSVC loss | "hinge" | scikit-learn: squared hinge |
LinearSVR epsilon | 0.1 | scikit-learn: 0 |
GaussianMixture covarianceType | "diag" | scikit-learn: "full" |
KernelRidge gamma | 1.0 | scikit-learn: 1 / nFeatures |
calibrationCurve nBins | 10 | scikit-learn: 5 |
Averaged metrics without average | "binary" for two classes, "weighted" for more | scikit-learn: "binary", and an error for multiclass input |
solveTriangular lower | true | SciPy: upper (lower=False) |
corrcoef on a matrix | rows are observations | NumPy: rows are variables (rowvar=True) |
expon and gamma scale | a rate | SciPy: scale = 1 / rate |
imshow row 0 | bottom of the y axis | matplotlib: top. Pass { origin: "upper" }. |
clip(t, min, max) with min > max | throws InvalidParameterError | NumPy and PyTorch: return max |
- 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 asbeta1andbeta2instead of abetastuple. crossValScore,crossValidateandGridSearchCVtake a number of folds ascv, not a splitter object. Splitters indeepbox/preprocessreturn arrays of{ trainIndex, testIndex }.- Seeded random streams are reproducible inside Deepbox. They are not bit-identical to NumPy or PyTorch.
complex64andcomplex128appear in theDTypetype, 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
DeviceErroron 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.
eigsupports real eigenvalues only, and thelinalgfunctions work on 2-D matrices.WorkerPoolruns its chunks in order on the calling thread, so it adds no parallelism.sparseSolveexpands the matrix into a dense workspace, so memory grows as O(N^2).- Dates are local-time JavaScript
Datevalues, and there is no time zone support.
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.
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);}Found a mistake? Open an issue.