vectorphile 0.1.0__tar.gz → 0.3.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 (132) hide show
  1. vectorphile-0.3.0/PKG-INFO +554 -0
  2. vectorphile-0.3.0/README.md +493 -0
  3. vectorphile-0.3.0/pyproject.toml +74 -0
  4. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/__init__.py +34 -1
  5. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/autograd/__init__.py +7 -1
  6. vectorphile-0.3.0/vectorphile/autograd/functional.py +171 -0
  7. vectorphile-0.3.0/vectorphile/backend/__init__.py +474 -0
  8. vectorphile-0.3.0/vectorphile/backend/_torch_backend.py +287 -0
  9. vectorphile-0.3.0/vectorphile/callbacks/__init__.py +521 -0
  10. vectorphile-0.3.0/vectorphile/cuda/__init__.py +454 -0
  11. vectorphile-0.3.0/vectorphile/cuda/triton_kernels.py +189 -0
  12. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/data/__init__.py +19 -0
  13. vectorphile-0.3.0/vectorphile/data/datasets.py +571 -0
  14. vectorphile-0.3.0/vectorphile/distributed/__init__.py +311 -0
  15. vectorphile-0.3.0/vectorphile/export/__init__.py +370 -0
  16. vectorphile-0.3.0/vectorphile/export/_gguf.py +449 -0
  17. vectorphile-0.3.0/vectorphile/hub/__init__.py +212 -0
  18. vectorphile-0.3.0/vectorphile/integrate/__init__.py +127 -0
  19. vectorphile-0.3.0/vectorphile/interpolate/__init__.py +117 -0
  20. vectorphile-0.3.0/vectorphile/io/__init__.py +176 -0
  21. vectorphile-0.3.0/vectorphile/ma/__init__.py +128 -0
  22. vectorphile-0.3.0/vectorphile/metrics/__init__.py +538 -0
  23. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/__init__.py +45 -0
  24. vectorphile-0.3.0/vectorphile/ml/anomaly.py +303 -0
  25. vectorphile-0.3.0/vectorphile/ml/catboost_impl.py +349 -0
  26. vectorphile-0.3.0/vectorphile/ml/ensemble_extra.py +537 -0
  27. vectorphile-0.3.0/vectorphile/ml/feature_selection.py +441 -0
  28. vectorphile-0.3.0/vectorphile/ml/lgbm.py +350 -0
  29. vectorphile-0.3.0/vectorphile/ml/manifold.py +412 -0
  30. vectorphile-0.3.0/vectorphile/ml/pipeline.py +276 -0
  31. vectorphile-0.3.0/vectorphile/ndimage/__init__.py +160 -0
  32. vectorphile-0.3.0/vectorphile/nn/__init__.py +107 -0
  33. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/nn/activations.py +6 -7
  34. vectorphile-0.3.0/vectorphile/nn/architectures/__init__.py +149 -0
  35. vectorphile-0.3.0/vectorphile/nn/architectures/attention.py +284 -0
  36. vectorphile-0.3.0/vectorphile/nn/architectures/cnn.py +646 -0
  37. vectorphile-0.3.0/vectorphile/nn/architectures/generative.py +613 -0
  38. vectorphile-0.3.0/vectorphile/nn/architectures/graph.py +477 -0
  39. vectorphile-0.3.0/vectorphile/nn/architectures/ssm.py +484 -0
  40. vectorphile-0.3.0/vectorphile/nn/architectures/transformer.py +829 -0
  41. vectorphile-0.3.0/vectorphile/nn/architectures/unet.py +377 -0
  42. vectorphile-0.3.0/vectorphile/nn/architectures/vision_transformer.py +384 -0
  43. vectorphile-0.3.0/vectorphile/nn/attention.py +243 -0
  44. vectorphile-0.3.0/vectorphile/nn/container.py +174 -0
  45. vectorphile-0.3.0/vectorphile/nn/einops.py +376 -0
  46. vectorphile-0.3.0/vectorphile/nn/flash_attention.py +214 -0
  47. vectorphile-0.3.0/vectorphile/nn/functional.py +460 -0
  48. vectorphile-0.3.0/vectorphile/nn/hooks.py +245 -0
  49. vectorphile-0.3.0/vectorphile/nn/init.py +140 -0
  50. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/nn/layers.py +41 -79
  51. vectorphile-0.3.0/vectorphile/nn/lr_schedulers.py +302 -0
  52. vectorphile-0.3.0/vectorphile/nn/norm.py +147 -0
  53. vectorphile-0.3.0/vectorphile/nn/optimizers_advanced.py +585 -0
  54. vectorphile-0.3.0/vectorphile/nn/pooling.py +209 -0
  55. vectorphile-0.3.0/vectorphile/nn/qat.py +296 -0
  56. vectorphile-0.3.0/vectorphile/nn/recurrent.py +312 -0
  57. vectorphile-0.3.0/vectorphile/nn/utils.py +102 -0
  58. vectorphile-0.3.0/vectorphile/polynomial/__init__.py +124 -0
  59. vectorphile-0.3.0/vectorphile/pretrained/__init__.py +346 -0
  60. vectorphile-0.3.0/vectorphile/pretrained/_config_loader.py +93 -0
  61. vectorphile-0.3.0/vectorphile/pretrained/_downloader.py +347 -0
  62. vectorphile-0.3.0/vectorphile/pretrained/_mappers.py +407 -0
  63. vectorphile-0.3.0/vectorphile/pretrained/_registry.py +272 -0
  64. vectorphile-0.3.0/vectorphile/quantization/__init__.py +267 -0
  65. vectorphile-0.3.0/vectorphile/rl/__init__.py +1184 -0
  66. vectorphile-0.3.0/vectorphile/spatial/__init__.py +107 -0
  67. vectorphile-0.3.0/vectorphile/text/__init__.py +482 -0
  68. vectorphile-0.3.0/vectorphile/tokenizers/__init__.py +569 -0
  69. vectorphile-0.3.0/vectorphile/trainer/__init__.py +404 -0
  70. vectorphile-0.3.0/vectorphile/transforms/__init__.py +230 -0
  71. vectorphile-0.3.0/vectorphile/vision/__init__.py +542 -0
  72. vectorphile-0.3.0/vectorphile/viz/__init__.py +566 -0
  73. vectorphile-0.3.0/vectorphile.egg-info/PKG-INFO +554 -0
  74. vectorphile-0.3.0/vectorphile.egg-info/SOURCES.txt +124 -0
  75. vectorphile-0.3.0/vectorphile.egg-info/requires.txt +55 -0
  76. vectorphile-0.1.0/PKG-INFO +0 -208
  77. vectorphile-0.1.0/README.md +0 -183
  78. vectorphile-0.1.0/pyproject.toml +0 -40
  79. vectorphile-0.1.0/vectorphile/nn/__init__.py +0 -20
  80. vectorphile-0.1.0/vectorphile.egg-info/PKG-INFO +0 -208
  81. vectorphile-0.1.0/vectorphile.egg-info/SOURCES.txt +0 -62
  82. vectorphile-0.1.0/vectorphile.egg-info/requires.txt +0 -9
  83. {vectorphile-0.1.0 → vectorphile-0.3.0}/LICENSE +0 -0
  84. {vectorphile-0.1.0 → vectorphile-0.3.0}/setup.cfg +0 -0
  85. {vectorphile-0.1.0 → vectorphile-0.3.0}/setup.py +0 -0
  86. {vectorphile-0.1.0 → vectorphile-0.3.0}/tests/test_data.py +0 -0
  87. {vectorphile-0.1.0 → vectorphile-0.3.0}/tests/test_ml.py +0 -0
  88. {vectorphile-0.1.0 → vectorphile-0.3.0}/tests/test_nn.py +0 -0
  89. {vectorphile-0.1.0 → vectorphile-0.3.0}/tests/test_tensor.py +0 -0
  90. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/amp/__init__.py +0 -0
  91. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/autograd/engine.py +0 -0
  92. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/core/__init__.py +0 -0
  93. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/core/tensor.py +0 -0
  94. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/data/frame.py +0 -0
  95. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/data/groupby.py +0 -0
  96. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/data/index.py +0 -0
  97. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/data/series.py +0 -0
  98. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/fft/__init__.py +0 -0
  99. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/linalg/__init__.py +0 -0
  100. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/boost/__init__.py +0 -0
  101. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/cluster.py +0 -0
  102. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/decomposition.py +0 -0
  103. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/ensemble.py +0 -0
  104. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/linear.py +0 -0
  105. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/metrics.py +0 -0
  106. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/model_selection.py +0 -0
  107. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/naive_bayes.py +0 -0
  108. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/neighbors.py +0 -0
  109. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/preprocessing.py +0 -0
  110. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/svm.py +0 -0
  111. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/ml/tree.py +0 -0
  112. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/nn/losses.py +0 -0
  113. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/nn/module.py +0 -0
  114. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/nn/sequential.py +0 -0
  115. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/optim/__init__.py +0 -0
  116. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/optim/adagrad.py +0 -0
  117. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/optim/adam.py +0 -0
  118. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/optim/lr_scheduler.py +0 -0
  119. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/optim/optimizer.py +0 -0
  120. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/optim/rmsprop.py +0 -0
  121. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/optim/sgd.py +0 -0
  122. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/optimize/__init__.py +0 -0
  123. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/random/__init__.py +0 -0
  124. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/signal/__init__.py +0 -0
  125. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/sparse/__init__.py +0 -0
  126. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/stats/__init__.py +0 -0
  127. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/utils/__init__.py +0 -0
  128. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/utils/data/__init__.py +0 -0
  129. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/utils/data/dataloader.py +0 -0
  130. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile/utils/data/dataset.py +0 -0
  131. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile.egg-info/dependency_links.txt +0 -0
  132. {vectorphile-0.1.0 → vectorphile-0.3.0}/vectorphile.egg-info/top_level.txt +0 -0
@@ -0,0 +1,554 @@
1
+ Metadata-Version: 2.4
2
+ Name: vectorphile
3
+ Version: 0.3.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: cuda
23
+ Requires-Dist: cupy-cuda12x>=12.0.0; extra == "cuda"
24
+ Provides-Extra: numba
25
+ Requires-Dist: numba>=0.57.0; extra == "numba"
26
+ Provides-Extra: triton
27
+ Requires-Dist: triton>=2.1.0; extra == "triton"
28
+ Provides-Extra: rl
29
+ Requires-Dist: gymnasium>=0.29.0; extra == "rl"
30
+ Provides-Extra: tokenizers
31
+ Requires-Dist: tokenizers>=0.15.0; extra == "tokenizers"
32
+ Provides-Extra: onnx
33
+ Requires-Dist: onnx>=1.14.0; extra == "onnx"
34
+ Requires-Dist: onnxruntime>=1.16.0; extra == "onnx"
35
+ Provides-Extra: coreml
36
+ Requires-Dist: coremltools>=7.0; extra == "coreml"
37
+ Provides-Extra: pretrained
38
+ Requires-Dist: huggingface-hub>=0.20.0; extra == "pretrained"
39
+ Requires-Dist: safetensors>=0.4.0; extra == "pretrained"
40
+ Provides-Extra: full
41
+ Requires-Dist: scipy>=1.10.0; extra == "full"
42
+ Requires-Dist: pyarrow>=12.0.0; extra == "full"
43
+ Requires-Dist: h5py>=3.8.0; extra == "full"
44
+ Requires-Dist: netCDF4>=1.6.0; extra == "full"
45
+ Requires-Dist: matplotlib>=3.7.0; extra == "full"
46
+ Requires-Dist: numba>=0.57.0; extra == "full"
47
+ Requires-Dist: triton>=2.1.0; extra == "full"
48
+ Requires-Dist: gymnasium>=0.29.0; extra == "full"
49
+ Requires-Dist: onnx>=1.14.0; extra == "full"
50
+ Requires-Dist: onnxruntime>=1.16.0; extra == "full"
51
+ Requires-Dist: huggingface-hub>=0.20.0; extra == "full"
52
+ Requires-Dist: safetensors>=0.4.0; extra == "full"
53
+ Provides-Extra: dev
54
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
55
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
56
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
57
+ Dynamic: author
58
+ Dynamic: home-page
59
+ Dynamic: license-file
60
+ Dynamic: requires-python
61
+
62
+ # vectorphile
63
+
64
+ > **A unified, research-first computational intelligence library for Python.**
65
+ > 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.
66
+
67
+ ```python
68
+ import vectorphile as vp
69
+ ```
70
+
71
+ ---
72
+
73
+ ## Philosophy
74
+
75
+ 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.
76
+
77
+ **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.
78
+
79
+ 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.
80
+
81
+ ---
82
+
83
+ ## Core Design Principles
84
+
85
+ - **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.
86
+ - **Autodiff-native** — The autograd engine is not bolted on. Every tensor operation is differentiable by default. Gradient flow is explicit, inspectable, and composable.
87
+ - **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.
88
+ - **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.
89
+ - **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.
90
+
91
+ ---
92
+
93
+ ## Module Map
94
+
95
+ | Module | What you get |
96
+ |---|---|
97
+ | `vp` (core) | `Tensor` class, all ndarray ops, broadcasting, slicing, reshaping, type casting, autograd |
98
+ | `vp.nn` | Linear, Conv, Pooling, RNN/LSTM/GRU, Attention, Transformer, Norm, activations, losses, `Sequential`, `ModuleList`, `ModuleDict` |
99
+ | `vp.nn.F` | Full functional API: activations, conv, pool, norm, dropout, embedding, one_hot, all losses, pad, interpolate |
100
+ | `vp.nn.init` | xavier_uniform/normal, kaiming_uniform/normal, orthogonal, sparse, trunc_normal, dirac |
101
+ | `vp.optim` | SGD, Adam, AdamW, RMSprop, Adagrad, LR schedulers |
102
+ | `vp.autograd` | Reverse-mode autodiff engine, computation graph, `no_grad` context |
103
+ | `vp.transforms` | JAX-inspired `grad`, `vmap`, `jit`, `pmap`, `checkpoint`, `jacobian`, `hessian`, `jvp`, `vjp`, `eval_shape` |
104
+ | `vp.ml` | Linear, trees, forests, XGB, LGBM, CatBoost, clustering, PCA/ICA/NMF, KNN, SVM, Naive Bayes, pipelines |
105
+ | `vp.ml.anomaly` | IsolationForest, LocalOutlierFactor, EllipticEnvelope, OneClassSVM |
106
+ | `vp.ml.manifold` | TSNE (Barnes-Hut), UMAP, MDS, Isomap, LLE, SpectralEmbedding |
107
+ | `vp.ml.feature_selection` | VarianceThreshold, SelectKBest, RFE, RFECV, SelectFromModel, chi2, mutual_info |
108
+ | `vp.ml.pipeline` | Pipeline, ColumnTransformer, FeatureUnion, make_pipeline |
109
+ | `vp.data` | `DataFrame`, `Series`, `read_csv`, `read_json`, GroupBy, merge, pivot, melt |
110
+ | `vp.linalg` | det, inv, svd, eig, lstsq, solve, norm, qr, cholesky, pinv |
111
+ | `vp.stats` | mean, std, corr, cov, zscore, t-test, chi2, ANOVA, Pearson/Spearman |
112
+ | `vp.random` | seed, rand, randn, choice, normal, binomial, multinomial |
113
+ | `vp.fft` | fft, ifft, rfft, fft2, fftshift |
114
+ | `vp.signal` | stft, convolve, correlate, butter, filtfilt, spectrogram |
115
+ | `vp.sparse` | csr_matrix, csc_matrix, coo_matrix |
116
+ | `vp.optimize` | minimize, root, curve_fit, differential_evolution |
117
+ | `vp.integrate` | quad, dblquad, nquad, solve_ivp, odeint, trapezoid, simpson, romberg |
118
+ | `vp.interpolate` | interp1d, CubicSpline, BSpline, griddata, RBFInterpolator, RegularGridInterpolator |
119
+ | `vp.spatial` | KDTree, cKDTree, ConvexHull, Delaunay, Voronoi, cdist, pdist |
120
+ | `vp.ndimage` | gaussian_filter, sobel, label, zoom, rotate, morphological ops, distance transforms |
121
+ | `vp.polynomial` | Polynomial, Chebyshev, Legendre, Laguerre, Hermite + Horner eval, Lagrange interpolation, Sturm |
122
+ | `vp.ma` | Full masked array support — MaskedArray, masked_where, masked_invalid, all statistics |
123
+ | `vp.io` | MAT, WAV, Parquet, Feather, HDF5, NetCDF4, Matrix Market, NumPy native |
124
+ | `vp.viz` | plot, scatter, bar, histogram, heatmap, boxplot, violin, pairplot, ROC, confusion matrix, training history |
125
+ | `vp.hub` | save_model, load_model, Checkpointer, model_card |
126
+ | `vp.quantization` | quantize (INT8/INT4/FP16), QuantizedModel, MinMaxCalibrator, magnitude_prune |
127
+ | `vp.amp` | autocast, GradScaler (Phase 2: real CUDA fp16/bf16) |
128
+ | `vp.utils.data` | `Dataset`, `TensorDataset`, `DataLoader` with batching and shuffling |
129
+ | `vp.backend` | 5-tier dispatch: Triton JIT → PyTorch CUDA → Numba CUDA → im2col+BLAS → NumPy |
130
+ | `vp.tokenizers` | BPE, WordPiece, SentencePiece, CharacterTokenizer — zero external deps |
131
+ | `vp.distributed` | DataParallel, DDP, GradientAccumulator, MixedPrecisionTrainer |
132
+ | `vp.export` | ONNX, TorchScript, CoreML, SavedModel, GGUF (Q4_0/Q8_0), benchmark |
133
+ | `vp.rl` | DQN/DoubleDQN/DuelingDQN, REINFORCE, A2C, PPO, SAC, TD3, PER, environments |
134
+ | `vp.pretrained` | HuggingFace Hub download, safetensors parser, weight mappers for GPT-2/BERT/ViT/LLaMA |
135
+ | `vp.metrics` | 25+ metrics: accuracy, BLEU, ROUGE-L, WER, NDCG, ECE, silhouette, ARI, NMI |
136
+ | `vp.callbacks` | EarlyStopping, ModelCheckpoint, ReduceLROnPlateau, TensorBoardLogger, WandBLogger, LRFinder |
137
+ | `vp.trainer` | PyTorch Lightning-style `Trainer` + `TrainableModel` base class |
138
+ | `vp.text` | beam_search, nucleus_sampling, contrastive_search, speculative_decoding, chat templates, `TextGenerationPipeline` |
139
+ | `vp.vision` | Compose, Resize, RandomCrop, ColorJitter, AugMix, ToTensor, Normalize, make_grid, extract_features |
140
+ | `vp.data.datasets` | MNIST, CIFAR-10, TinyShakespeare, IMDb + DataLoader, samplers, random_split |
141
+ | `vp.nn.lr_schedulers` | StepLR, CosineAnnealingLR, OneCycleLR, WarmupCosineDecay, PolynomialLR, get_scheduler |
142
+ | `vp.nn.einops` | rearrange, reduce, repeat, pack, unpack, EinMix |
143
+ | `vp.nn.hooks` | register_forward_hook, register_backward_hook, FeatureExtractor, GradientRecorder |
144
+ | `vp.autograd` | Reverse-mode + second-order autodiff, `jacobian`, `hessian`, `vmap`, `checkpoint` |
145
+ | `vp.nn.flash_attention` | Flash Attention 2 (tiled, O(N) memory), variable-length sequences |
146
+ | `vp.nn.qat` | Quantization-aware training (straight-through estimator), prepare_qat / convert_qat |
147
+ | `vp.optim` (advanced) | Lion, Sophia, Adan, CAME, Prodigy, ScheduleFreeAdamW |
148
+ | `vp.nn.architectures` | CNN zoo (VGG/ResNet/DenseNet/EfficientNet), ViT/DeiT, Mamba/S4, VAE/DDPM/DCGAN, U-Net, GCN/GAT/GIN |
149
+
150
+ ---
151
+
152
+ ## Installation
153
+
154
+ ```bash
155
+ pip install vectorphile
156
+ ```
157
+
158
+ **With optional dependencies:**
159
+
160
+ ```bash
161
+ pip install "vectorphile[full]" # scipy, pyarrow, h5py, netCDF4, matplotlib
162
+ pip install "vectorphile[viz]" # matplotlib only
163
+ pip install "vectorphile[io]" # pyarrow, h5py, netCDF4
164
+ pip install "vectorphile[dev]" # pytest, pytest-cov, ruff
165
+ ```
166
+
167
+ **From source:**
168
+
169
+ ```bash
170
+ git clone https://github.com/vectorphile/vectorphile
171
+ cd vectorphile
172
+ pip install -e ".[dev]"
173
+ ```
174
+
175
+ **Requirements:** Python >= 3.9, NumPy >= 1.24, SciPy >= 1.10
176
+
177
+ ---
178
+
179
+ ## Usage
180
+
181
+ ### Tensors
182
+
183
+ The `Tensor` is the central primitive. All operations — arithmetic, reduction, reshaping, broadcasting — are defined on it.
184
+
185
+ ```python
186
+ import vectorphile as vp
187
+
188
+ x = vp.randn(3, 4)
189
+ y = vp.ones(4, 5)
190
+ z = x @ y # matrix multiply → (3, 5)
191
+
192
+ t = vp.tensor([1.0, 2.0, 3.0], dtype='float32')
193
+ t2 = t.reshape(1, 3).T # (3, 1)
194
+
195
+ # Element-wise ops with broadcasting
196
+ a = vp.zeros(5, 1) + vp.randn(1, 8) # (5, 8)
197
+
198
+ # Reductions
199
+ print(x.sum(axis=1, keepdims=True))
200
+ print(x.mean(), x.std(), x.max())
201
+ ```
202
+
203
+ ### Automatic Differentiation
204
+
205
+ The autograd engine builds a dynamic computation graph during the forward pass. Gradients are computed via reverse-mode accumulation.
206
+
207
+ ```python
208
+ x = vp.tensor([2.0, 3.0], requires_grad=True)
209
+
210
+ # Any composition of tensor ops is differentiable
211
+ y = (x ** 2 + 3 * x - vp.log(x + 1)).sum()
212
+ y.backward()
213
+
214
+ print(x.grad) # analytical: [2x + 3 - 1/(x+1)] evaluated at [2, 3]
215
+
216
+ # Disable gradient tracking for inference
217
+ with vp.no_grad():
218
+ pred = model(X_test)
219
+ ```
220
+
221
+ ### Neural Networks
222
+
223
+ `vp.nn` provides composable layer primitives. Each layer is a differentiable function mapping tensors to tensors.
224
+
225
+ ```python
226
+ model = vp.nn.Sequential(
227
+ vp.nn.Linear(784, 512),
228
+ vp.nn.BatchNorm1d(512),
229
+ vp.nn.GELU(),
230
+ vp.nn.Dropout(p=0.3),
231
+ vp.nn.Linear(512, 256),
232
+ vp.nn.LayerNorm(256),
233
+ vp.nn.ReLU(),
234
+ vp.nn.Linear(256, 10),
235
+ )
236
+
237
+ criterion = vp.nn.CrossEntropyLoss()
238
+ optimizer = vp.optim.AdamW(model.parameters(), lr=1e-3, weight_decay=1e-4)
239
+ scheduler = vp.optim.CosineAnnealingLR(optimizer, T_max=100)
240
+
241
+ for epoch in range(100):
242
+ optimizer.zero_grad()
243
+ logits = model(X_train)
244
+ loss = criterion(logits, y_train)
245
+ loss.backward()
246
+ optimizer.step()
247
+ scheduler.step()
248
+ ```
249
+
250
+ **Available layers:**
251
+ - Linear, Embedding
252
+ - Conv1d, Conv2d (Phase 2: direct CUDA kernels)
253
+ - BatchNorm1d, BatchNorm2d, LayerNorm, GroupNorm
254
+ - ReLU, GELU, SiLU, Tanh, Sigmoid, Softmax, LogSoftmax
255
+ - Dropout, Dropout2d
256
+ - MultiheadAttention (Phase 2)
257
+
258
+ **Available losses:**
259
+ - CrossEntropyLoss, NLLLoss, BCELoss, BCEWithLogitsLoss
260
+ - MSELoss, L1Loss, HuberLoss, SmoothL1Loss
261
+ - KLDivLoss, CosineEmbeddingLoss, TripletMarginLoss
262
+
263
+ ### Optimizers
264
+
265
+ ```python
266
+ # First-order
267
+ vp.optim.SGD(params, lr=0.01, momentum=0.9, nesterov=True)
268
+ vp.optim.Adam(params, lr=1e-3, betas=(0.9, 0.999))
269
+ vp.optim.AdamW(params, lr=1e-3, weight_decay=1e-2)
270
+ vp.optim.RMSprop(params, lr=1e-3, alpha=0.99)
271
+ vp.optim.Adagrad(params, lr=1e-2)
272
+
273
+ # LR Schedulers
274
+ vp.optim.StepLR(optimizer, step_size=30, gamma=0.1)
275
+ vp.optim.CosineAnnealingLR(optimizer, T_max=100)
276
+ vp.optim.ReduceLROnPlateau(optimizer, patience=10)
277
+ vp.optim.OneCycleLR(optimizer, max_lr=0.01, total_steps=1000)
278
+ ```
279
+
280
+ ### Classical Learning Algorithms
281
+
282
+ ```python
283
+ from vectorphile import ml
284
+
285
+ # Data splitting
286
+ X_train, X_test, y_train, y_test = ml.train_test_split(X, y, test_size=0.2, random_state=42)
287
+
288
+ # Preprocessing
289
+ scaler = ml.StandardScaler()
290
+ X_train = scaler.fit_transform(X_train)
291
+ X_test = scaler.transform(X_test)
292
+
293
+ # Ensemble methods
294
+ clf = ml.RandomForestClassifier(n_estimators=200, max_depth=None, min_samples_split=2)
295
+ clf.fit(X_train, y_train)
296
+
297
+ # Gradient boosting
298
+ from vectorphile.ml.boost import XGBClassifier
299
+ bst = XGBClassifier(n_estimators=300, learning_rate=0.05, max_depth=6, reg_lambda=1.0)
300
+ bst.fit(X_train, y_train)
301
+
302
+ # Dimensionality reduction
303
+ pca = ml.PCA(n_components=50)
304
+ X_reduced = pca.fit_transform(X)
305
+
306
+ # Clustering
307
+ kmeans = ml.KMeans(n_clusters=8, init='k-means++', max_iter=300)
308
+ labels = kmeans.fit_predict(X)
309
+
310
+ # Evaluation
311
+ print(ml.accuracy_score(y_test, clf.predict(X_test)))
312
+ print(ml.classification_report(y_test, clf.predict(X_test)))
313
+ print(ml.roc_auc_score(y_test, clf.predict_proba(X_test)[:, 1]))
314
+
315
+ # Cross-validation
316
+ scores = ml.cross_val_score(clf, X, y, cv=5, scoring='f1_weighted')
317
+ ```
318
+
319
+ **Full algorithm coverage:**
320
+
321
+ | Category | Algorithms |
322
+ |---|---|
323
+ | Linear Models | LinearRegression, Ridge, Lasso, ElasticNet, LogisticRegression, SGDClassifier, Perceptron |
324
+ | Trees | DecisionTreeClassifier, DecisionTreeRegressor |
325
+ | Ensembles | RandomForestClassifier, RandomForestRegressor, ExtraTreesClassifier, GradientBoostingClassifier, BaggingClassifier, VotingClassifier, StackingClassifier |
326
+ | Boosting | XGBClassifier, XGBRegressor (histogram-based, regularized) |
327
+ | Neighbors | KNeighborsClassifier, KNeighborsRegressor |
328
+ | Support Vector | SVC, SVR, LinearSVC |
329
+ | Naive Bayes | GaussianNB, MultinomialNB, BernoulliNB |
330
+ | Clustering | KMeans, DBSCAN, AgglomerativeClustering, MeanShift, SpectralClustering |
331
+ | Decomposition | PCA, TruncatedSVD, NMF, FastICA, FactorAnalysis |
332
+ | Preprocessing | StandardScaler, MinMaxScaler, RobustScaler, LabelEncoder, OneHotEncoder, PolynomialFeatures |
333
+ | Model Selection | cross_val_score, GridSearchCV, RandomizedSearchCV, StratifiedKFold |
334
+ | Metrics | accuracy, precision, recall, f1, roc_auc, log_loss, r2, MAE, MSE, confusion_matrix |
335
+
336
+ ### DataFrames
337
+
338
+ ```python
339
+ df = vp.read_csv('dataset.csv')
340
+
341
+ # Filtering and mutation
342
+ high_value = df[df['revenue'] > 1e6]
343
+ df['margin'] = (df['revenue'] - df['cost']) / df['revenue']
344
+
345
+ # GroupBy aggregation
346
+ monthly = df.groupby(['year', 'month']).agg({'revenue': 'sum', 'units': 'mean'})
347
+
348
+ # Merge / join
349
+ result = df.merge(metadata, on='product_id', how='left')
350
+
351
+ # Reshape
352
+ wide = df.pivot(index='date', columns='region', values='sales')
353
+ long = wide.melt(id_vars=['date'], var_name='region', value_name='sales')
354
+
355
+ # Descriptive statistics
356
+ df[['revenue', 'cost', 'margin']].describe()
357
+ df[['revenue', 'margin']].corr()
358
+
359
+ # I/O
360
+ df.to_csv('output.csv', index=False)
361
+ df.to_json('output.json', orient='records')
362
+ ```
363
+
364
+ ### Linear Algebra
365
+
366
+ ```python
367
+ A = vp.randn(100, 100)
368
+
369
+ U, S, Vt = vp.linalg.svd(A) # singular value decomposition
370
+ eigenvalues, eigenvectors = vp.linalg.eig(A)
371
+ L = vp.linalg.cholesky(A.T @ A) # Cholesky factorization
372
+ Q, R = vp.linalg.qr(A) # QR decomposition
373
+
374
+ x = vp.linalg.solve(A, b) # solve Ax = b
375
+ x_lstsq = vp.linalg.lstsq(A, b) # least-squares solution
376
+
377
+ print(vp.linalg.det(A))
378
+ print(vp.linalg.norm(A, ord='fro')) # Frobenius norm
379
+ print(vp.linalg.cond(A)) # condition number
380
+ ```
381
+
382
+ ### Statistical Inference
383
+
384
+ ```python
385
+ from vectorphile import stats
386
+
387
+ # Descriptive
388
+ print(stats.mean(x), stats.std(x), stats.skewness(x), stats.kurtosis(x))
389
+
390
+ # Correlation
391
+ r_pearson, p = stats.pearsonr(x, y)
392
+ r_spearman, p = stats.spearmanr(x, y)
393
+ cov_matrix = stats.cov(X)
394
+
395
+ # Hypothesis testing
396
+ t_stat, p_val = stats.ttest_ind(group_a, group_b)
397
+ chi2_stat, p_val = stats.chi2_contingency(contingency_table)
398
+ f_stat, p_val = stats.f_oneway(g1, g2, g3)
399
+
400
+ # Normalization
401
+ z = stats.zscore(x)
402
+ ```
403
+
404
+ ### Signal Processing
405
+
406
+ ```python
407
+ from vectorphile import fft, signal
408
+
409
+ # FFT
410
+ spectrum = fft.fft(x)
411
+ freqs = fft.fftfreq(len(x), d=1/sample_rate)
412
+ X2d = fft.fft2(image)
413
+
414
+ # Filtering
415
+ b, a = signal.butter(order=4, cutoff=0.1, btype='low')
416
+ filtered = signal.filtfilt(b, a, noisy_signal)
417
+
418
+ # Time-frequency
419
+ f, t, Zxx = signal.stft(x, fs=sample_rate, nperseg=256)
420
+ f, t, Sxx = signal.spectrogram(x, fs=sample_rate)
421
+
422
+ # Convolution
423
+ out = signal.convolve(signal_a, kernel, mode='same')
424
+ ```
425
+
426
+ ### DataLoader Pipeline
427
+
428
+ ```python
429
+ from vectorphile.utils.data import TensorDataset, DataLoader
430
+
431
+ dataset = TensorDataset(X_train, y_train)
432
+ loader = DataLoader(dataset, batch_size=64, shuffle=True, drop_last=False)
433
+
434
+ for X_batch, y_batch in loader:
435
+ logits = model(X_batch)
436
+ loss = criterion(logits, y_batch)
437
+ loss.backward()
438
+ optimizer.step()
439
+ optimizer.zero_grad()
440
+ ```
441
+
442
+ ---
443
+
444
+ ## Architecture
445
+
446
+ ```
447
+ vectorphile/
448
+ ├── __init__.py ← top-level API surface
449
+ ├── core/
450
+ │ ├── tensor.py ← Tensor class, __array_ufunc__, operator overloads
451
+ │ └── ops.py ← all primitive tensor operations
452
+ ├── autograd/
453
+ │ ├── engine.py ← reverse-mode autodiff, Node, Graph
454
+ │ └── functional.py ← differentiable functional ops
455
+ ├── nn/
456
+ │ ├── module.py ← base Module, parameter registration
457
+ │ ├── layers.py ← Linear, Conv, Norm, Dropout, Embedding
458
+ │ ├── activations.py ← ReLU, GELU, SiLU, Softmax, etc.
459
+ │ ├── losses.py ← all loss functions
460
+ │ └── sequential.py ← Sequential container
461
+ ├── optim/
462
+ │ ├── base.py ← Optimizer base class
463
+ │ ├── first_order.py ← SGD, Adam, AdamW, RMSprop, Adagrad
464
+ │ └── schedulers.py ← StepLR, CosineAnnealing, OneCycle, Plateau
465
+ ├── ml/
466
+ │ ├── linear.py ← LinearRegression, Ridge, Lasso, Logistic
467
+ │ ├── tree.py ← DecisionTree (CART)
468
+ │ ├── ensemble.py ← RandomForest, ExtraTrees, GradientBoosting
469
+ │ ├── boost/ ← XGBClassifier, XGBRegressor
470
+ │ ├── cluster.py ← KMeans, DBSCAN, Agglomerative
471
+ │ ├── decompose.py ← PCA, SVD, NMF, ICA
472
+ │ ├── neighbors.py ← KNN
473
+ │ ├── svm.py ← SVC, SVR
474
+ │ ├── naive_bayes.py ← GaussianNB, MultinomialNB
475
+ │ ├── preprocess.py ← scalers, encoders
476
+ │ ├── metrics.py ← all evaluation metrics
477
+ │ └── model_select.py ← CV, GridSearch, RandomSearch
478
+ ├── data/
479
+ │ ├── frame.py ← DataFrame
480
+ │ ├── series.py ← Series
481
+ │ ├── groupby.py ← GroupBy engine
482
+ │ └── io.py ← read_csv, read_json, to_csv, to_json
483
+ ├── linalg/ ← thin wrappers over LAPACK routines via NumPy
484
+ ├── stats/ ← descriptive + inferential statistics
485
+ ├── random/ ← seeded RNG, all distributions
486
+ ├── fft/ ← FFT via NumPy backend, Phase 2: cuFFT
487
+ ├── signal/ ← DSP algorithms
488
+ ├── sparse/ ← CSR, CSC, COO sparse formats
489
+ ├── optimize/ ← minimizers, root finders, curve fitting
490
+ ├── amp/ ← mixed-precision context (Phase 2)
491
+ └── utils/
492
+ └── data/ ← Dataset, TensorDataset, DataLoader
493
+ ```
494
+
495
+ ---
496
+
497
+ ## Roadmap
498
+
499
+ ### v0.1–0.2 — Core (complete)
500
+ - Full tensor API with reverse-mode autodiff
501
+ - Complete neural network layer set (Linear, Conv, RNN, Transformer, Norm)
502
+ - All classical ML algorithms (trees, forests, XGBoost, clustering, PCA)
503
+ - DataFrame, GroupBy, merge/pivot
504
+ - Linear algebra, statistics, FFT, signal, sparse, optimization
505
+
506
+ ### v0.3.0 — Production completeness (complete)
507
+ - 5-tier CUDA backend dispatcher (Triton → PyTorch → Numba → im2col → NumPy)
508
+ - BPE / WordPiece / SentencePiece tokenizers from scratch
509
+ - Distributed training: DataParallel, DDP, MixedPrecision
510
+ - Model export: ONNX, TorchScript, CoreML
511
+ - Reinforcement learning: DQN, PPO, SAC, TD3
512
+ - Pretrained weights hub (HuggingFace download, safetensors parser)
513
+ - Architecture zoo: CNN/ResNet/EfficientNet, ViT/DeiT, Mamba/S4, VAE/DDPM, U-Net, GCN/GAT/GIN
514
+ - Flash Attention, QAT, advanced optimizers (Lion, Sophia, Adan, Prodigy)
515
+
516
+ ### v0.4.0 — Ecosystem parity (complete)
517
+ - GGUF binary format reader/writer (Q4_0, Q8_0 quantization)
518
+ - 25+ evaluation metrics (BLEU, ROUGE, WER, ECE, NDCG, silhouette)
519
+ - 10 training callbacks (EarlyStopping, TensorBoardLogger, WandBLogger, LRFinder)
520
+ - Keras/Lightning-style `Trainer` + `TrainableModel` base class
521
+ - 11 LR schedulers (`get_scheduler` factory, WarmupCosineDecay, OneCycleLR)
522
+ - einops-compatible `rearrange`/`reduce`/`repeat`/`pack`/`unpack`/`EinMix`
523
+ - Forward/backward hooks, `FeatureExtractor`, `GradientRecorder`
524
+ - Text generation: beam search, nucleus, contrastive, speculative decoding, chat templates
525
+ - Vision transforms: Compose/Resize/ColorJitter/AugMix/Normalize + ImageNet defaults
526
+ - Datasets: MNIST, CIFAR-10, TinyShakespeare, IMDb + DataLoader/samplers
527
+
528
+ ### v0.5.0 — Planned
529
+ - Real CUDA C extensions (cuBLAS GEMM, cuDNN conv)
530
+ - fp16 / bf16 automatic mixed precision on GPU
531
+ - Triton fused kernels in production paths
532
+ - Multi-node distributed via NCCL
533
+
534
+ ---
535
+
536
+ ## Running Tests
537
+
538
+ ```bash
539
+ pytest tests/ -v
540
+ ```
541
+
542
+ The test suite covers tensor operations, autograd correctness (checked against analytical gradients), all ML algorithm outputs, DataFrame operations, and numerical routines.
543
+
544
+ ---
545
+
546
+ ## Contributing
547
+
548
+ This library is in active research development. Issues, proposals, and pull requests are welcome at [github.com/vectorphile/vectorphile](https://github.com/vectorphile/vectorphile).
549
+
550
+ ---
551
+
552
+ ## License
553
+
554
+ Apache-2.0