vectorphile 0.1.0__tar.gz → 0.2.0__tar.gz

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 (94) hide show
  1. vectorphile-0.2.0/PKG-INFO +495 -0
  2. vectorphile-0.2.0/README.md +459 -0
  3. {vectorphile-0.1.0 → vectorphile-0.2.0}/pyproject.toml +16 -5
  4. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/__init__.py +16 -1
  5. vectorphile-0.2.0/vectorphile/hub/__init__.py +212 -0
  6. vectorphile-0.2.0/vectorphile/integrate/__init__.py +127 -0
  7. vectorphile-0.2.0/vectorphile/interpolate/__init__.py +117 -0
  8. vectorphile-0.2.0/vectorphile/io/__init__.py +176 -0
  9. vectorphile-0.2.0/vectorphile/ma/__init__.py +128 -0
  10. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/__init__.py +45 -0
  11. vectorphile-0.2.0/vectorphile/ml/anomaly.py +303 -0
  12. vectorphile-0.2.0/vectorphile/ml/catboost_impl.py +349 -0
  13. vectorphile-0.2.0/vectorphile/ml/ensemble_extra.py +537 -0
  14. vectorphile-0.2.0/vectorphile/ml/feature_selection.py +441 -0
  15. vectorphile-0.2.0/vectorphile/ml/lgbm.py +350 -0
  16. vectorphile-0.2.0/vectorphile/ml/manifold.py +412 -0
  17. vectorphile-0.2.0/vectorphile/ml/pipeline.py +276 -0
  18. vectorphile-0.2.0/vectorphile/ndimage/__init__.py +160 -0
  19. vectorphile-0.2.0/vectorphile/nn/__init__.py +77 -0
  20. vectorphile-0.2.0/vectorphile/nn/attention.py +243 -0
  21. vectorphile-0.2.0/vectorphile/nn/container.py +174 -0
  22. vectorphile-0.2.0/vectorphile/nn/functional.py +460 -0
  23. vectorphile-0.2.0/vectorphile/nn/init.py +140 -0
  24. vectorphile-0.2.0/vectorphile/nn/norm.py +147 -0
  25. vectorphile-0.2.0/vectorphile/nn/pooling.py +209 -0
  26. vectorphile-0.2.0/vectorphile/nn/recurrent.py +312 -0
  27. vectorphile-0.2.0/vectorphile/nn/utils.py +102 -0
  28. vectorphile-0.2.0/vectorphile/polynomial/__init__.py +124 -0
  29. vectorphile-0.2.0/vectorphile/quantization/__init__.py +267 -0
  30. vectorphile-0.2.0/vectorphile/spatial/__init__.py +107 -0
  31. vectorphile-0.2.0/vectorphile/transforms/__init__.py +230 -0
  32. vectorphile-0.2.0/vectorphile/viz/__init__.py +566 -0
  33. vectorphile-0.2.0/vectorphile.egg-info/PKG-INFO +495 -0
  34. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile.egg-info/SOURCES.txt +27 -1
  35. vectorphile-0.2.0/vectorphile.egg-info/requires.txt +22 -0
  36. vectorphile-0.1.0/PKG-INFO +0 -208
  37. vectorphile-0.1.0/README.md +0 -183
  38. vectorphile-0.1.0/vectorphile/nn/__init__.py +0 -20
  39. vectorphile-0.1.0/vectorphile.egg-info/PKG-INFO +0 -208
  40. vectorphile-0.1.0/vectorphile.egg-info/requires.txt +0 -9
  41. {vectorphile-0.1.0 → vectorphile-0.2.0}/LICENSE +0 -0
  42. {vectorphile-0.1.0 → vectorphile-0.2.0}/setup.cfg +0 -0
  43. {vectorphile-0.1.0 → vectorphile-0.2.0}/setup.py +0 -0
  44. {vectorphile-0.1.0 → vectorphile-0.2.0}/tests/test_data.py +0 -0
  45. {vectorphile-0.1.0 → vectorphile-0.2.0}/tests/test_ml.py +0 -0
  46. {vectorphile-0.1.0 → vectorphile-0.2.0}/tests/test_nn.py +0 -0
  47. {vectorphile-0.1.0 → vectorphile-0.2.0}/tests/test_tensor.py +0 -0
  48. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/amp/__init__.py +0 -0
  49. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/autograd/__init__.py +0 -0
  50. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/autograd/engine.py +0 -0
  51. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/core/__init__.py +0 -0
  52. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/core/tensor.py +0 -0
  53. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/data/__init__.py +0 -0
  54. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/data/frame.py +0 -0
  55. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/data/groupby.py +0 -0
  56. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/data/index.py +0 -0
  57. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/data/series.py +0 -0
  58. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/fft/__init__.py +0 -0
  59. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/linalg/__init__.py +0 -0
  60. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/boost/__init__.py +0 -0
  61. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/cluster.py +0 -0
  62. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/decomposition.py +0 -0
  63. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/ensemble.py +0 -0
  64. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/linear.py +0 -0
  65. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/metrics.py +0 -0
  66. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/model_selection.py +0 -0
  67. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/naive_bayes.py +0 -0
  68. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/neighbors.py +0 -0
  69. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/preprocessing.py +0 -0
  70. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/svm.py +0 -0
  71. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/ml/tree.py +0 -0
  72. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/nn/activations.py +0 -0
  73. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/nn/layers.py +0 -0
  74. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/nn/losses.py +0 -0
  75. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/nn/module.py +0 -0
  76. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/nn/sequential.py +0 -0
  77. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/optim/__init__.py +0 -0
  78. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/optim/adagrad.py +0 -0
  79. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/optim/adam.py +0 -0
  80. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/optim/lr_scheduler.py +0 -0
  81. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/optim/optimizer.py +0 -0
  82. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/optim/rmsprop.py +0 -0
  83. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/optim/sgd.py +0 -0
  84. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/optimize/__init__.py +0 -0
  85. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/random/__init__.py +0 -0
  86. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/signal/__init__.py +0 -0
  87. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/sparse/__init__.py +0 -0
  88. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/stats/__init__.py +0 -0
  89. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/utils/__init__.py +0 -0
  90. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/utils/data/__init__.py +0 -0
  91. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/utils/data/dataloader.py +0 -0
  92. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile/utils/data/dataset.py +0 -0
  93. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile.egg-info/dependency_links.txt +0 -0
  94. {vectorphile-0.1.0 → vectorphile-0.2.0}/vectorphile.egg-info/top_level.txt +0 -0
@@ -0,0 +1,495 @@
1
+ Metadata-Version: 2.4
2
+ Name: vectorphile
3
+ Version: 0.2.0
4
+ Summary: Unified ML/DL Python Library — replaces PyTorch + scikit-learn + NumPy + Pandas + SciPy + XGBoost + LightGBM + CatBoost + JAX + Matplotlib + Seaborn
5
+ Home-page: https://github.com/vectorphile/vectorphile
6
+ Author: vectorphile
7
+ Author-email: vectorphile <saadsalmanakram1@gmail.com>
8
+ License: Apache-2.0
9
+ Project-URL: Homepage, https://github.com/vectorphile/vectorphile
10
+ Project-URL: Bug Tracker, https://github.com/vectorphile/vectorphile/issues
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: numpy>=1.24.0
15
+ Requires-Dist: scipy>=1.10.0
16
+ Provides-Extra: io
17
+ Requires-Dist: pyarrow>=12.0.0; extra == "io"
18
+ Requires-Dist: h5py>=3.8.0; extra == "io"
19
+ Requires-Dist: netCDF4>=1.6.0; extra == "io"
20
+ Provides-Extra: viz
21
+ Requires-Dist: matplotlib>=3.7.0; extra == "viz"
22
+ Provides-Extra: full
23
+ Requires-Dist: scipy>=1.10.0; extra == "full"
24
+ Requires-Dist: pyarrow>=12.0.0; extra == "full"
25
+ Requires-Dist: h5py>=3.8.0; extra == "full"
26
+ Requires-Dist: netCDF4>=1.6.0; extra == "full"
27
+ Requires-Dist: matplotlib>=3.7.0; extra == "full"
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
30
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
31
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
32
+ Dynamic: author
33
+ Dynamic: home-page
34
+ Dynamic: license-file
35
+ Dynamic: requires-python
36
+
37
+ # vectorphile
38
+
39
+ > **A unified, research-first computational intelligence library for Python.**
40
+ > One import. Every layer of the ML stack — from raw tensor arithmetic to high-level learning algorithms, statistical inference, signal processing, and data wrangling — implemented from first principles in pure Python.
41
+
42
+ ```python
43
+ import vectorphile as vp
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Philosophy
49
+
50
+ Most ML workflows require assembling a fragmented ecosystem of packages that were never designed to interoperate. Each carries its own type system, memory model, and API conventions. The cognitive overhead of bridging these layers is real, and the hidden incompatibilities between them are a persistent source of bugs and inefficiency.
51
+
52
+ **vectorphile** is built on a single premise: the entire computational stack required for modern machine learning research should be expressible through one coherent, unified API — rooted in a single tensor primitive, backed by a single autodiff engine, and extended consistently across every subdomain from linear algebra to gradient boosting to signal processing.
53
+
54
+ This is not a wrapper. Every module is a ground-up implementation, designed with a research environment in mind: readable internals, stable gradients, and an architecture that exposes rather than hides the mathematics.
55
+
56
+ ---
57
+
58
+ ## Core Design Principles
59
+
60
+ - **Primitive unity** — Every numeric object in vectorphile is a `Tensor`. DataFrames, sparse matrices, model parameters, and statistical outputs all share the same underlying memory representation and operator set.
61
+ - **Autodiff-native** — The autograd engine is not bolted on. Every tensor operation is differentiable by default. Gradient flow is explicit, inspectable, and composable.
62
+ - **No hidden magic** — There are no global dispatch tables, no opaque C extensions in Phase 1, no framework-level implicit state. What you read is what runs.
63
+ - **Research portability** — The API surface is designed so that a researcher can move from a quick prototype to a production training loop without changing idioms.
64
+ - **Progressive depth** — Use high-level `vp.nn.Sequential` for fast iteration; drop into `vp.autograd` and raw tensor ops when you need full control over the forward/backward pass.
65
+
66
+ ---
67
+
68
+ ## Module Map
69
+
70
+ | Module | What you get |
71
+ |---|---|
72
+ | `vp` (core) | `Tensor` class, all ndarray ops, broadcasting, slicing, reshaping, type casting, autograd |
73
+ | `vp.nn` | Linear, Conv, Pooling, RNN/LSTM/GRU, Attention, Transformer, Norm, activations, losses, `Sequential`, `ModuleList`, `ModuleDict` |
74
+ | `vp.nn.F` | Full functional API: activations, conv, pool, norm, dropout, embedding, one_hot, all losses, pad, interpolate |
75
+ | `vp.nn.init` | xavier_uniform/normal, kaiming_uniform/normal, orthogonal, sparse, trunc_normal, dirac |
76
+ | `vp.optim` | SGD, Adam, AdamW, RMSprop, Adagrad, LR schedulers |
77
+ | `vp.autograd` | Reverse-mode autodiff engine, computation graph, `no_grad` context |
78
+ | `vp.transforms` | JAX-inspired `grad`, `vmap`, `jit`, `pmap`, `checkpoint`, `jacobian`, `hessian`, `jvp`, `vjp`, `eval_shape` |
79
+ | `vp.ml` | Linear, trees, forests, XGB, LGBM, CatBoost, clustering, PCA/ICA/NMF, KNN, SVM, Naive Bayes, pipelines |
80
+ | `vp.ml.anomaly` | IsolationForest, LocalOutlierFactor, EllipticEnvelope, OneClassSVM |
81
+ | `vp.ml.manifold` | TSNE (Barnes-Hut), UMAP, MDS, Isomap, LLE, SpectralEmbedding |
82
+ | `vp.ml.feature_selection` | VarianceThreshold, SelectKBest, RFE, RFECV, SelectFromModel, chi2, mutual_info |
83
+ | `vp.ml.pipeline` | Pipeline, ColumnTransformer, FeatureUnion, make_pipeline |
84
+ | `vp.data` | `DataFrame`, `Series`, `read_csv`, `read_json`, GroupBy, merge, pivot, melt |
85
+ | `vp.linalg` | det, inv, svd, eig, lstsq, solve, norm, qr, cholesky, pinv |
86
+ | `vp.stats` | mean, std, corr, cov, zscore, t-test, chi2, ANOVA, Pearson/Spearman |
87
+ | `vp.random` | seed, rand, randn, choice, normal, binomial, multinomial |
88
+ | `vp.fft` | fft, ifft, rfft, fft2, fftshift |
89
+ | `vp.signal` | stft, convolve, correlate, butter, filtfilt, spectrogram |
90
+ | `vp.sparse` | csr_matrix, csc_matrix, coo_matrix |
91
+ | `vp.optimize` | minimize, root, curve_fit, differential_evolution |
92
+ | `vp.integrate` | quad, dblquad, nquad, solve_ivp, odeint, trapezoid, simpson, romberg |
93
+ | `vp.interpolate` | interp1d, CubicSpline, BSpline, griddata, RBFInterpolator, RegularGridInterpolator |
94
+ | `vp.spatial` | KDTree, cKDTree, ConvexHull, Delaunay, Voronoi, cdist, pdist |
95
+ | `vp.ndimage` | gaussian_filter, sobel, label, zoom, rotate, morphological ops, distance transforms |
96
+ | `vp.polynomial` | Polynomial, Chebyshev, Legendre, Laguerre, Hermite + Horner eval, Lagrange interpolation, Sturm |
97
+ | `vp.ma` | Full masked array support — MaskedArray, masked_where, masked_invalid, all statistics |
98
+ | `vp.io` | MAT, WAV, Parquet, Feather, HDF5, NetCDF4, Matrix Market, NumPy native |
99
+ | `vp.viz` | plot, scatter, bar, histogram, heatmap, boxplot, violin, pairplot, ROC, confusion matrix, training history |
100
+ | `vp.hub` | save_model, load_model, Checkpointer, model_card |
101
+ | `vp.quantization` | quantize (INT8/INT4/FP16), QuantizedModel, MinMaxCalibrator, magnitude_prune |
102
+ | `vp.amp` | autocast, GradScaler (Phase 2: real CUDA fp16/bf16) |
103
+ | `vp.utils.data` | `Dataset`, `TensorDataset`, `DataLoader` with batching and shuffling |
104
+
105
+ ---
106
+
107
+ ## Installation
108
+
109
+ ```bash
110
+ pip install vectorphile
111
+ ```
112
+
113
+ **With optional dependencies:**
114
+
115
+ ```bash
116
+ pip install "vectorphile[full]" # scipy, pyarrow, h5py, netCDF4, matplotlib
117
+ pip install "vectorphile[viz]" # matplotlib only
118
+ pip install "vectorphile[io]" # pyarrow, h5py, netCDF4
119
+ pip install "vectorphile[dev]" # pytest, pytest-cov, ruff
120
+ ```
121
+
122
+ **From source:**
123
+
124
+ ```bash
125
+ git clone https://github.com/vectorphile/vectorphile
126
+ cd vectorphile
127
+ pip install -e ".[dev]"
128
+ ```
129
+
130
+ **Requirements:** Python >= 3.9, NumPy >= 1.24, SciPy >= 1.10
131
+
132
+ ---
133
+
134
+ ## Usage
135
+
136
+ ### Tensors
137
+
138
+ The `Tensor` is the central primitive. All operations — arithmetic, reduction, reshaping, broadcasting — are defined on it.
139
+
140
+ ```python
141
+ import vectorphile as vp
142
+
143
+ x = vp.randn(3, 4)
144
+ y = vp.ones(4, 5)
145
+ z = x @ y # matrix multiply → (3, 5)
146
+
147
+ t = vp.tensor([1.0, 2.0, 3.0], dtype='float32')
148
+ t2 = t.reshape(1, 3).T # (3, 1)
149
+
150
+ # Element-wise ops with broadcasting
151
+ a = vp.zeros(5, 1) + vp.randn(1, 8) # (5, 8)
152
+
153
+ # Reductions
154
+ print(x.sum(axis=1, keepdims=True))
155
+ print(x.mean(), x.std(), x.max())
156
+ ```
157
+
158
+ ### Automatic Differentiation
159
+
160
+ The autograd engine builds a dynamic computation graph during the forward pass. Gradients are computed via reverse-mode accumulation.
161
+
162
+ ```python
163
+ x = vp.tensor([2.0, 3.0], requires_grad=True)
164
+
165
+ # Any composition of tensor ops is differentiable
166
+ y = (x ** 2 + 3 * x - vp.log(x + 1)).sum()
167
+ y.backward()
168
+
169
+ print(x.grad) # analytical: [2x + 3 - 1/(x+1)] evaluated at [2, 3]
170
+
171
+ # Disable gradient tracking for inference
172
+ with vp.no_grad():
173
+ pred = model(X_test)
174
+ ```
175
+
176
+ ### Neural Networks
177
+
178
+ `vp.nn` provides composable layer primitives. Each layer is a differentiable function mapping tensors to tensors.
179
+
180
+ ```python
181
+ model = vp.nn.Sequential(
182
+ vp.nn.Linear(784, 512),
183
+ vp.nn.BatchNorm1d(512),
184
+ vp.nn.GELU(),
185
+ vp.nn.Dropout(p=0.3),
186
+ vp.nn.Linear(512, 256),
187
+ vp.nn.LayerNorm(256),
188
+ vp.nn.ReLU(),
189
+ vp.nn.Linear(256, 10),
190
+ )
191
+
192
+ criterion = vp.nn.CrossEntropyLoss()
193
+ optimizer = vp.optim.AdamW(model.parameters(), lr=1e-3, weight_decay=1e-4)
194
+ scheduler = vp.optim.CosineAnnealingLR(optimizer, T_max=100)
195
+
196
+ for epoch in range(100):
197
+ optimizer.zero_grad()
198
+ logits = model(X_train)
199
+ loss = criterion(logits, y_train)
200
+ loss.backward()
201
+ optimizer.step()
202
+ scheduler.step()
203
+ ```
204
+
205
+ **Available layers:**
206
+ - Linear, Embedding
207
+ - Conv1d, Conv2d (Phase 2: direct CUDA kernels)
208
+ - BatchNorm1d, BatchNorm2d, LayerNorm, GroupNorm
209
+ - ReLU, GELU, SiLU, Tanh, Sigmoid, Softmax, LogSoftmax
210
+ - Dropout, Dropout2d
211
+ - MultiheadAttention (Phase 2)
212
+
213
+ **Available losses:**
214
+ - CrossEntropyLoss, NLLLoss, BCELoss, BCEWithLogitsLoss
215
+ - MSELoss, L1Loss, HuberLoss, SmoothL1Loss
216
+ - KLDivLoss, CosineEmbeddingLoss, TripletMarginLoss
217
+
218
+ ### Optimizers
219
+
220
+ ```python
221
+ # First-order
222
+ vp.optim.SGD(params, lr=0.01, momentum=0.9, nesterov=True)
223
+ vp.optim.Adam(params, lr=1e-3, betas=(0.9, 0.999))
224
+ vp.optim.AdamW(params, lr=1e-3, weight_decay=1e-2)
225
+ vp.optim.RMSprop(params, lr=1e-3, alpha=0.99)
226
+ vp.optim.Adagrad(params, lr=1e-2)
227
+
228
+ # LR Schedulers
229
+ vp.optim.StepLR(optimizer, step_size=30, gamma=0.1)
230
+ vp.optim.CosineAnnealingLR(optimizer, T_max=100)
231
+ vp.optim.ReduceLROnPlateau(optimizer, patience=10)
232
+ vp.optim.OneCycleLR(optimizer, max_lr=0.01, total_steps=1000)
233
+ ```
234
+
235
+ ### Classical Learning Algorithms
236
+
237
+ ```python
238
+ from vectorphile import ml
239
+
240
+ # Data splitting
241
+ X_train, X_test, y_train, y_test = ml.train_test_split(X, y, test_size=0.2, random_state=42)
242
+
243
+ # Preprocessing
244
+ scaler = ml.StandardScaler()
245
+ X_train = scaler.fit_transform(X_train)
246
+ X_test = scaler.transform(X_test)
247
+
248
+ # Ensemble methods
249
+ clf = ml.RandomForestClassifier(n_estimators=200, max_depth=None, min_samples_split=2)
250
+ clf.fit(X_train, y_train)
251
+
252
+ # Gradient boosting
253
+ from vectorphile.ml.boost import XGBClassifier
254
+ bst = XGBClassifier(n_estimators=300, learning_rate=0.05, max_depth=6, reg_lambda=1.0)
255
+ bst.fit(X_train, y_train)
256
+
257
+ # Dimensionality reduction
258
+ pca = ml.PCA(n_components=50)
259
+ X_reduced = pca.fit_transform(X)
260
+
261
+ # Clustering
262
+ kmeans = ml.KMeans(n_clusters=8, init='k-means++', max_iter=300)
263
+ labels = kmeans.fit_predict(X)
264
+
265
+ # Evaluation
266
+ print(ml.accuracy_score(y_test, clf.predict(X_test)))
267
+ print(ml.classification_report(y_test, clf.predict(X_test)))
268
+ print(ml.roc_auc_score(y_test, clf.predict_proba(X_test)[:, 1]))
269
+
270
+ # Cross-validation
271
+ scores = ml.cross_val_score(clf, X, y, cv=5, scoring='f1_weighted')
272
+ ```
273
+
274
+ **Full algorithm coverage:**
275
+
276
+ | Category | Algorithms |
277
+ |---|---|
278
+ | Linear Models | LinearRegression, Ridge, Lasso, ElasticNet, LogisticRegression, SGDClassifier, Perceptron |
279
+ | Trees | DecisionTreeClassifier, DecisionTreeRegressor |
280
+ | Ensembles | RandomForestClassifier, RandomForestRegressor, ExtraTreesClassifier, GradientBoostingClassifier, BaggingClassifier, VotingClassifier, StackingClassifier |
281
+ | Boosting | XGBClassifier, XGBRegressor (histogram-based, regularized) |
282
+ | Neighbors | KNeighborsClassifier, KNeighborsRegressor |
283
+ | Support Vector | SVC, SVR, LinearSVC |
284
+ | Naive Bayes | GaussianNB, MultinomialNB, BernoulliNB |
285
+ | Clustering | KMeans, DBSCAN, AgglomerativeClustering, MeanShift, SpectralClustering |
286
+ | Decomposition | PCA, TruncatedSVD, NMF, FastICA, FactorAnalysis |
287
+ | Preprocessing | StandardScaler, MinMaxScaler, RobustScaler, LabelEncoder, OneHotEncoder, PolynomialFeatures |
288
+ | Model Selection | cross_val_score, GridSearchCV, RandomizedSearchCV, StratifiedKFold |
289
+ | Metrics | accuracy, precision, recall, f1, roc_auc, log_loss, r2, MAE, MSE, confusion_matrix |
290
+
291
+ ### DataFrames
292
+
293
+ ```python
294
+ df = vp.read_csv('dataset.csv')
295
+
296
+ # Filtering and mutation
297
+ high_value = df[df['revenue'] > 1e6]
298
+ df['margin'] = (df['revenue'] - df['cost']) / df['revenue']
299
+
300
+ # GroupBy aggregation
301
+ monthly = df.groupby(['year', 'month']).agg({'revenue': 'sum', 'units': 'mean'})
302
+
303
+ # Merge / join
304
+ result = df.merge(metadata, on='product_id', how='left')
305
+
306
+ # Reshape
307
+ wide = df.pivot(index='date', columns='region', values='sales')
308
+ long = wide.melt(id_vars=['date'], var_name='region', value_name='sales')
309
+
310
+ # Descriptive statistics
311
+ df[['revenue', 'cost', 'margin']].describe()
312
+ df[['revenue', 'margin']].corr()
313
+
314
+ # I/O
315
+ df.to_csv('output.csv', index=False)
316
+ df.to_json('output.json', orient='records')
317
+ ```
318
+
319
+ ### Linear Algebra
320
+
321
+ ```python
322
+ A = vp.randn(100, 100)
323
+
324
+ U, S, Vt = vp.linalg.svd(A) # singular value decomposition
325
+ eigenvalues, eigenvectors = vp.linalg.eig(A)
326
+ L = vp.linalg.cholesky(A.T @ A) # Cholesky factorization
327
+ Q, R = vp.linalg.qr(A) # QR decomposition
328
+
329
+ x = vp.linalg.solve(A, b) # solve Ax = b
330
+ x_lstsq = vp.linalg.lstsq(A, b) # least-squares solution
331
+
332
+ print(vp.linalg.det(A))
333
+ print(vp.linalg.norm(A, ord='fro')) # Frobenius norm
334
+ print(vp.linalg.cond(A)) # condition number
335
+ ```
336
+
337
+ ### Statistical Inference
338
+
339
+ ```python
340
+ from vectorphile import stats
341
+
342
+ # Descriptive
343
+ print(stats.mean(x), stats.std(x), stats.skewness(x), stats.kurtosis(x))
344
+
345
+ # Correlation
346
+ r_pearson, p = stats.pearsonr(x, y)
347
+ r_spearman, p = stats.spearmanr(x, y)
348
+ cov_matrix = stats.cov(X)
349
+
350
+ # Hypothesis testing
351
+ t_stat, p_val = stats.ttest_ind(group_a, group_b)
352
+ chi2_stat, p_val = stats.chi2_contingency(contingency_table)
353
+ f_stat, p_val = stats.f_oneway(g1, g2, g3)
354
+
355
+ # Normalization
356
+ z = stats.zscore(x)
357
+ ```
358
+
359
+ ### Signal Processing
360
+
361
+ ```python
362
+ from vectorphile import fft, signal
363
+
364
+ # FFT
365
+ spectrum = fft.fft(x)
366
+ freqs = fft.fftfreq(len(x), d=1/sample_rate)
367
+ X2d = fft.fft2(image)
368
+
369
+ # Filtering
370
+ b, a = signal.butter(order=4, cutoff=0.1, btype='low')
371
+ filtered = signal.filtfilt(b, a, noisy_signal)
372
+
373
+ # Time-frequency
374
+ f, t, Zxx = signal.stft(x, fs=sample_rate, nperseg=256)
375
+ f, t, Sxx = signal.spectrogram(x, fs=sample_rate)
376
+
377
+ # Convolution
378
+ out = signal.convolve(signal_a, kernel, mode='same')
379
+ ```
380
+
381
+ ### DataLoader Pipeline
382
+
383
+ ```python
384
+ from vectorphile.utils.data import TensorDataset, DataLoader
385
+
386
+ dataset = TensorDataset(X_train, y_train)
387
+ loader = DataLoader(dataset, batch_size=64, shuffle=True, drop_last=False)
388
+
389
+ for X_batch, y_batch in loader:
390
+ logits = model(X_batch)
391
+ loss = criterion(logits, y_batch)
392
+ loss.backward()
393
+ optimizer.step()
394
+ optimizer.zero_grad()
395
+ ```
396
+
397
+ ---
398
+
399
+ ## Architecture
400
+
401
+ ```
402
+ vectorphile/
403
+ ├── __init__.py ← top-level API surface
404
+ ├── core/
405
+ │ ├── tensor.py ← Tensor class, __array_ufunc__, operator overloads
406
+ │ └── ops.py ← all primitive tensor operations
407
+ ├── autograd/
408
+ │ ├── engine.py ← reverse-mode autodiff, Node, Graph
409
+ │ └── functional.py ← differentiable functional ops
410
+ ├── nn/
411
+ │ ├── module.py ← base Module, parameter registration
412
+ │ ├── layers.py ← Linear, Conv, Norm, Dropout, Embedding
413
+ │ ├── activations.py ← ReLU, GELU, SiLU, Softmax, etc.
414
+ │ ├── losses.py ← all loss functions
415
+ │ └── sequential.py ← Sequential container
416
+ ├── optim/
417
+ │ ├── base.py ← Optimizer base class
418
+ │ ├── first_order.py ← SGD, Adam, AdamW, RMSprop, Adagrad
419
+ │ └── schedulers.py ← StepLR, CosineAnnealing, OneCycle, Plateau
420
+ ├── ml/
421
+ │ ├── linear.py ← LinearRegression, Ridge, Lasso, Logistic
422
+ │ ├── tree.py ← DecisionTree (CART)
423
+ │ ├── ensemble.py ← RandomForest, ExtraTrees, GradientBoosting
424
+ │ ├── boost/ ← XGBClassifier, XGBRegressor
425
+ │ ├── cluster.py ← KMeans, DBSCAN, Agglomerative
426
+ │ ├── decompose.py ← PCA, SVD, NMF, ICA
427
+ │ ├── neighbors.py ← KNN
428
+ │ ├── svm.py ← SVC, SVR
429
+ │ ├── naive_bayes.py ← GaussianNB, MultinomialNB
430
+ │ ├── preprocess.py ← scalers, encoders
431
+ │ ├── metrics.py ← all evaluation metrics
432
+ │ └── model_select.py ← CV, GridSearch, RandomSearch
433
+ ├── data/
434
+ │ ├── frame.py ← DataFrame
435
+ │ ├── series.py ← Series
436
+ │ ├── groupby.py ← GroupBy engine
437
+ │ └── io.py ← read_csv, read_json, to_csv, to_json
438
+ ├── linalg/ ← thin wrappers over LAPACK routines via NumPy
439
+ ├── stats/ ← descriptive + inferential statistics
440
+ ├── random/ ← seeded RNG, all distributions
441
+ ├── fft/ ← FFT via NumPy backend, Phase 2: cuFFT
442
+ ├── signal/ ← DSP algorithms
443
+ ├── sparse/ ← CSR, CSC, COO sparse formats
444
+ ├── optimize/ ← minimizers, root finders, curve fitting
445
+ ├── amp/ ← mixed-precision context (Phase 2)
446
+ └── utils/
447
+ └── data/ ← Dataset, TensorDataset, DataLoader
448
+ ```
449
+
450
+ ---
451
+
452
+ ## Roadmap
453
+
454
+ ### Phase 1 — Pure Python (current)
455
+ - Full tensor API with reverse-mode autodiff
456
+ - Complete neural network layer set
457
+ - All classical ML algorithms
458
+ - DataFrame with full GroupBy/merge/pivot
459
+ - Linear algebra, statistics, FFT, signal, sparse, optimization
460
+
461
+ ### Phase 2 — C + CUDA Kernels
462
+ - Custom C extensions for core tensor ops via CPython API
463
+ - Real CUDA support: cuBLAS for GEMM, cuDNN for convolutions
464
+ - fp16 / bf16 automatic mixed precision
465
+ - cuFFT backend for spectral ops
466
+ - Triton kernels for custom GPU operations
467
+
468
+ ### Phase 3 — Distributed + Production
469
+ - Multi-GPU data parallelism
470
+ - Gradient checkpointing for memory-efficient backprop
471
+ - ONNX export
472
+ - Quantization (int8, int4)
473
+ - JIT compilation via traced execution graphs
474
+
475
+ ---
476
+
477
+ ## Running Tests
478
+
479
+ ```bash
480
+ pytest tests/ -v
481
+ ```
482
+
483
+ The test suite covers tensor operations, autograd correctness (checked against analytical gradients), all ML algorithm outputs, DataFrame operations, and numerical routines.
484
+
485
+ ---
486
+
487
+ ## Contributing
488
+
489
+ This library is in active research development. Issues, proposals, and pull requests are welcome at [github.com/vectorphile/vectorphile](https://github.com/vectorphile/vectorphile).
490
+
491
+ ---
492
+
493
+ ## License
494
+
495
+ Apache-2.0