scm2cpp-learn 0.20.0__tar.gz → 0.22.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 (77) hide show
  1. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/PKG-INFO +41 -2
  2. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/README.md +40 -1
  3. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/pyproject.toml +1 -1
  4. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/setup.py +29 -0
  5. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/__init__.py +418 -62
  6. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_compat.py +8 -6
  7. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader.py +6 -6
  8. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_accel_cublas.py +36 -36
  9. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_classifiers.py +52 -52
  10. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_derived_blas.py +2 -2
  11. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_derived_cublas.py +2 -2
  12. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_derived_loops.py +2 -2
  13. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_gpu_cuda.py +41 -41
  14. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_gramops_blas.py +159 -159
  15. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_gramops_loops.py +163 -163
  16. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_nmf_blas.py +3 -3
  17. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_nmf_cublas.py +3 -3
  18. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/_loader_nmf_loops.py +3 -3
  19. scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/accel_cublas/accel.hpp +1250 -0
  20. scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/accel_cublas/accel_capi.cpp +82 -0
  21. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/classifiers.hpp +768 -768
  22. scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/classifiers_capi.cpp +115 -0
  23. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/derived_blas/lasso_design.hpp +38 -38
  24. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/derived_blas/lasso_design_capi.cpp +1 -1
  25. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/derived_cublas/lasso_design.hpp +39 -39
  26. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/derived_cublas/lasso_design_capi.cpp +1 -1
  27. scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/derived_loops/lasso_design.hpp +179 -0
  28. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/derived_loops/lasso_design_capi.cpp +1 -1
  29. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/gpu_cuda/gpu.hpp +675 -675
  30. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/gpu_cuda/gpu_capi.cpp +44 -44
  31. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/gramops_blas/gramops.hpp +1799 -1799
  32. scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/gramops_blas/gramops_capi.cpp +295 -0
  33. scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/gramops_loops/gramops.hpp +7711 -0
  34. scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/gramops_loops/gramops_capi.cpp +301 -0
  35. scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/lasso_cov.hpp +152 -0
  36. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/lasso_cov_capi.cpp +3 -3
  37. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/nmf_blas/nmf_cd.hpp +39 -39
  38. {scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/nmf_cublas → scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/nmf_blas}/nmf_cd_capi.cpp +2 -2
  39. scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/nmf_cublas/nmf_cd.hpp +136 -0
  40. {scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/nmf_loops → scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/nmf_cublas}/nmf_cd_capi.cpp +2 -2
  41. scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/nmf_loops/nmf_cd.hpp +167 -0
  42. {scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/nmf_blas → scm2cpp_learn-0.22.0/src/scm2cpp_learn/_generated/nmf_loops}/nmf_cd_capi.cpp +2 -2
  43. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/scm2cpp.hpp +15 -1
  44. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/batch_capi.cu +7 -4
  45. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn.egg-info/PKG-INFO +41 -2
  46. scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/accel_cublas/accel.hpp +0 -1250
  47. scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/accel_cublas/accel_capi.cpp +0 -82
  48. scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/classifiers_capi.cpp +0 -115
  49. scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/derived_loops/lasso_design.hpp +0 -179
  50. scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/gramops_blas/gramops_capi.cpp +0 -295
  51. scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/gramops_loops/gramops.hpp +0 -7711
  52. scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/gramops_loops/gramops_capi.cpp +0 -301
  53. scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/lasso_cov.hpp +0 -152
  54. scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/nmf_cublas/nmf_cd.hpp +0 -136
  55. scm2cpp_learn-0.20.0/src/scm2cpp_learn/_generated/nmf_loops/nmf_cd.hpp +0 -167
  56. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/setup.cfg +0 -0
  57. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/__init__.py +0 -0
  58. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/accel_cublas/accel.cpp +0 -0
  59. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/classifiers.cpp +0 -0
  60. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/derived_blas/lasso_design.cpp +0 -0
  61. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/derived_cublas/lasso_design.cpp +0 -0
  62. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/derived_loops/lasso_design.cpp +0 -0
  63. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/gpu_cuda/gpu.cpp +0 -0
  64. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/gramops_blas/gramops.cpp +0 -0
  65. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/gramops_loops/gramops.cpp +0 -0
  66. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/lasso_cov.cpp +0 -0
  67. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/nmf_blas/nmf_cd.cpp +0 -0
  68. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/nmf_cublas/nmf_cd.cpp +0 -0
  69. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/nmf_loops/nmf_cd.cpp +0 -0
  70. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/scm2cpp-blas.hpp +0 -0
  71. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/scm2cpp-cublas.hpp +0 -0
  72. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_generated/scm2cpp-cuda.hpp +0 -0
  73. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn/_libfind.py +0 -0
  74. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn.egg-info/SOURCES.txt +0 -0
  75. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn.egg-info/dependency_links.txt +0 -0
  76. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn.egg-info/requires.txt +0 -0
  77. {scm2cpp_learn-0.20.0 → scm2cpp_learn-0.22.0}/src/scm2cpp_learn.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scm2cpp-learn
3
- Version: 0.20.0
3
+ Version: 0.22.0
4
4
  Summary: scikit-learn estimators (lasso, elastic net, ridge, RidgeCV, ARD, SVM, SVR, logistic regression, GLMs, Huber, Theil-Sen, F-score selection, RFE, NMF, Gaussian mixture, FastICA, PCA, KernelPCA, LDA, TruncatedSVD, PLS, CCA, graphical lasso, RANSAC, SGD, OMP, LARS) translated from Scheme to C++ by scm2cpp; GPU batch solver and CUDA kernels included
5
5
  Author: Hirotaka Niitsuma
6
6
  License: MIT
@@ -37,7 +37,7 @@ with a DeprecationWarning.
37
37
  $ pip install scm2cpp-learn
38
38
  ```
39
39
 
40
- On Linux x86_64, macOS arm64 (macOS 14 or later) and Windows AMD64
40
+ On Linux x86_64, macOS arm64 (macOS 15 or later) and Windows AMD64
41
41
  this installs a wheel: compiled, nothing to build (with OpenBLAS
42
42
  inside on Linux and macOS; Windows has the loop variants). Elsewhere pip builds the sdist,
43
43
  which needs a C++17 compiler and nothing else. The wheels carry no
@@ -456,6 +456,45 @@ the pick is exact at n=5,000 and one grid step apart on a near-tie
456
456
  elsewhere (mean-MSE relative gap at most 2.6e-4), and sklearn at
457
457
  tol=1e-10 picks our alpha at every size.
458
458
 
459
+ `cv` may also be a splitter (`TimeSeriesSplit`, a shuffled `KFold`, ...)
460
+ or a list of (train, test) index pairs, and `fit_intercept=True` centres
461
+ each fold's training rows as `LassoCV` does (through the Gram, not a
462
+ centred copy); the default stays the fit through the origin. A
463
+ `TimeSeriesSplit` fold's training rows are a prefix, so its Gram is the
464
+ previous fold's plus the new rows' -- the five folds cost one pass over
465
+ the training rows, not five. Against `LassoCV` on the same grid the
466
+ validation errors agree to 1e-11 and the coefficients and intercept
467
+ to 1e-11.
468
+
469
+ `solver="lars"` (lasso only) solves each fold and the refit by the
470
+ translated least angle regression over the same Gram
471
+ (`examples/kernel-only/lars.scm`, method "lasso") and reads the
472
+ solutions at the grid off the recorded path, which is piecewise linear
473
+ in alpha: exact up to rounding, with no tolerance, and with a cost set
474
+ by the number of path steps rather than by conditioning. Columns equal
475
+ up to a factor are cut to the longest one first (two equal columns tie
476
+ in the path; scikit-learn's `lars_path` stops early there), and a grid
477
+ point whose solution misses the optimality conditions (1e-5 relative)
478
+ is finished by coordinate descent (`n_polished_`). Where the columns
479
+ are strongly correlated -- moving averages over overlapping windows --
480
+ coordinate descent needs thousands of sweeps and LARS is far faster: on
481
+ a stock-feature design with n=743 and p=180, 0.21 s against 145 s for
482
+ the descent on the same grid; at p=3495, 2.2 s, where the descent was
483
+ stopped after 30 minutes. The default stays `solver="cd"`.
484
+
485
+ `working_set=k` (with `solver="lars"`, a dense X) is for a design too
486
+ wide for its Gram matrix -- p by p, 309 GB at p = 196,574. Each fold
487
+ and the refit are solved on a working set of columns: the k most
488
+ correlated with y to begin with; then, while a column outside the set
489
+ breaks the optimality conditions at some grid point (the gradient
490
+ against alpha over all p columns, 1e-5 relative), the k worst of them
491
+ join and the set is solved again. When none does, every grid solution
492
+ solves the whole problem -- checked, not assumed -- so the fit is the
493
+ full Gram's (`check-wheel.py`: 3e-13 at p = 3000, n = 150, the set
494
+ staying well below p), in memory O(np) plus the set's Gram.
495
+ `working_set_` records the rounds and the final set's size for each
496
+ fold and the refit.
497
+
459
498
  The elastic net cross-validates the same way: `CovLassoCV(l1_ratio=0.5)`
460
499
  against `ElasticNetCV(l1_ratio=0.5)` on the same folds and alpha grid
461
500
  (`bench/lasso-compare.py --cv-only --l1-ratio 0.5`, same conditions,
@@ -19,7 +19,7 @@ with a DeprecationWarning.
19
19
  $ pip install scm2cpp-learn
20
20
  ```
21
21
 
22
- On Linux x86_64, macOS arm64 (macOS 14 or later) and Windows AMD64
22
+ On Linux x86_64, macOS arm64 (macOS 15 or later) and Windows AMD64
23
23
  this installs a wheel: compiled, nothing to build (with OpenBLAS
24
24
  inside on Linux and macOS; Windows has the loop variants). Elsewhere pip builds the sdist,
25
25
  which needs a C++17 compiler and nothing else. The wheels carry no
@@ -438,6 +438,45 @@ the pick is exact at n=5,000 and one grid step apart on a near-tie
438
438
  elsewhere (mean-MSE relative gap at most 2.6e-4), and sklearn at
439
439
  tol=1e-10 picks our alpha at every size.
440
440
 
441
+ `cv` may also be a splitter (`TimeSeriesSplit`, a shuffled `KFold`, ...)
442
+ or a list of (train, test) index pairs, and `fit_intercept=True` centres
443
+ each fold's training rows as `LassoCV` does (through the Gram, not a
444
+ centred copy); the default stays the fit through the origin. A
445
+ `TimeSeriesSplit` fold's training rows are a prefix, so its Gram is the
446
+ previous fold's plus the new rows' -- the five folds cost one pass over
447
+ the training rows, not five. Against `LassoCV` on the same grid the
448
+ validation errors agree to 1e-11 and the coefficients and intercept
449
+ to 1e-11.
450
+
451
+ `solver="lars"` (lasso only) solves each fold and the refit by the
452
+ translated least angle regression over the same Gram
453
+ (`examples/kernel-only/lars.scm`, method "lasso") and reads the
454
+ solutions at the grid off the recorded path, which is piecewise linear
455
+ in alpha: exact up to rounding, with no tolerance, and with a cost set
456
+ by the number of path steps rather than by conditioning. Columns equal
457
+ up to a factor are cut to the longest one first (two equal columns tie
458
+ in the path; scikit-learn's `lars_path` stops early there), and a grid
459
+ point whose solution misses the optimality conditions (1e-5 relative)
460
+ is finished by coordinate descent (`n_polished_`). Where the columns
461
+ are strongly correlated -- moving averages over overlapping windows --
462
+ coordinate descent needs thousands of sweeps and LARS is far faster: on
463
+ a stock-feature design with n=743 and p=180, 0.21 s against 145 s for
464
+ the descent on the same grid; at p=3495, 2.2 s, where the descent was
465
+ stopped after 30 minutes. The default stays `solver="cd"`.
466
+
467
+ `working_set=k` (with `solver="lars"`, a dense X) is for a design too
468
+ wide for its Gram matrix -- p by p, 309 GB at p = 196,574. Each fold
469
+ and the refit are solved on a working set of columns: the k most
470
+ correlated with y to begin with; then, while a column outside the set
471
+ breaks the optimality conditions at some grid point (the gradient
472
+ against alpha over all p columns, 1e-5 relative), the k worst of them
473
+ join and the set is solved again. When none does, every grid solution
474
+ solves the whole problem -- checked, not assumed -- so the fit is the
475
+ full Gram's (`check-wheel.py`: 3e-13 at p = 3000, n = 150, the set
476
+ staying well below p), in memory O(np) plus the set's Gram.
477
+ `working_set_` records the rounds and the final set's size for each
478
+ fold and the refit.
479
+
441
480
  The elastic net cross-validates the same way: `CovLassoCV(l1_ratio=0.5)`
442
481
  against `ElasticNetCV(l1_ratio=0.5)` on the same folds and alpha grid
443
482
  (`bench/lasso-compare.py --cv-only --l1-ratio 0.5`, same conditions,
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scm2cpp-learn"
7
- version = "0.20.0"
7
+ version = "0.22.0"
8
8
  description = "scikit-learn estimators (lasso, elastic net, ridge, RidgeCV, ARD, SVM, SVR, logistic regression, GLMs, Huber, Theil-Sen, F-score selection, RFE, NMF, Gaussian mixture, FastICA, PCA, KernelPCA, LDA, TruncatedSVD, PLS, CCA, graphical lasso, RANSAC, SGD, OMP, LARS) translated from Scheme to C++ by scm2cpp; GPU batch solver and CUDA kernels included"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -12,6 +12,7 @@ device, or a failed nvcc all leave a working CPU package behind, and
12
12
  the batch path notices at import and falls back.
13
13
  """
14
14
  import os
15
+ import platform
15
16
  import re
16
17
  import shutil
17
18
  import subprocess
@@ -33,6 +34,33 @@ GEN = PKG / "_generated"
33
34
  MSVC = ["/O2", "/std:c++17", "/EHsc", "/bigobj"]
34
35
  CXXFLAGS = ["-O2", "-std=c++17"] if os.name != "nt" else MSVC
35
36
 
37
+
38
+ def align_flags():
39
+ """-Wa,-mbranches-within-32B-boundaries where the assembler takes it.
40
+
41
+ Skylake-family x86 cores slow a jump that crosses or ends on a 32-byte
42
+ boundary (the JCC erratum microcode), so where a hot loop's branch
43
+ lands depends on unrelated code around it: the linear SVM's sweep
44
+ moved 10-20% between builds that differed only elsewhere. The GNU
45
+ assembler pads such branches away. Other assemblers and other
46
+ machines get nothing.
47
+ """
48
+ if os.name == "nt" or platform.machine().lower() not in ("x86_64", "amd64"):
49
+ return []
50
+ cxx = os.environ.get("CXX", "c++")
51
+ flag = "-Wa,-mbranches-within-32B-boundaries"
52
+ try:
53
+ r = subprocess.run([cxx, flag, "-x", "c++", "-c", "-", "-o", os.devnull],
54
+ input="int f(int n){int s=0;for(int i=0;i<n;i++)s+=i;return s;}\n",
55
+ capture_output=True, text=True)
56
+ except OSError:
57
+ return []
58
+ return [flag] if r.returncode == 0 else []
59
+
60
+
61
+ _align = align_flags()
62
+ CXXFLAGS = CXXFLAGS + _align
63
+
36
64
  kernel = Extension(
37
65
  "scm2cpp_learn._lasso_cov",
38
66
  sources=[GEN_REL + "/lasso_cov_capi.cpp"],
@@ -252,6 +280,7 @@ def cuda_home():
252
280
  # the flat index i*p + j as an induction variable, and the linear SVM's
253
281
  # sweep runs 25% slower.
254
282
  _cls_flags = ["-O3", "-std=c++17", "-fstrict-overflow"] if os.name != "nt" else MSVC
283
+ _cls_flags = _cls_flags + _align
255
284
  classifiers = Extension(
256
285
  "scm2cpp_learn._classifiers",
257
286
  sources=[GEN_REL + "/classifiers_capi.cpp"],