deepbox 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +39 -37
  3. package/dist/{CSRMatrix-KzNt6QpS.d.ts → CSRMatrix-B7XtUAZO.d.cts} +3 -3
  4. package/dist/{CSRMatrix-CwGwQRea.d.cts → CSRMatrix-CtD23fRM.d.ts} +3 -3
  5. package/dist/{Tensor-BQLk1ltW.d.cts → Tensor-BORFp_zt.d.ts} +27 -7
  6. package/dist/{Tensor-g8mUClel.d.ts → Tensor-fxBg-TFZ.d.cts} +27 -7
  7. package/dist/{chunk-FJYLIGJX.js → chunk-3AX37GPK.js} +33 -7
  8. package/dist/chunk-3AX37GPK.js.map +1 -0
  9. package/dist/{chunk-PR647I7R.js → chunk-3YFEYDHN.js} +21 -4
  10. package/dist/chunk-3YFEYDHN.js.map +1 -0
  11. package/dist/{chunk-XMWVME2W.js → chunk-6SX26MAJ.js} +4 -4
  12. package/dist/{chunk-XMWVME2W.js.map → chunk-6SX26MAJ.js.map} +1 -1
  13. package/dist/{chunk-C4PKXY74.cjs → chunk-6X7XFNDO.cjs} +94 -77
  14. package/dist/chunk-6X7XFNDO.cjs.map +1 -0
  15. package/dist/{chunk-6AE5FKKQ.cjs → chunk-724CXHFH.cjs} +1211 -919
  16. package/dist/chunk-724CXHFH.cjs.map +1 -0
  17. package/dist/{chunk-AU7XHGKJ.js → chunk-AJTKVBY5.js} +4 -4
  18. package/dist/{chunk-AU7XHGKJ.js.map → chunk-AJTKVBY5.js.map} +1 -1
  19. package/dist/{chunk-ZB75FESB.cjs → chunk-AV6WGSYX.cjs} +130 -104
  20. package/dist/chunk-AV6WGSYX.cjs.map +1 -0
  21. package/dist/{chunk-ZLW62TJG.cjs → chunk-BWOSU234.cjs} +142 -141
  22. package/dist/chunk-BWOSU234.cjs.map +1 -0
  23. package/dist/{chunk-4S73VUBD.js → chunk-CZOMBUI7.js} +3 -3
  24. package/dist/chunk-CZOMBUI7.js.map +1 -0
  25. package/dist/{chunk-QERHVCHC.cjs → chunk-EUZHJDZ6.cjs} +419 -364
  26. package/dist/chunk-EUZHJDZ6.cjs.map +1 -0
  27. package/dist/{chunk-AD436M45.js → chunk-G2G55ATL.js} +120 -58
  28. package/dist/chunk-G2G55ATL.js.map +1 -0
  29. package/dist/{chunk-5R4S63PF.js → chunk-G3WNLNYS.js} +119 -64
  30. package/dist/chunk-G3WNLNYS.js.map +1 -0
  31. package/dist/{chunk-XEG44RF6.cjs → chunk-G7KXZHG6.cjs} +105 -95
  32. package/dist/chunk-G7KXZHG6.cjs.map +1 -0
  33. package/dist/{chunk-MLBMYKCG.js → chunk-H3JR7SV2.js} +255 -113
  34. package/dist/chunk-H3JR7SV2.js.map +1 -0
  35. package/dist/{chunk-PHV2DKRS.cjs → chunk-HDKMIG6E.cjs} +107 -107
  36. package/dist/{chunk-PHV2DKRS.cjs.map → chunk-HDKMIG6E.cjs.map} +1 -1
  37. package/dist/{chunk-ALS7ETWZ.cjs → chunk-HI2EZHCJ.cjs} +111 -102
  38. package/dist/chunk-HI2EZHCJ.cjs.map +1 -0
  39. package/dist/{chunk-OX6QXFMV.cjs → chunk-IT4BZUYE.cjs} +490 -428
  40. package/dist/chunk-IT4BZUYE.cjs.map +1 -0
  41. package/dist/{chunk-E3EU5FZO.cjs → chunk-JTZPRV6E.cjs} +123 -123
  42. package/dist/{chunk-E3EU5FZO.cjs.map → chunk-JTZPRV6E.cjs.map} +1 -1
  43. package/dist/{chunk-PL7TAYKI.js → chunk-K2L5C5YH.js} +8 -7
  44. package/dist/chunk-K2L5C5YH.js.map +1 -0
  45. package/dist/{chunk-BCR7G3A6.js → chunk-KCF6P34A.js} +356 -64
  46. package/dist/chunk-KCF6P34A.js.map +1 -0
  47. package/dist/{chunk-ZXKBDFP3.js → chunk-LZHVHD62.js} +15 -6
  48. package/dist/chunk-LZHVHD62.js.map +1 -0
  49. package/dist/{chunk-LWECRCW2.cjs → chunk-MTJF52AJ.cjs} +141 -141
  50. package/dist/{chunk-LWECRCW2.cjs.map → chunk-MTJF52AJ.cjs.map} +1 -1
  51. package/dist/{chunk-B5TNKUEY.js → chunk-NDDTUFKK.js} +16 -6
  52. package/dist/chunk-NDDTUFKK.js.map +1 -0
  53. package/dist/{chunk-DWZY6PIP.cjs → chunk-NOQI6OFL.cjs} +615 -473
  54. package/dist/chunk-NOQI6OFL.cjs.map +1 -0
  55. package/dist/{chunk-F3JWBINJ.js → chunk-OEXDJFHA.js} +4 -4
  56. package/dist/{chunk-F3JWBINJ.js.map → chunk-OEXDJFHA.js.map} +1 -1
  57. package/dist/{chunk-JSCDE774.cjs → chunk-Z6BGACIH.cjs} +3 -3
  58. package/dist/chunk-Z6BGACIH.cjs.map +1 -0
  59. package/dist/core/index.cjs +50 -50
  60. package/dist/core/index.d.cts +2 -2
  61. package/dist/core/index.d.ts +2 -2
  62. package/dist/core/index.js +1 -1
  63. package/dist/dataframe/index.cjs +6 -6
  64. package/dist/dataframe/index.d.cts +3 -3
  65. package/dist/dataframe/index.d.ts +3 -3
  66. package/dist/dataframe/index.js +3 -3
  67. package/dist/datasets/index.cjs +34 -34
  68. package/dist/datasets/index.d.cts +3 -3
  69. package/dist/datasets/index.d.ts +3 -3
  70. package/dist/datasets/index.js +3 -3
  71. package/dist/{index-C1mfVYoo.d.ts → index-B18dHc8q.d.ts} +81 -46
  72. package/dist/{index-GFAVyOWO.d.ts → index-BHHX0qTY.d.cts} +14 -12
  73. package/dist/{index-tk4lSYod.d.ts → index-BI6QOUvV.d.ts} +106 -80
  74. package/dist/{index-DIp_RrRt.d.ts → index-BKvK21lf.d.ts} +13 -35
  75. package/dist/{index-BJY2SI4i.d.ts → index-BL8jLf3K.d.cts} +12 -11
  76. package/dist/{index-Cn3SdB0O.d.ts → index-BNbX167d.d.cts} +16 -10
  77. package/dist/{index-BWGhrDlr.d.ts → index-BT2ofL7Z.d.cts} +35 -35
  78. package/dist/{index-BbA2Gxfl.d.ts → index-BqcfIcL4.d.ts} +15 -15
  79. package/dist/{index-ZtI1Iy4L.d.ts → index-BrgrECM2.d.ts} +41 -38
  80. package/dist/{index-CDw5CnOU.d.ts → index-BtYKI9yJ.d.ts} +10 -8
  81. package/dist/{index-DIT_OO9C.d.cts → index-C7nLsAOC.d.cts} +10 -8
  82. package/dist/{index-D9Loo1_A.d.cts → index-CNj2Mxwf.d.cts} +81 -46
  83. package/dist/{index-DmEg_LCm.d.cts → index-CYlxeNW1.d.cts} +5 -3
  84. package/dist/{index-D61yaSMY.d.cts → index-CiTd61a5.d.ts} +12 -11
  85. package/dist/{index-BndMbqsM.d.ts → index-Cjnn0KeN.d.cts} +35 -21
  86. package/dist/{index-9oQx1HgV.d.cts → index-CkGGAn69.d.cts} +41 -38
  87. package/dist/{index-74AB8Cyh.d.cts → index-D4URSgqA.d.ts} +16 -10
  88. package/dist/{index-DoPWVxPo.d.cts → index-D4pn5zLT.d.ts} +35 -21
  89. package/dist/{index-DuCxd-8d.d.ts → index-D9ztTlDr.d.ts} +60 -42
  90. package/dist/{index-BgHYAoSS.d.cts → index-DF28ZPB5.d.cts} +60 -42
  91. package/dist/{index-eJgeni9c.d.cts → index-DLdiQzf0.d.cts} +106 -80
  92. package/dist/{index-WHQLn0e8.d.cts → index-DN4omPQw.d.ts} +35 -35
  93. package/dist/{index-CrqLlS-a.d.ts → index-DUnFq1WV.d.ts} +5 -3
  94. package/dist/{index-DbultU6X.d.cts → index-DgaYshkF.d.ts} +14 -12
  95. package/dist/{index-B_DK4FKY.d.cts → index-GUHYEhxs.d.cts} +13 -35
  96. package/dist/{index-CCvlwAmL.d.cts → index-TP--4irE.d.cts} +16 -14
  97. package/dist/{index-Dx42TZaY.d.ts → index-x0z_sanT.d.ts} +16 -14
  98. package/dist/{index-DyZ4QQf5.d.cts → index-xWH7ujWa.d.cts} +15 -15
  99. package/dist/index.cjs +26 -26
  100. package/dist/index.d.cts +17 -17
  101. package/dist/index.d.ts +17 -17
  102. package/dist/index.js +13 -13
  103. package/dist/linalg/index.cjs +22 -22
  104. package/dist/linalg/index.d.cts +3 -3
  105. package/dist/linalg/index.d.ts +3 -3
  106. package/dist/linalg/index.js +3 -3
  107. package/dist/metrics/index.cjs +40 -40
  108. package/dist/metrics/index.d.cts +3 -3
  109. package/dist/metrics/index.d.ts +3 -3
  110. package/dist/metrics/index.js +3 -3
  111. package/dist/ml/index.cjs +23 -23
  112. package/dist/ml/index.d.cts +3 -3
  113. package/dist/ml/index.d.ts +3 -3
  114. package/dist/ml/index.js +4 -4
  115. package/dist/ndarray/index.cjs +125 -125
  116. package/dist/ndarray/index.d.cts +5 -5
  117. package/dist/ndarray/index.d.ts +5 -5
  118. package/dist/ndarray/index.js +2 -2
  119. package/dist/nn/index.cjs +36 -36
  120. package/dist/nn/index.d.cts +6 -6
  121. package/dist/nn/index.d.ts +6 -6
  122. package/dist/nn/index.js +3 -3
  123. package/dist/optim/index.cjs +19 -19
  124. package/dist/optim/index.d.cts +4 -4
  125. package/dist/optim/index.d.ts +4 -4
  126. package/dist/optim/index.js +2 -2
  127. package/dist/plot/index.cjs +29 -29
  128. package/dist/plot/index.d.cts +6 -6
  129. package/dist/plot/index.d.ts +6 -6
  130. package/dist/plot/index.js +3 -3
  131. package/dist/preprocess/index.cjs +21 -21
  132. package/dist/preprocess/index.d.cts +4 -4
  133. package/dist/preprocess/index.d.ts +4 -4
  134. package/dist/preprocess/index.js +3 -3
  135. package/dist/random/index.cjs +19 -19
  136. package/dist/random/index.d.cts +3 -3
  137. package/dist/random/index.d.ts +3 -3
  138. package/dist/random/index.js +3 -3
  139. package/dist/stats/index.cjs +36 -36
  140. package/dist/stats/index.d.cts +3 -3
  141. package/dist/stats/index.d.ts +3 -3
  142. package/dist/stats/index.js +3 -3
  143. package/dist/{tensor-B96jjJLQ.d.cts → tensor-IlVTF0bz.d.cts} +16 -3
  144. package/dist/{tensor-B96jjJLQ.d.ts → tensor-IlVTF0bz.d.ts} +16 -3
  145. package/package.json +3 -2
  146. package/dist/chunk-4S73VUBD.js.map +0 -1
  147. package/dist/chunk-5R4S63PF.js.map +0 -1
  148. package/dist/chunk-6AE5FKKQ.cjs.map +0 -1
  149. package/dist/chunk-AD436M45.js.map +0 -1
  150. package/dist/chunk-ALS7ETWZ.cjs.map +0 -1
  151. package/dist/chunk-B5TNKUEY.js.map +0 -1
  152. package/dist/chunk-BCR7G3A6.js.map +0 -1
  153. package/dist/chunk-C4PKXY74.cjs.map +0 -1
  154. package/dist/chunk-DWZY6PIP.cjs.map +0 -1
  155. package/dist/chunk-FJYLIGJX.js.map +0 -1
  156. package/dist/chunk-JSCDE774.cjs.map +0 -1
  157. package/dist/chunk-MLBMYKCG.js.map +0 -1
  158. package/dist/chunk-OX6QXFMV.cjs.map +0 -1
  159. package/dist/chunk-PL7TAYKI.js.map +0 -1
  160. package/dist/chunk-PR647I7R.js.map +0 -1
  161. package/dist/chunk-QERHVCHC.cjs.map +0 -1
  162. package/dist/chunk-XEG44RF6.cjs.map +0 -1
  163. package/dist/chunk-ZB75FESB.cjs.map +0 -1
  164. package/dist/chunk-ZLW62TJG.cjs.map +0 -1
  165. package/dist/chunk-ZXKBDFP3.js.map +0 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Jehaad Aljohani
3
+ Copyright (c) 2025-2026 Jehaad Aljohani
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ <img src="./Banner.png" alt="Deepbox" />
2
+
1
3
  # Deepbox
2
4
 
3
5
  ## The TypeScript Toolkit for AI & Numerical Computing
@@ -6,9 +8,9 @@
6
8
  [![npm version](https://img.shields.io/npm/v/deepbox)](https://www.npmjs.com/package/deepbox)
7
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
8
10
 
9
- Deepbox is a comprehensive, type-safe TypeScript library that unifies numerical computing, tabular data workflows, and machine learning into a single modular package. Zero runtime dependencies. 4 009 tests. Production-ready.
11
+ Deepbox is a comprehensive, type-safe TypeScript library that unifies numerical computing, tabular data workflows, and machine learning into a single modular package. Zero runtime dependencies. 4,344 tests. Production-ready.
10
12
 
11
- _Inspired by NumPy, Pandas, PyTorch, scikit-learn, and Matplotlib._
13
+ > **Documentation:** https://deepbox.dev/docs · **Examples:** https://deepbox.dev/examples · **Projects:** https://deepbox.dev/projects
12
14
 
13
15
  ## Requirements
14
16
 
@@ -60,27 +62,27 @@ const predictions = model.predict(XTest);
60
62
  Prefer per-module imports for tree-shaking, or use namespaces from the root:
61
63
 
62
64
  ```ts
63
- import * as ds from "deepbox";
64
- const t = ds.ndarray.tensor([1, 2, 3]);
65
+ import * as db from "deepbox";
66
+ const t = db.ndarray.tensor([1, 2, 3]);
65
67
  ```
66
68
 
67
69
  ## Modules
68
70
 
69
- | Module | What it provides | Inspired by |
70
- | -------------------- | -------------------------------------------------------------------------------------- | -------------------- |
71
- | `deepbox/core` | Types, errors, validation, dtype helpers, configuration | - |
72
- | `deepbox/ndarray` | N-D tensors with autograd, broadcasting, 90+ ops, sparse matrices | NumPy, PyTorch |
73
- | `deepbox/linalg` | SVD, QR, LU, Cholesky, eigenvalue decomposition, solvers, norms | NumPy/SciPy |
74
- | `deepbox/dataframe` | DataFrame + Series with 50+ operations, CSV I/O | Pandas |
75
- | `deepbox/stats` | Descriptive stats, correlations, hypothesis tests (t-test, ANOVA, chi-square, etc.) | SciPy/statsmodels |
76
- | `deepbox/metrics` | 40+ ML metrics (classification, regression, clustering) | scikit-learn |
77
- | `deepbox/preprocess` | Scalers, encoders, normalizers, cross-validation splits | scikit-learn |
78
- | `deepbox/ml` | Classical ML (Linear, Ridge, Lasso, Logistic, Trees, SVM, KNN, Naive Bayes, Ensembles) | scikit-learn |
79
- | `deepbox/nn` | Neural networks (Linear, Conv, RNN/LSTM/GRU, Attention, Normalization, Losses) | PyTorch |
80
- | `deepbox/optim` | Optimizers (SGD, Adam, AdamW, RMSprop, etc.) + LR schedulers | PyTorch |
81
- | `deepbox/random` | Distributions (uniform, normal, binomial, gamma, beta, etc.) + sampling | NumPy.random |
82
- | `deepbox/datasets` | Built-in datasets (Iris, Digits, Breast Cancer, etc.) + synthetic generators | scikit-learn/PyTorch |
83
- | `deepbox/plot` | SVG/PNG plotting (scatter, line, bar, hist, heatmap, contour, ML plots) | Matplotlib |
71
+ | Module | What it provides | Docs |
72
+ | -------------------- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
73
+ | `deepbox/core` | Types, errors, validation, dtype helpers, configuration | [core](https://deepbox.dev/docs/core-types) |
74
+ | `deepbox/ndarray` | N-D tensors with autograd, broadcasting, 90+ ops, sparse matrices | [ndarray](https://deepbox.dev/docs/ndarray-tensor) |
75
+ | `deepbox/linalg` | SVD, QR, LU, Cholesky, eigenvalue decomposition, solvers, norms | [linalg](https://deepbox.dev/docs/linalg-decompositions) |
76
+ | `deepbox/dataframe` | DataFrame + Series with 50+ operations, CSV I/O | [dataframe](https://deepbox.dev/docs/dataframe-overview) |
77
+ | `deepbox/stats` | Descriptive stats, correlations, hypothesis tests (t-test, ANOVA, chi-square, etc.) | [stats](https://deepbox.dev/docs/stats-descriptive) |
78
+ | `deepbox/metrics` | 40+ ML metrics (classification, regression, clustering) | [metrics](https://deepbox.dev/docs/metrics-classification) |
79
+ | `deepbox/preprocess` | Scalers, encoders, normalizers, cross-validation splits | [preprocess](https://deepbox.dev/docs/preprocess-scalers) |
80
+ | `deepbox/ml` | Classical ML (Linear, Ridge, Lasso, Logistic, Trees, SVM, KNN, Naive Bayes, Ensembles) | [ml](https://deepbox.dev/docs/ml-linear) |
81
+ | `deepbox/nn` | Neural networks (Linear, Conv, RNN/LSTM/GRU, Attention, Normalization, Losses) | [nn](https://deepbox.dev/docs/nn-module) |
82
+ | `deepbox/optim` | Optimizers (SGD, Adam, AdamW, RMSprop, etc.) + LR schedulers | [optim](https://deepbox.dev/docs/optim-optimizers) |
83
+ | `deepbox/random` | Distributions (uniform, normal, binomial, gamma, beta, etc.) + sampling | [random](https://deepbox.dev/docs/random-distributions) |
84
+ | `deepbox/datasets` | Built-in datasets (Iris, Digits, Breast Cancer, etc.) + synthetic generators | [datasets](https://deepbox.dev/docs/datasets-builtin) |
85
+ | `deepbox/plot` | SVG/PNG plotting (scatter, line, bar, hist, heatmap, contour, ML plots) | [plot](https://deepbox.dev/docs/plot-basic) |
84
86
 
85
87
  ## Features
86
88
 
@@ -88,14 +90,14 @@ const t = ds.ndarray.tensor([1, 2, 3]);
88
90
 
89
91
  - **90+ operations**: arithmetic, trigonometric, logical, reductions, sorting, manipulation
90
92
  - **Automatic differentiation**: `GradTensor` with reverse-mode backpropagation
91
- - **Broadcasting**: NumPy-compatible semantics
93
+ - **Broadcasting**: full broadcasting semantics ([docs](https://deepbox.dev/docs/ndarray-ops))
92
94
  - **Sparse matrices**: CSR format with arithmetic and matrix operations
93
95
  - **Multiple dtypes**: float32, float64, int32, int64, uint8, bool, string
94
96
  - **Activation functions**: ReLU, Sigmoid, Softmax, GELU, Mish, Swish, ELU, LeakyReLU
95
97
 
96
98
  ### DataFrames & Series
97
99
 
98
- - **Pandas-like API**: filtering, grouping, joining, merging, pivoting, sorting
100
+ - **Tabular API**: filtering, grouping, joining, merging, pivoting, sorting ([docs](https://deepbox.dev/docs/dataframe-overview))
99
101
  - **CSV I/O**: read and write CSV files
100
102
  - **Descriptive statistics**: `describe()`, value counts, correlation matrices
101
103
 
@@ -262,7 +264,7 @@ const df = new DataFrame({
262
264
 
263
265
  const itDept = df.filter((row) => row.department === "IT");
264
266
  const avgSalary = df.groupBy("department").agg({ salary: "mean" });
265
- const sorted = df.sort("salary", { ascending: false });
267
+ const sorted = df.sort("salary", false);
266
268
  ```
267
269
 
268
270
  ### Plotting
@@ -292,28 +294,28 @@ Deepbox is pure TypeScript — no native addons, no WebAssembly, no C bindings.
292
294
 
293
295
  | Category | Deepbox Wins | Python Package Wins | Competing Against |
294
296
  | --- | ---: | ---: | --- |
295
- | DataFrames | 24 | 31 | Pandas (C / Cython) |
297
+ | DataFrames | 23 | 32 | Pandas (C / Cython) |
296
298
  | Datasets | 11 | 30 | scikit-learn |
297
299
  | Linear Algebra | 0 | 54 | NumPy + SciPy (LAPACK) |
298
- | Metrics | 45 | 18 | scikit-learn (C / Cython) |
299
- | ML Training | 16 | 32 | scikit-learn (C / Cython) |
300
+ | Metrics | 46 | 17 | scikit-learn (C / Cython) |
301
+ | ML Training | 15 | 33 | scikit-learn (C / Cython) |
300
302
  | NDArray Ops | 6 | 88 | NumPy (C / BLAS) |
301
303
  | Plotting | 43 | 0 | Matplotlib (C / Agg) |
302
- | Preprocessing | 20 | 23 | scikit-learn (C / Cython) |
304
+ | Preprocessing | 19 | 24 | scikit-learn (C / Cython) |
303
305
  | Random | 0 | 44 | NumPy (C) |
304
- | Statistics | 31 | 26 | SciPy (C / Fortran) |
305
- | **Total** | **196** | **346** | |
306
+ | Statistics | 30 | 27 | SciPy (C / Fortran) |
307
+ | **Total** | **193** | **349** | |
306
308
 
307
309
  ### Where Deepbox shines
308
310
 
309
- - **bar** (200 bars) — 16488.6x faster *(Plotting)*
310
- - **KNeighborsClassifier fit** (200x5) — 48.4x faster *(ML Training)*
311
- - **transpose** (500x500) — 43.9x faster *(NDArray Ops)*
312
- - **fbetaScore (β=0.5)** (1K) — 34.0x faster *(Metrics)*
313
- - **describe** (100x5) — 29.4x faster *(DataFrames)*
314
- - **chisquare** (10 bins) — 18.5x faster *(Statistics)*
315
- - **loadLinnerud** (20x3) — 15.3x faster *(Datasets)*
316
- - **PowerTransformer fit** (500x10) — 6.3x faster *(Preprocessing)*
311
+ - **bar** (200 bars) — 9963.3x faster *(Plotting)*
312
+ - **transpose** (500x500) — 54.5x faster *(NDArray Ops)*
313
+ - **KNeighborsRegressor fit** (200x5) — 36.6x faster *(ML Training)*
314
+ - **fbetaScore (β=0.5)** (1K) — 30.9x faster *(Metrics)*
315
+ - **describe** (100x5) — 29.5x faster *(DataFrames)*
316
+ - **chisquare** (10 bins) — 19.3x faster *(Statistics)*
317
+ - **loadLinnerud** (20x3) — 15.1x faster *(Datasets)*
318
+ - **PowerTransformer fit** (500x10) — 6.4x faster *(Preprocessing)*
317
319
 
318
320
  ### Context
319
321
 
@@ -328,7 +330,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for the full development workflow.
328
330
  ```bash
329
331
  npm install # Install dependencies
330
332
  npm run build # Build the package
331
- npm test # Run 4 009 tests
333
+ npm test # Run 4,344 tests
332
334
  npm run typecheck # Type checking
333
335
  npm run lint # Lint with Biome
334
336
  npm run format # Format with Biome
@@ -1,5 +1,5 @@
1
- import { S as Shape } from './tensor-B96jjJLQ.js';
2
- import { T as Tensor } from './Tensor-g8mUClel.js';
1
+ import { S as Shape } from './tensor-IlVTF0bz.cjs';
2
+ import { T as Tensor } from './Tensor-fxBg-TFZ.cjs';
3
3
 
4
4
  type CSRMatrixInit = {
5
5
  readonly data: Float64Array;
@@ -36,7 +36,7 @@ type CSRMatrixInit = {
36
36
  * const dense = sparse.toDense();
37
37
  * ```
38
38
  *
39
- * @see {@link https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_(CSR,_CRS_or_Yale_format) | Wikipedia: CSR}
39
+ * @see {@link https://deepbox.dev/docs/ndarray-sparse | Deepbox Sparse Matrices}
40
40
  */
41
41
  declare class CSRMatrix {
42
42
  readonly data: Float64Array;
@@ -1,5 +1,5 @@
1
- import { S as Shape } from './tensor-B96jjJLQ.cjs';
2
- import { T as Tensor } from './Tensor-BQLk1ltW.cjs';
1
+ import { S as Shape } from './tensor-IlVTF0bz.js';
2
+ import { T as Tensor } from './Tensor-BORFp_zt.js';
3
3
 
4
4
  type CSRMatrixInit = {
5
5
  readonly data: Float64Array;
@@ -36,7 +36,7 @@ type CSRMatrixInit = {
36
36
  * const dense = sparse.toDense();
37
37
  * ```
38
38
  *
39
- * @see {@link https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_(CSR,_CRS_or_Yale_format) | Wikipedia: CSR}
39
+ * @see {@link https://deepbox.dev/docs/ndarray-sparse | Deepbox Sparse Matrices}
40
40
  */
41
41
  declare class CSRMatrix {
42
42
  readonly data: Float64Array;
@@ -1,4 +1,10 @@
1
- import { S as Shape, D as DType, T as TensorLike, a as Device, b as TypedArray } from './tensor-B96jjJLQ.cjs';
1
+ import { S as Shape, D as DType, b as TensorLike, a as Device, T as TypedArray, E as ElementOf } from './tensor-IlVTF0bz.js';
2
+
3
+ type SliceRange = number | {
4
+ readonly start?: number;
5
+ readonly end?: number;
6
+ readonly step?: number;
7
+ };
2
8
 
3
9
  type TensorOptions = {
4
10
  readonly dtype: DType;
@@ -14,7 +20,7 @@ type TensorData<D extends DType> = D extends "string" ? string[] : TypedArray;
14
20
  * - Memory-efficient strided views
15
21
  * - Device abstraction (CPU, WebGPU, WASM)
16
22
  *
17
- * Inspired by NumPy ndarray and PyTorch Tensor.
23
+ * @see {@link https://deepbox.dev/docs/ndarray-tensor | Deepbox Tensors}
18
24
  *
19
25
  * @typeParam S - Shape type (readonly number array)
20
26
  * @typeParam D - Data type (DType literal)
@@ -82,7 +88,7 @@ declare class Tensor<S extends Shape = Shape, D extends DType = DType> implement
82
88
  * Requires a contiguous tensor; non-contiguous views will throw.
83
89
  *
84
90
  * This is a convenience method that wraps the standalone `reshape` function,
85
- * providing a more intuitive API similar to NumPy and PyTorch.
91
+ * providing a more intuitive API for tensor slicing and indexing.
86
92
  *
87
93
  * @param newShape - The desired shape for the tensor
88
94
  * @returns A new tensor with the specified shape
@@ -99,8 +105,8 @@ declare class Tensor<S extends Shape = Shape, D extends DType = DType> implement
99
105
  * console.log(flat.shape); // [4]
100
106
  * ```
101
107
  *
102
- * @see {@link https://numpy.org/doc/stable/reference/generated/numpy.reshape.html | NumPy reshape}
103
- * @see {@link https://pytorch.org/docs/stable/generated/torch.reshape.html | PyTorch reshape}
108
+ * @see {@link https://deepbox.dev/docs/ndarray-tensor | Deepbox Tensor Creation}
109
+ * @see {@link https://deepbox.dev/docs/ndarray-tensor | Deepbox Tensors}
104
110
  */
105
111
  reshape<S2 extends Shape>(this: Tensor<S, "string">, newShape: S2): Tensor<S2, "string">;
106
112
  reshape<S2 extends Shape>(this: Tensor<S, Exclude<DType, "string">>, newShape: S2): Tensor<S2, Exclude<DType, "string">>;
@@ -122,7 +128,21 @@ declare class Tensor<S extends Shape = Shape, D extends DType = DType> implement
122
128
  flatten(this: Tensor<S, "string">): Tensor<[number], "string">;
123
129
  flatten(this: Tensor<S, Exclude<DType, "string">>): Tensor<[number], Exclude<DType, "string">>;
124
130
  flatten(this: Tensor<S, DType>): Tensor<[number], DType>;
125
- at(...indices: number[]): unknown;
131
+ /**
132
+ * Slice this tensor along one or more axes.
133
+ *
134
+ * @param ranges - Per-axis slice specifications (number, or {start?, end?, step?})
135
+ * @returns New tensor with the sliced data
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const t = tensor([[1, 2, 3], [4, 5, 6]]);
140
+ * t.slice(0); // tensor([1, 2, 3])
141
+ * t.slice({ start: 0, end: 1 }, { start: 1 }); // tensor([[2, 3]])
142
+ * ```
143
+ */
144
+ slice(...ranges: SliceRange[]): Tensor;
145
+ at(...indices: number[]): ElementOf<D>;
126
146
  toArray(): unknown;
127
147
  /**
128
148
  * Return a human-readable string representation of this tensor.
@@ -144,4 +164,4 @@ declare class Tensor<S extends Shape = Shape, D extends DType = DType> implement
144
164
  toString(maxElements?: number): string;
145
165
  }
146
166
 
147
- export { Tensor as T, type TensorOptions as a };
167
+ export { type SliceRange as S, Tensor as T, type TensorOptions as a };
@@ -1,4 +1,10 @@
1
- import { S as Shape, D as DType, T as TensorLike, a as Device, b as TypedArray } from './tensor-B96jjJLQ.js';
1
+ import { S as Shape, D as DType, b as TensorLike, a as Device, T as TypedArray, E as ElementOf } from './tensor-IlVTF0bz.cjs';
2
+
3
+ type SliceRange = number | {
4
+ readonly start?: number;
5
+ readonly end?: number;
6
+ readonly step?: number;
7
+ };
2
8
 
3
9
  type TensorOptions = {
4
10
  readonly dtype: DType;
@@ -14,7 +20,7 @@ type TensorData<D extends DType> = D extends "string" ? string[] : TypedArray;
14
20
  * - Memory-efficient strided views
15
21
  * - Device abstraction (CPU, WebGPU, WASM)
16
22
  *
17
- * Inspired by NumPy ndarray and PyTorch Tensor.
23
+ * @see {@link https://deepbox.dev/docs/ndarray-tensor | Deepbox Tensors}
18
24
  *
19
25
  * @typeParam S - Shape type (readonly number array)
20
26
  * @typeParam D - Data type (DType literal)
@@ -82,7 +88,7 @@ declare class Tensor<S extends Shape = Shape, D extends DType = DType> implement
82
88
  * Requires a contiguous tensor; non-contiguous views will throw.
83
89
  *
84
90
  * This is a convenience method that wraps the standalone `reshape` function,
85
- * providing a more intuitive API similar to NumPy and PyTorch.
91
+ * providing a more intuitive API for tensor slicing and indexing.
86
92
  *
87
93
  * @param newShape - The desired shape for the tensor
88
94
  * @returns A new tensor with the specified shape
@@ -99,8 +105,8 @@ declare class Tensor<S extends Shape = Shape, D extends DType = DType> implement
99
105
  * console.log(flat.shape); // [4]
100
106
  * ```
101
107
  *
102
- * @see {@link https://numpy.org/doc/stable/reference/generated/numpy.reshape.html | NumPy reshape}
103
- * @see {@link https://pytorch.org/docs/stable/generated/torch.reshape.html | PyTorch reshape}
108
+ * @see {@link https://deepbox.dev/docs/ndarray-tensor | Deepbox Tensor Creation}
109
+ * @see {@link https://deepbox.dev/docs/ndarray-tensor | Deepbox Tensors}
104
110
  */
105
111
  reshape<S2 extends Shape>(this: Tensor<S, "string">, newShape: S2): Tensor<S2, "string">;
106
112
  reshape<S2 extends Shape>(this: Tensor<S, Exclude<DType, "string">>, newShape: S2): Tensor<S2, Exclude<DType, "string">>;
@@ -122,7 +128,21 @@ declare class Tensor<S extends Shape = Shape, D extends DType = DType> implement
122
128
  flatten(this: Tensor<S, "string">): Tensor<[number], "string">;
123
129
  flatten(this: Tensor<S, Exclude<DType, "string">>): Tensor<[number], Exclude<DType, "string">>;
124
130
  flatten(this: Tensor<S, DType>): Tensor<[number], DType>;
125
- at(...indices: number[]): unknown;
131
+ /**
132
+ * Slice this tensor along one or more axes.
133
+ *
134
+ * @param ranges - Per-axis slice specifications (number, or {start?, end?, step?})
135
+ * @returns New tensor with the sliced data
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const t = tensor([[1, 2, 3], [4, 5, 6]]);
140
+ * t.slice(0); // tensor([1, 2, 3])
141
+ * t.slice({ start: 0, end: 1 }, { start: 1 }); // tensor([[2, 3]])
142
+ * ```
143
+ */
144
+ slice(...ranges: SliceRange[]): Tensor;
145
+ at(...indices: number[]): ElementOf<D>;
126
146
  toArray(): unknown;
127
147
  /**
128
148
  * Return a human-readable string representation of this tensor.
@@ -144,4 +164,4 @@ declare class Tensor<S extends Shape = Shape, D extends DType = DType> implement
144
164
  toString(maxElements?: number): string;
145
165
  }
146
166
 
147
- export { Tensor as T, type TensorOptions as a };
167
+ export { type SliceRange as S, Tensor as T, type TensorOptions as a };
@@ -1,5 +1,5 @@
1
- import { tensor } from './chunk-BCR7G3A6.js';
2
- import { __export, InvalidParameterError, DataValidationError, ShapeError, getNumericElement, DTypeError, getStringElement, getBigIntElement, isTypedArray, isNumericTypedArray } from './chunk-4S73VUBD.js';
1
+ import { tensor } from './chunk-KCF6P34A.js';
2
+ import { __export, InvalidParameterError, DataValidationError, ShapeError, getNumericElement, DTypeError, getStringElement, getBigIntElement, isTypedArray, isNumericTypedArray } from './chunk-CZOMBUI7.js';
3
3
 
4
4
  // src/metrics/index.ts
5
5
  var metrics_exports = {};
@@ -134,6 +134,20 @@ function ensureBinaryValue(value, name, index) {
134
134
  );
135
135
  }
136
136
  }
137
+ function isMulticlass(yTrue, yPred) {
138
+ if (yTrue.dtype === "string" || yPred.dtype === "string") return true;
139
+ const yTrueData = getNumericLabelData(yTrue);
140
+ const yPredData = getNumericLabelData(yPred);
141
+ const trueOffset = createFlatOffsetter(yTrue);
142
+ const predOffset = createFlatOffsetter(yPred);
143
+ const unique = /* @__PURE__ */ new Set();
144
+ for (let i = 0; i < yTrue.size; i++) {
145
+ unique.add(getNumericElement(yTrueData, trueOffset(i)));
146
+ unique.add(getNumericElement(yPredData, predOffset(i)));
147
+ if (unique.size > 2) return true;
148
+ }
149
+ return unique.size > 2;
150
+ }
137
151
  function assertBinaryLabels(yTrue, yPred) {
138
152
  if (yTrue.dtype === "string" || yPred.dtype === "string") {
139
153
  throw new InvalidParameterError(
@@ -232,7 +246,10 @@ function accuracy(yTrue, yPred) {
232
246
  }
233
247
  return correct / yTrue.size;
234
248
  }
235
- function precision(yTrue, yPred, average = "binary") {
249
+ function precision(yTrue, yPred, average) {
250
+ if (average === void 0) {
251
+ average = isMulticlass(yTrue, yPred) ? "weighted" : "binary";
252
+ }
236
253
  assertSameSizeVectors(yTrue, yPred, "yTrue", "yPred");
237
254
  if (yTrue.size === 0) return average === null ? [] : 0;
238
255
  if (average === "binary") {
@@ -298,7 +315,10 @@ function precision(yTrue, yPred, average = "binary") {
298
315
  average
299
316
  );
300
317
  }
301
- function recall(yTrue, yPred, average = "binary") {
318
+ function recall(yTrue, yPred, average) {
319
+ if (average === void 0) {
320
+ average = isMulticlass(yTrue, yPred) ? "weighted" : "binary";
321
+ }
302
322
  assertSameSizeVectors(yTrue, yPred, "yTrue", "yPred");
303
323
  if (yTrue.size === 0) return average === null ? [] : 0;
304
324
  if (average === "binary") {
@@ -364,7 +384,13 @@ function recall(yTrue, yPred, average = "binary") {
364
384
  average
365
385
  );
366
386
  }
367
- function f1Score(yTrue, yPred, average = "binary") {
387
+ function f1Score(yTrue, yPred, average) {
388
+ if (average !== null && typeof average === "object") {
389
+ average = average.average;
390
+ }
391
+ if (average === void 0) {
392
+ average = isMulticlass(yTrue, yPred) ? "weighted" : "binary";
393
+ }
368
394
  if (average === "binary" || average === "micro") {
369
395
  const p = precision(yTrue, yPred, average);
370
396
  const r = recall(yTrue, yPred, average);
@@ -1936,5 +1962,5 @@ function explainedVarianceScore(yTrue, yPred) {
1936
1962
  }
1937
1963
 
1938
1964
  export { accuracy, adjustedMutualInfoScore, adjustedR2Score, adjustedRandScore, averagePrecisionScore, balancedAccuracyScore, calinskiHarabaszScore, classificationReport, cohenKappaScore, completenessScore, confusionMatrix, daviesBouldinScore, explainedVarianceScore, f1Score, fbetaScore, fowlkesMallowsScore, hammingLoss, homogeneityScore, jaccardScore, logLoss, mae, mape, matthewsCorrcoef, maxError, medianAbsoluteError, metrics_exports, mse, normalizedMutualInfoScore, precision, precisionRecallCurve, r2Score, recall, rmse, rocAucScore, rocCurve, silhouetteSamples, silhouetteScore, vMeasureScore };
1939
- //# sourceMappingURL=chunk-FJYLIGJX.js.map
1940
- //# sourceMappingURL=chunk-FJYLIGJX.js.map
1965
+ //# sourceMappingURL=chunk-3AX37GPK.js.map
1966
+ //# sourceMappingURL=chunk-3AX37GPK.js.map