deepbox 0.1.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 (173) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +344 -0
  3. package/dist/CSRMatrix-CwGwQRea.d.cts +219 -0
  4. package/dist/CSRMatrix-KzNt6QpS.d.ts +219 -0
  5. package/dist/Tensor-BQLk1ltW.d.cts +147 -0
  6. package/dist/Tensor-g8mUClel.d.ts +147 -0
  7. package/dist/chunk-4S73VUBD.js +677 -0
  8. package/dist/chunk-4S73VUBD.js.map +1 -0
  9. package/dist/chunk-5R4S63PF.js +2925 -0
  10. package/dist/chunk-5R4S63PF.js.map +1 -0
  11. package/dist/chunk-6AE5FKKQ.cjs +9264 -0
  12. package/dist/chunk-6AE5FKKQ.cjs.map +1 -0
  13. package/dist/chunk-AD436M45.js +3854 -0
  14. package/dist/chunk-AD436M45.js.map +1 -0
  15. package/dist/chunk-ALS7ETWZ.cjs +4263 -0
  16. package/dist/chunk-ALS7ETWZ.cjs.map +1 -0
  17. package/dist/chunk-AU7XHGKJ.js +2092 -0
  18. package/dist/chunk-AU7XHGKJ.js.map +1 -0
  19. package/dist/chunk-B5TNKUEY.js +1481 -0
  20. package/dist/chunk-B5TNKUEY.js.map +1 -0
  21. package/dist/chunk-BCR7G3A6.js +9136 -0
  22. package/dist/chunk-BCR7G3A6.js.map +1 -0
  23. package/dist/chunk-C4PKXY74.cjs +1917 -0
  24. package/dist/chunk-C4PKXY74.cjs.map +1 -0
  25. package/dist/chunk-DWZY6PIP.cjs +6400 -0
  26. package/dist/chunk-DWZY6PIP.cjs.map +1 -0
  27. package/dist/chunk-E3EU5FZO.cjs +2113 -0
  28. package/dist/chunk-E3EU5FZO.cjs.map +1 -0
  29. package/dist/chunk-F3JWBINJ.js +1054 -0
  30. package/dist/chunk-F3JWBINJ.js.map +1 -0
  31. package/dist/chunk-FJYLIGJX.js +1940 -0
  32. package/dist/chunk-FJYLIGJX.js.map +1 -0
  33. package/dist/chunk-JSCDE774.cjs +729 -0
  34. package/dist/chunk-JSCDE774.cjs.map +1 -0
  35. package/dist/chunk-LWECRCW2.cjs +2412 -0
  36. package/dist/chunk-LWECRCW2.cjs.map +1 -0
  37. package/dist/chunk-MLBMYKCG.js +6379 -0
  38. package/dist/chunk-MLBMYKCG.js.map +1 -0
  39. package/dist/chunk-OX6QXFMV.cjs +3874 -0
  40. package/dist/chunk-OX6QXFMV.cjs.map +1 -0
  41. package/dist/chunk-PHV2DKRS.cjs +1072 -0
  42. package/dist/chunk-PHV2DKRS.cjs.map +1 -0
  43. package/dist/chunk-PL7TAYKI.js +4056 -0
  44. package/dist/chunk-PL7TAYKI.js.map +1 -0
  45. package/dist/chunk-PR647I7R.js +1898 -0
  46. package/dist/chunk-PR647I7R.js.map +1 -0
  47. package/dist/chunk-QERHVCHC.cjs +2960 -0
  48. package/dist/chunk-QERHVCHC.cjs.map +1 -0
  49. package/dist/chunk-XEG44RF6.cjs +1514 -0
  50. package/dist/chunk-XEG44RF6.cjs.map +1 -0
  51. package/dist/chunk-XMWVME2W.js +2377 -0
  52. package/dist/chunk-XMWVME2W.js.map +1 -0
  53. package/dist/chunk-ZB75FESB.cjs +1979 -0
  54. package/dist/chunk-ZB75FESB.cjs.map +1 -0
  55. package/dist/chunk-ZLW62TJG.cjs +4061 -0
  56. package/dist/chunk-ZLW62TJG.cjs.map +1 -0
  57. package/dist/chunk-ZXKBDFP3.js +4235 -0
  58. package/dist/chunk-ZXKBDFP3.js.map +1 -0
  59. package/dist/core/index.cjs +204 -0
  60. package/dist/core/index.cjs.map +1 -0
  61. package/dist/core/index.d.cts +2 -0
  62. package/dist/core/index.d.ts +2 -0
  63. package/dist/core/index.js +3 -0
  64. package/dist/core/index.js.map +1 -0
  65. package/dist/dataframe/index.cjs +22 -0
  66. package/dist/dataframe/index.cjs.map +1 -0
  67. package/dist/dataframe/index.d.cts +3 -0
  68. package/dist/dataframe/index.d.ts +3 -0
  69. package/dist/dataframe/index.js +5 -0
  70. package/dist/dataframe/index.js.map +1 -0
  71. package/dist/datasets/index.cjs +134 -0
  72. package/dist/datasets/index.cjs.map +1 -0
  73. package/dist/datasets/index.d.cts +3 -0
  74. package/dist/datasets/index.d.ts +3 -0
  75. package/dist/datasets/index.js +5 -0
  76. package/dist/datasets/index.js.map +1 -0
  77. package/dist/index-74AB8Cyh.d.cts +1126 -0
  78. package/dist/index-9oQx1HgV.d.cts +1180 -0
  79. package/dist/index-BJY2SI4i.d.ts +483 -0
  80. package/dist/index-BWGhrDlr.d.ts +733 -0
  81. package/dist/index-B_DK4FKY.d.cts +242 -0
  82. package/dist/index-BbA2Gxfl.d.ts +456 -0
  83. package/dist/index-BgHYAoSS.d.cts +837 -0
  84. package/dist/index-BndMbqsM.d.ts +1439 -0
  85. package/dist/index-C1mfVYoo.d.ts +2517 -0
  86. package/dist/index-CCvlwAmL.d.cts +809 -0
  87. package/dist/index-CDw5CnOU.d.ts +785 -0
  88. package/dist/index-Cn3SdB0O.d.ts +1126 -0
  89. package/dist/index-CrqLlS-a.d.ts +776 -0
  90. package/dist/index-D61yaSMY.d.cts +483 -0
  91. package/dist/index-D9Loo1_A.d.cts +2517 -0
  92. package/dist/index-DIT_OO9C.d.cts +785 -0
  93. package/dist/index-DIp_RrRt.d.ts +242 -0
  94. package/dist/index-DbultU6X.d.cts +1427 -0
  95. package/dist/index-DmEg_LCm.d.cts +776 -0
  96. package/dist/index-DoPWVxPo.d.cts +1439 -0
  97. package/dist/index-DuCxd-8d.d.ts +837 -0
  98. package/dist/index-Dx42TZaY.d.ts +809 -0
  99. package/dist/index-DyZ4QQf5.d.cts +456 -0
  100. package/dist/index-GFAVyOWO.d.ts +1427 -0
  101. package/dist/index-WHQLn0e8.d.cts +733 -0
  102. package/dist/index-ZtI1Iy4L.d.ts +1180 -0
  103. package/dist/index-eJgeni9c.d.cts +1911 -0
  104. package/dist/index-tk4lSYod.d.ts +1911 -0
  105. package/dist/index.cjs +72 -0
  106. package/dist/index.cjs.map +1 -0
  107. package/dist/index.d.cts +17 -0
  108. package/dist/index.d.ts +17 -0
  109. package/dist/index.js +15 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/linalg/index.cjs +86 -0
  112. package/dist/linalg/index.cjs.map +1 -0
  113. package/dist/linalg/index.d.cts +3 -0
  114. package/dist/linalg/index.d.ts +3 -0
  115. package/dist/linalg/index.js +5 -0
  116. package/dist/linalg/index.js.map +1 -0
  117. package/dist/metrics/index.cjs +158 -0
  118. package/dist/metrics/index.cjs.map +1 -0
  119. package/dist/metrics/index.d.cts +3 -0
  120. package/dist/metrics/index.d.ts +3 -0
  121. package/dist/metrics/index.js +5 -0
  122. package/dist/metrics/index.js.map +1 -0
  123. package/dist/ml/index.cjs +87 -0
  124. package/dist/ml/index.cjs.map +1 -0
  125. package/dist/ml/index.d.cts +3 -0
  126. package/dist/ml/index.d.ts +3 -0
  127. package/dist/ml/index.js +6 -0
  128. package/dist/ml/index.js.map +1 -0
  129. package/dist/ndarray/index.cjs +501 -0
  130. package/dist/ndarray/index.cjs.map +1 -0
  131. package/dist/ndarray/index.d.cts +5 -0
  132. package/dist/ndarray/index.d.ts +5 -0
  133. package/dist/ndarray/index.js +4 -0
  134. package/dist/ndarray/index.js.map +1 -0
  135. package/dist/nn/index.cjs +142 -0
  136. package/dist/nn/index.cjs.map +1 -0
  137. package/dist/nn/index.d.cts +6 -0
  138. package/dist/nn/index.d.ts +6 -0
  139. package/dist/nn/index.js +5 -0
  140. package/dist/nn/index.js.map +1 -0
  141. package/dist/optim/index.cjs +77 -0
  142. package/dist/optim/index.cjs.map +1 -0
  143. package/dist/optim/index.d.cts +4 -0
  144. package/dist/optim/index.d.ts +4 -0
  145. package/dist/optim/index.js +4 -0
  146. package/dist/optim/index.js.map +1 -0
  147. package/dist/plot/index.cjs +114 -0
  148. package/dist/plot/index.cjs.map +1 -0
  149. package/dist/plot/index.d.cts +6 -0
  150. package/dist/plot/index.d.ts +6 -0
  151. package/dist/plot/index.js +5 -0
  152. package/dist/plot/index.js.map +1 -0
  153. package/dist/preprocess/index.cjs +82 -0
  154. package/dist/preprocess/index.cjs.map +1 -0
  155. package/dist/preprocess/index.d.cts +4 -0
  156. package/dist/preprocess/index.d.ts +4 -0
  157. package/dist/preprocess/index.js +5 -0
  158. package/dist/preprocess/index.js.map +1 -0
  159. package/dist/random/index.cjs +74 -0
  160. package/dist/random/index.cjs.map +1 -0
  161. package/dist/random/index.d.cts +3 -0
  162. package/dist/random/index.d.ts +3 -0
  163. package/dist/random/index.js +5 -0
  164. package/dist/random/index.js.map +1 -0
  165. package/dist/stats/index.cjs +142 -0
  166. package/dist/stats/index.cjs.map +1 -0
  167. package/dist/stats/index.d.cts +3 -0
  168. package/dist/stats/index.d.ts +3 -0
  169. package/dist/stats/index.js +5 -0
  170. package/dist/stats/index.js.map +1 -0
  171. package/dist/tensor-B96jjJLQ.d.cts +205 -0
  172. package/dist/tensor-B96jjJLQ.d.ts +205 -0
  173. package/package.json +226 -0
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Supported compute devices for tensor operations.
3
+ *
4
+ * - `cpu`: Standard CPU execution (always available)
5
+ * - `webgpu`: GPU acceleration via WebGPU API (when supported)
6
+ * - `wasm`: WebAssembly acceleration for better CPU performance
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import type { Device } from 'deepbox/core';
11
+ * import { setDevice } from 'deepbox/core';
12
+ *
13
+ * const device: Device = 'cpu';
14
+ * setDevice(device);
15
+ * ```
16
+ */
17
+ type Device = "cpu" | "webgpu" | "wasm";
18
+ /**
19
+ * Array of all supported device types.
20
+ *
21
+ * Use this constant for validation or UI selection.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { DEVICES } from 'deepbox/core';
26
+ *
27
+ * console.log(DEVICES); // ['cpu', 'webgpu', 'wasm']
28
+ * ```
29
+ */
30
+ declare const DEVICES: readonly Device[];
31
+ /**
32
+ * Type guard to check if a value is a valid Device.
33
+ *
34
+ * @param value - The value to check
35
+ * @returns True if value is a valid Device, false otherwise
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { isDevice } from 'deepbox/core';
40
+ *
41
+ * if (isDevice('cpu')) {
42
+ * console.log('Valid device');
43
+ * }
44
+ *
45
+ * isDevice('gpu'); // false
46
+ * isDevice('cpu'); // true
47
+ * ```
48
+ */
49
+ declare function isDevice(value: unknown): value is Device;
50
+
51
+ /**
52
+ * Supported data types for tensors.
53
+ *
54
+ * - `float32`: 32-bit floating point (single precision)
55
+ * - `float64`: 64-bit floating point (double precision)
56
+ * - `int32`: 32-bit signed integer
57
+ * - `int64`: 64-bit signed integer (BigInt)
58
+ * - `uint8`: 8-bit unsigned integer
59
+ * - `bool`: Boolean values (stored as uint8)
60
+ * - `string`: String values (limited support)
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * import type { DType } from 'deepbox/core';
65
+ * import { tensor } from 'deepbox/ndarray';
66
+ *
67
+ * const dtype: DType = 'float32';
68
+ * const x = tensor([1, 2, 3], { dtype });
69
+ * ```
70
+ *
71
+ * @see {@link https://numpy.org/doc/stable/user/basics.types.html | NumPy Data Types}
72
+ */
73
+ type DType = "float32" | "float64" | "int32" | "int64" | "uint8" | "bool" | "string";
74
+ /**
75
+ * Array of all supported data types.
76
+ *
77
+ * Use this constant for validation or UI selection.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * import { DTYPES } from 'deepbox/core';
82
+ *
83
+ * console.log(DTYPES);
84
+ * // ['float32', 'float64', 'int32', 'int64', 'uint8', 'bool', 'string']
85
+ * ```
86
+ */
87
+ declare const DTYPES: readonly DType[];
88
+ /**
89
+ * Type guard to check if a value is a valid DType.
90
+ *
91
+ * @param value - The value to check
92
+ * @returns True if value is a valid DType, false otherwise
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { isDType } from 'deepbox/core';
97
+ *
98
+ * if (isDType('float32')) {
99
+ * console.log('Valid dtype');
100
+ * }
101
+ *
102
+ * isDType('float128'); // false
103
+ * isDType('int32'); // true
104
+ * ```
105
+ */
106
+ declare function isDType(value: unknown): value is DType;
107
+
108
+ /**
109
+ * Represents the dimensions of a multi-dimensional array (tensor).
110
+ *
111
+ * Each element represents the size of that dimension.
112
+ * For example, [2, 3, 4] represents a 3D array with dimensions 2×3×4.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * const shape1D: Shape = [5]; // 1D array with 5 elements
117
+ * const shape2D: Shape = [3, 4]; // 2D array (matrix) 3×4
118
+ * const shape3D: Shape = [2, 3, 4]; // 3D array 2×3×4
119
+ * const scalar: Shape = []; // Scalar (0-dimensional)
120
+ * ```
121
+ */
122
+ type Shape = readonly number[];
123
+ /**
124
+ * Union type of all TypedArray types supported by Deepbox.
125
+ *
126
+ * TypedArrays provide efficient storage and manipulation of numeric data
127
+ * in JavaScript, offering better performance than regular arrays for
128
+ * numerical computations.
129
+ *
130
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | MDN TypedArray}
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * import type { TypedArray } from 'deepbox/core';
135
+ *
136
+ * function processArray(arr: TypedArray): number {
137
+ * let sum = 0;
138
+ * for (let i = 0; i < arr.length; i++) {
139
+ * sum += Number(arr[i]);
140
+ * }
141
+ * return sum;
142
+ * }
143
+ * ```
144
+ */
145
+ type TypedArray = Float32Array | Float64Array | Int32Array | BigInt64Array | Uint8Array;
146
+ /**
147
+ * Backing storage for a tensor.
148
+ *
149
+ * Numeric tensors are backed by TypedArrays.
150
+ * String tensors are backed by a string array.
151
+ */
152
+ type TensorStorage = TypedArray | string[];
153
+ /**
154
+ * Axis identifier.
155
+ *
156
+ * Can be an integer index (0, 1, ...) or a string alias:
157
+ * - `0` aliases: "index", "rows"
158
+ * - `1` aliases: "columns"
159
+ */
160
+ type Axis = number | "index" | "rows" | "columns";
161
+
162
+ /**
163
+ * Type representing a tensor-like object.
164
+ *
165
+ * This type defines the core properties that any tensor implementation
166
+ * must provide. It enables type-safe tensor operations and interoperability
167
+ * between different tensor implementations.
168
+ *
169
+ * @typeParam S - The shape type (extends Shape)
170
+ * @typeParam D - The data type (extends DType)
171
+ *
172
+ * @property shape - Dimensions of the tensor (e.g., [2, 3, 4])
173
+ * @property dtype - Data type of tensor elements
174
+ * @property device - Compute device where tensor resides
175
+ * @property data - Underlying TypedArray storage
176
+ * @property strides - Step sizes for each dimension in memory
177
+ * @property offset - Starting position in the data buffer
178
+ * @property size - Total number of elements in the tensor
179
+ * @property ndim - Number of dimensions (rank) of the tensor
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * import type { TensorLike } from 'deepbox/core';
184
+ *
185
+ * function processTensor<S extends Shape, D extends DType>(
186
+ * tensor: TensorLike<S, D>
187
+ * ): void {
188
+ * console.log(`Shape: ${tensor.shape}`);
189
+ * console.log(`Size: ${tensor.size}`);
190
+ * console.log(`DType: ${tensor.dtype}`);
191
+ * }
192
+ * ```
193
+ */
194
+ type TensorLike<S extends Shape = Shape, D extends DType = DType> = {
195
+ readonly shape: S;
196
+ readonly dtype: D;
197
+ readonly device: Device;
198
+ readonly data: TensorStorage;
199
+ readonly strides: readonly number[];
200
+ readonly offset: number;
201
+ readonly size: number;
202
+ readonly ndim: number;
203
+ };
204
+
205
+ export { type Axis as A, type DType as D, type Shape as S, type TensorLike as T, type Device as a, type TypedArray as b, DEVICES as c, DTYPES as d, type TensorStorage as e, isDevice as f, isDType as i };
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Supported compute devices for tensor operations.
3
+ *
4
+ * - `cpu`: Standard CPU execution (always available)
5
+ * - `webgpu`: GPU acceleration via WebGPU API (when supported)
6
+ * - `wasm`: WebAssembly acceleration for better CPU performance
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import type { Device } from 'deepbox/core';
11
+ * import { setDevice } from 'deepbox/core';
12
+ *
13
+ * const device: Device = 'cpu';
14
+ * setDevice(device);
15
+ * ```
16
+ */
17
+ type Device = "cpu" | "webgpu" | "wasm";
18
+ /**
19
+ * Array of all supported device types.
20
+ *
21
+ * Use this constant for validation or UI selection.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { DEVICES } from 'deepbox/core';
26
+ *
27
+ * console.log(DEVICES); // ['cpu', 'webgpu', 'wasm']
28
+ * ```
29
+ */
30
+ declare const DEVICES: readonly Device[];
31
+ /**
32
+ * Type guard to check if a value is a valid Device.
33
+ *
34
+ * @param value - The value to check
35
+ * @returns True if value is a valid Device, false otherwise
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { isDevice } from 'deepbox/core';
40
+ *
41
+ * if (isDevice('cpu')) {
42
+ * console.log('Valid device');
43
+ * }
44
+ *
45
+ * isDevice('gpu'); // false
46
+ * isDevice('cpu'); // true
47
+ * ```
48
+ */
49
+ declare function isDevice(value: unknown): value is Device;
50
+
51
+ /**
52
+ * Supported data types for tensors.
53
+ *
54
+ * - `float32`: 32-bit floating point (single precision)
55
+ * - `float64`: 64-bit floating point (double precision)
56
+ * - `int32`: 32-bit signed integer
57
+ * - `int64`: 64-bit signed integer (BigInt)
58
+ * - `uint8`: 8-bit unsigned integer
59
+ * - `bool`: Boolean values (stored as uint8)
60
+ * - `string`: String values (limited support)
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * import type { DType } from 'deepbox/core';
65
+ * import { tensor } from 'deepbox/ndarray';
66
+ *
67
+ * const dtype: DType = 'float32';
68
+ * const x = tensor([1, 2, 3], { dtype });
69
+ * ```
70
+ *
71
+ * @see {@link https://numpy.org/doc/stable/user/basics.types.html | NumPy Data Types}
72
+ */
73
+ type DType = "float32" | "float64" | "int32" | "int64" | "uint8" | "bool" | "string";
74
+ /**
75
+ * Array of all supported data types.
76
+ *
77
+ * Use this constant for validation or UI selection.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * import { DTYPES } from 'deepbox/core';
82
+ *
83
+ * console.log(DTYPES);
84
+ * // ['float32', 'float64', 'int32', 'int64', 'uint8', 'bool', 'string']
85
+ * ```
86
+ */
87
+ declare const DTYPES: readonly DType[];
88
+ /**
89
+ * Type guard to check if a value is a valid DType.
90
+ *
91
+ * @param value - The value to check
92
+ * @returns True if value is a valid DType, false otherwise
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { isDType } from 'deepbox/core';
97
+ *
98
+ * if (isDType('float32')) {
99
+ * console.log('Valid dtype');
100
+ * }
101
+ *
102
+ * isDType('float128'); // false
103
+ * isDType('int32'); // true
104
+ * ```
105
+ */
106
+ declare function isDType(value: unknown): value is DType;
107
+
108
+ /**
109
+ * Represents the dimensions of a multi-dimensional array (tensor).
110
+ *
111
+ * Each element represents the size of that dimension.
112
+ * For example, [2, 3, 4] represents a 3D array with dimensions 2×3×4.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * const shape1D: Shape = [5]; // 1D array with 5 elements
117
+ * const shape2D: Shape = [3, 4]; // 2D array (matrix) 3×4
118
+ * const shape3D: Shape = [2, 3, 4]; // 3D array 2×3×4
119
+ * const scalar: Shape = []; // Scalar (0-dimensional)
120
+ * ```
121
+ */
122
+ type Shape = readonly number[];
123
+ /**
124
+ * Union type of all TypedArray types supported by Deepbox.
125
+ *
126
+ * TypedArrays provide efficient storage and manipulation of numeric data
127
+ * in JavaScript, offering better performance than regular arrays for
128
+ * numerical computations.
129
+ *
130
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | MDN TypedArray}
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * import type { TypedArray } from 'deepbox/core';
135
+ *
136
+ * function processArray(arr: TypedArray): number {
137
+ * let sum = 0;
138
+ * for (let i = 0; i < arr.length; i++) {
139
+ * sum += Number(arr[i]);
140
+ * }
141
+ * return sum;
142
+ * }
143
+ * ```
144
+ */
145
+ type TypedArray = Float32Array | Float64Array | Int32Array | BigInt64Array | Uint8Array;
146
+ /**
147
+ * Backing storage for a tensor.
148
+ *
149
+ * Numeric tensors are backed by TypedArrays.
150
+ * String tensors are backed by a string array.
151
+ */
152
+ type TensorStorage = TypedArray | string[];
153
+ /**
154
+ * Axis identifier.
155
+ *
156
+ * Can be an integer index (0, 1, ...) or a string alias:
157
+ * - `0` aliases: "index", "rows"
158
+ * - `1` aliases: "columns"
159
+ */
160
+ type Axis = number | "index" | "rows" | "columns";
161
+
162
+ /**
163
+ * Type representing a tensor-like object.
164
+ *
165
+ * This type defines the core properties that any tensor implementation
166
+ * must provide. It enables type-safe tensor operations and interoperability
167
+ * between different tensor implementations.
168
+ *
169
+ * @typeParam S - The shape type (extends Shape)
170
+ * @typeParam D - The data type (extends DType)
171
+ *
172
+ * @property shape - Dimensions of the tensor (e.g., [2, 3, 4])
173
+ * @property dtype - Data type of tensor elements
174
+ * @property device - Compute device where tensor resides
175
+ * @property data - Underlying TypedArray storage
176
+ * @property strides - Step sizes for each dimension in memory
177
+ * @property offset - Starting position in the data buffer
178
+ * @property size - Total number of elements in the tensor
179
+ * @property ndim - Number of dimensions (rank) of the tensor
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * import type { TensorLike } from 'deepbox/core';
184
+ *
185
+ * function processTensor<S extends Shape, D extends DType>(
186
+ * tensor: TensorLike<S, D>
187
+ * ): void {
188
+ * console.log(`Shape: ${tensor.shape}`);
189
+ * console.log(`Size: ${tensor.size}`);
190
+ * console.log(`DType: ${tensor.dtype}`);
191
+ * }
192
+ * ```
193
+ */
194
+ type TensorLike<S extends Shape = Shape, D extends DType = DType> = {
195
+ readonly shape: S;
196
+ readonly dtype: D;
197
+ readonly device: Device;
198
+ readonly data: TensorStorage;
199
+ readonly strides: readonly number[];
200
+ readonly offset: number;
201
+ readonly size: number;
202
+ readonly ndim: number;
203
+ };
204
+
205
+ export { type Axis as A, type DType as D, type Shape as S, type TensorLike as T, type Device as a, type TypedArray as b, DEVICES as c, DTYPES as d, type TensorStorage as e, isDevice as f, isDType as i };
package/package.json ADDED
@@ -0,0 +1,226 @@
1
+ {
2
+ "name": "deepbox",
3
+ "version": "0.1.0",
4
+ "description": "The TypeScript Toolkit for AI & Numerical Computing",
5
+ "author": "Jehaad Aljohani",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/jehaad1/Deepbox.git"
10
+ },
11
+ "homepage": "https://github.com/jehaad1/Deepbox#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/jehaad1/Deepbox/issues"
14
+ },
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "main": "./dist/index.cjs",
18
+ "module": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "scripts": {
21
+ "build": "tsup",
22
+ "dev": "tsup --watch",
23
+ "test": "vitest run",
24
+ "test:coverage": "vitest run --coverage",
25
+ "lint": "biome check .",
26
+ "lint:fix": "biome check --write .",
27
+ "lint:check": "biome check .",
28
+ "format": "biome format --write .",
29
+ "format:check": "biome format .",
30
+ "typecheck": "tsc --noEmit",
31
+ "clean": "rm -rf dist",
32
+ "prepack": "npm run build",
33
+ "all": "npm run format:check && npm run lint:check && npm run typecheck && npm run build && npm run test && npm run test:coverage",
34
+ "all:fix": "npm run format && npm run lint:fix && npm run typecheck && npm run build && npm run test && npm run test:coverage",
35
+ "project:01": "tsx --tsconfig docs/projects/tsconfig.json docs/projects/01-financial-risk-analysis/index.ts",
36
+ "project:02": "tsx --tsconfig docs/projects/tsconfig.json docs/projects/02-neural-image-classifier/index.ts",
37
+ "project:03": "tsx --tsconfig docs/projects/tsconfig.json docs/projects/03-customer-churn-prediction/index.ts",
38
+ "project:04": "tsx --tsconfig docs/projects/tsconfig.json docs/projects/04-stock-price-forecasting/index.ts",
39
+ "project:05": "tsx --tsconfig docs/projects/tsconfig.json docs/projects/05-recommendation-engine/index.ts",
40
+ "project:06": "tsx --tsconfig docs/projects/tsconfig.json docs/projects/06-sentiment-analysis/index.ts",
41
+ "projects:all": "npm run project:01 && npm run project:02 && npm run project:03 && npm run project:04 && npm run project:05 && npm run project:06",
42
+ "example:00": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/00-quick-start/index.ts",
43
+ "example:01": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/01-tensor-basics/index.ts",
44
+ "example:02": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/02-tensor-operations/index.ts",
45
+ "example:03": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/03-data-analysis/index.ts",
46
+ "example:04": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/04-dataframe-basics/index.ts",
47
+ "example:05": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/05-dataframe-groupby/index.ts",
48
+ "example:06": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/06-ml-pipeline/index.ts",
49
+ "example:07": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/07-linear-regression/index.ts",
50
+ "example:08": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/08-logistic-regression/index.ts",
51
+ "example:09": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/09-ridge-lasso/index.ts",
52
+ "example:10": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/10-advanced-ml-models/index.ts",
53
+ "example:11": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/11-tree-ensemble-models/index.ts",
54
+ "example:12": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/12-complete-pipeline/index.ts",
55
+ "example:13": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/13-neural-network-training/index.ts",
56
+ "example:14": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/14-autograd/index.ts",
57
+ "example:15": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/15-activation-functions/index.ts",
58
+ "example:16": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/16-lr-schedulers/index.ts",
59
+ "example:17": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/17-preprocessing-encoders/index.ts",
60
+ "example:18": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/18-preprocessing-scalers/index.ts",
61
+ "example:19": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/19-statistics/index.ts",
62
+ "example:20": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/20-linear-algebra/index.ts",
63
+ "example:21": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/21-random-sampling/index.ts",
64
+ "example:22": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/22-datasets/index.ts",
65
+ "example:23": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/23-cross-validation/index.ts",
66
+ "example:24": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/24-metrics/index.ts",
67
+ "example:25": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/25-plotting/index.ts",
68
+ "example:26": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/26-sparse-matrices/index.ts",
69
+ "example:27": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/27-cnn-layers/index.ts",
70
+ "example:28": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/28-rnn-lstm-gru/index.ts",
71
+ "example:29": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/29-attention-transformer/index.ts",
72
+ "example:30": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/30-normalization-dropout/index.ts",
73
+ "example:31": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/31-dataloader/index.ts",
74
+ "example:32": "npx tsx --tsconfig docs/examples/tsconfig.json docs/examples/32-module-system/index.ts",
75
+ "examples:all": "npm run example:00 && npm run example:01 && npm run example:02 && npm run example:03 && npm run example:04 && npm run example:05 && npm run example:06 && npm run example:07 && npm run example:08 && npm run example:09 && npm run example:10 && npm run example:11 && npm run example:12 && npm run example:13 && npm run example:14 && npm run example:15 && npm run example:16 && npm run example:17 && npm run example:18 && npm run example:19 && npm run example:20 && npm run example:21 && npm run example:22 && npm run example:23 && npm run example:24 && npm run example:25 && npm run example:26 && npm run example:27 && npm run example:28 && npm run example:29 && npm run example:30 && npm run example:31 && npm run example:32",
76
+ "bench:dataframe": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/01-dataframe.ts",
77
+ "bench:datasets": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/02-datasets.ts",
78
+ "bench:linalg": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/03-linalg.ts",
79
+ "bench:metrics": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/04-metrics.ts",
80
+ "bench:ml": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/05-ml.ts",
81
+ "bench:ndarray": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/06-ndarray.ts",
82
+ "bench:nn": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/07-nn.ts",
83
+ "bench:optim": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/08-optim.ts",
84
+ "bench:plot": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/09-plot.ts",
85
+ "bench:preprocess": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/10-preprocess.ts",
86
+ "bench:random": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/11-random.ts",
87
+ "bench:stats": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/deepbox/12-stats.ts",
88
+ "bench:compare": "npx tsx --tsconfig benchmarks/tsconfig.json benchmarks/compare.ts",
89
+ "bench:deepbox": "npm run bench:dataframe && npm run bench:datasets && npm run bench:linalg && npm run bench:metrics && npm run bench:ml && npm run bench:ndarray && npm run bench:nn && npm run bench:optim && npm run bench:plot && npm run bench:preprocess && npm run bench:random && npm run bench:stats",
90
+ "bench:python": "python3 benchmarks/python/01_dataframe.py && python3 benchmarks/python/02_datasets.py && python3 benchmarks/python/03_linalg.py && python3 benchmarks/python/04_metrics.py && python3 benchmarks/python/05_ml.py && python3 benchmarks/python/06_ndarray.py && python3 benchmarks/python/07_nn.py && python3 benchmarks/python/08_optim.py && python3 benchmarks/python/09_plot.py && python3 benchmarks/python/10_preprocess.py && python3 benchmarks/python/11_random.py && python3 benchmarks/python/12_stats.py",
91
+ "bench:all": "npm run bench:deepbox && npm run bench:python && npm run bench:compare"
92
+ },
93
+ "exports": {
94
+ ".": {
95
+ "types": "./dist/index.d.ts",
96
+ "import": "./dist/index.js",
97
+ "require": "./dist/index.cjs"
98
+ },
99
+ "./core": {
100
+ "types": "./dist/core/index.d.ts",
101
+ "import": "./dist/core/index.js",
102
+ "require": "./dist/core/index.cjs"
103
+ },
104
+ "./ndarray": {
105
+ "types": "./dist/ndarray/index.d.ts",
106
+ "import": "./dist/ndarray/index.js",
107
+ "require": "./dist/ndarray/index.cjs"
108
+ },
109
+ "./linalg": {
110
+ "types": "./dist/linalg/index.d.ts",
111
+ "import": "./dist/linalg/index.js",
112
+ "require": "./dist/linalg/index.cjs"
113
+ },
114
+ "./dataframe": {
115
+ "types": "./dist/dataframe/index.d.ts",
116
+ "import": "./dist/dataframe/index.js",
117
+ "require": "./dist/dataframe/index.cjs"
118
+ },
119
+ "./stats": {
120
+ "types": "./dist/stats/index.d.ts",
121
+ "import": "./dist/stats/index.js",
122
+ "require": "./dist/stats/index.cjs"
123
+ },
124
+ "./metrics": {
125
+ "types": "./dist/metrics/index.d.ts",
126
+ "import": "./dist/metrics/index.js",
127
+ "require": "./dist/metrics/index.cjs"
128
+ },
129
+ "./preprocess": {
130
+ "types": "./dist/preprocess/index.d.ts",
131
+ "import": "./dist/preprocess/index.js",
132
+ "require": "./dist/preprocess/index.cjs"
133
+ },
134
+ "./ml": {
135
+ "types": "./dist/ml/index.d.ts",
136
+ "import": "./dist/ml/index.js",
137
+ "require": "./dist/ml/index.cjs"
138
+ },
139
+ "./nn": {
140
+ "types": "./dist/nn/index.d.ts",
141
+ "import": "./dist/nn/index.js",
142
+ "require": "./dist/nn/index.cjs"
143
+ },
144
+ "./optim": {
145
+ "types": "./dist/optim/index.d.ts",
146
+ "import": "./dist/optim/index.js",
147
+ "require": "./dist/optim/index.cjs"
148
+ },
149
+ "./random": {
150
+ "types": "./dist/random/index.d.ts",
151
+ "import": "./dist/random/index.js",
152
+ "require": "./dist/random/index.cjs"
153
+ },
154
+ "./plot": {
155
+ "types": "./dist/plot/index.d.ts",
156
+ "import": "./dist/plot/index.js",
157
+ "require": "./dist/plot/index.cjs"
158
+ },
159
+ "./datasets": {
160
+ "types": "./dist/datasets/index.d.ts",
161
+ "import": "./dist/datasets/index.js",
162
+ "require": "./dist/datasets/index.cjs"
163
+ }
164
+ },
165
+ "files": [
166
+ "dist",
167
+ "README.md",
168
+ "LICENSE"
169
+ ],
170
+ "devDependencies": {
171
+ "@biomejs/biome": "^2.3.0",
172
+ "@types/node": "^20.0.0",
173
+ "@vitest/coverage-v8": "^4.0.18",
174
+ "tsx": "^4.7.0",
175
+ "tsup": "^8.0.0",
176
+ "typescript": "^5.4.0",
177
+ "vitest": "^4.0.18"
178
+ },
179
+ "keywords": [
180
+ "deepbox",
181
+ "machine-learning",
182
+ "deep-learning",
183
+ "data-science",
184
+ "data-analysis",
185
+ "data-mining",
186
+ "ml",
187
+ "ai",
188
+ "numpy",
189
+ "pandas",
190
+ "pytorch",
191
+ "scikit-learn",
192
+ "tensor",
193
+ "ndarray",
194
+ "dataframe",
195
+ "linear-algebra",
196
+ "statistics",
197
+ "statistical-learning",
198
+ "probability",
199
+ "numerical",
200
+ "numerical-computing",
201
+ "scientific-computing",
202
+ "math",
203
+ "optimization",
204
+ "neural-network",
205
+ "regression",
206
+ "classification",
207
+ "clustering",
208
+ "dimensionality-reduction",
209
+ "preprocessing",
210
+ "feature-engineering",
211
+ "standardization",
212
+ "normalization",
213
+ "scaling",
214
+ "encoding",
215
+ "metrics",
216
+ "cross-validation",
217
+ "time-series"
218
+ ],
219
+ "publishConfig": {
220
+ "access": "public"
221
+ },
222
+ "packageManager": "npm@11.6.2",
223
+ "engines": {
224
+ "node": ">=24.13.0"
225
+ }
226
+ }