scm2cpp-lasso 0.15.0__tar.gz → 0.15.1__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 (67) hide show
  1. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/PKG-INFO +11 -4
  2. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/README.md +10 -3
  3. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/pyproject.toml +1 -1
  4. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/__init__.py +10 -8
  5. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/derived_blas/lasso_design.hpp +17 -14
  6. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/derived_cublas/lasso_design.hpp +18 -15
  7. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/derived_loops/lasso_design.hpp +29 -26
  8. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso.egg-info/PKG-INFO +11 -4
  9. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/setup.cfg +0 -0
  10. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/setup.py +0 -0
  11. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_compat.py +0 -0
  12. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/__init__.py +0 -0
  13. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader.py +0 -0
  14. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_accel_cublas.py +0 -0
  15. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_classifiers.py +0 -0
  16. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_derived_blas.py +0 -0
  17. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_derived_cublas.py +0 -0
  18. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_derived_loops.py +0 -0
  19. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_gpu_cuda.py +0 -0
  20. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_gramops_blas.py +0 -0
  21. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_gramops_loops.py +0 -0
  22. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_nmf_blas.py +0 -0
  23. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_nmf_cublas.py +0 -0
  24. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/_loader_nmf_loops.py +0 -0
  25. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/accel_cublas/accel.cpp +0 -0
  26. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/accel_cublas/accel.hpp +0 -0
  27. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/accel_cublas/accel_capi.cpp +0 -0
  28. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/classifiers.cpp +0 -0
  29. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/classifiers.hpp +0 -0
  30. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/classifiers_capi.cpp +0 -0
  31. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/derived_blas/lasso_design.cpp +0 -0
  32. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/derived_blas/lasso_design_capi.cpp +0 -0
  33. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/derived_cublas/lasso_design.cpp +0 -0
  34. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/derived_cublas/lasso_design_capi.cpp +0 -0
  35. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/derived_loops/lasso_design.cpp +0 -0
  36. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/derived_loops/lasso_design_capi.cpp +0 -0
  37. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/gpu_cuda/gpu.cpp +0 -0
  38. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/gpu_cuda/gpu.hpp +0 -0
  39. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/gpu_cuda/gpu_capi.cpp +0 -0
  40. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/gramops_blas/gramops.cpp +0 -0
  41. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/gramops_blas/gramops.hpp +0 -0
  42. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/gramops_blas/gramops_capi.cpp +0 -0
  43. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/gramops_loops/gramops.cpp +0 -0
  44. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/gramops_loops/gramops.hpp +0 -0
  45. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/gramops_loops/gramops_capi.cpp +0 -0
  46. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/lasso_cov.cpp +0 -0
  47. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/lasso_cov.hpp +0 -0
  48. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/lasso_cov_capi.cpp +0 -0
  49. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/nmf_blas/nmf_cd.cpp +0 -0
  50. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/nmf_blas/nmf_cd.hpp +0 -0
  51. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/nmf_blas/nmf_cd_capi.cpp +0 -0
  52. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/nmf_cublas/nmf_cd.cpp +0 -0
  53. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/nmf_cublas/nmf_cd.hpp +0 -0
  54. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/nmf_cublas/nmf_cd_capi.cpp +0 -0
  55. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/nmf_loops/nmf_cd.cpp +0 -0
  56. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/nmf_loops/nmf_cd.hpp +0 -0
  57. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/nmf_loops/nmf_cd_capi.cpp +0 -0
  58. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/scm2cpp-blas.hpp +0 -0
  59. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/scm2cpp-cublas.hpp +0 -0
  60. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/scm2cpp-cuda.hpp +0 -0
  61. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_generated/scm2cpp.hpp +0 -0
  62. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/_libfind.py +0 -0
  63. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso/batch_capi.cu +0 -0
  64. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso.egg-info/SOURCES.txt +0 -0
  65. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso.egg-info/dependency_links.txt +0 -0
  66. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso.egg-info/requires.txt +0 -0
  67. {scm2cpp_lasso-0.15.0 → scm2cpp_lasso-0.15.1}/src/scm2cpp_lasso.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scm2cpp-lasso
3
- Version: 0.15.0
3
+ Version: 0.15.1
4
4
  Summary: scikit-learn estimators (lasso, elastic net, ridge, ARD, SVM, SVR, logistic regression, GLMs, Huber, Theil-Sen, F-score selection, RFE, NMF, Gaussian mixture, FastICA, PCA, 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
@@ -109,9 +109,7 @@ from scikit-learn's `BaseEstimator` and the matching mixin, so `clone`,
109
109
  `get_params` / `set_params`, `GridSearchCV`, `Pipeline` and
110
110
  `cross_val_score` take them, and all 44 pass
111
111
  `sklearn.utils.estimator_checks.check_estimator` (`check-sklearn.py`
112
- runs it; the expected failures are `DesignLasso`'s missing `n_iter_`,
113
- since the derived kernel does not count its sweeps, and
114
- `LBFGSLogisticRegressionCV`'s
112
+ runs it; the one expected failure is `LBFGSLogisticRegressionCV`'s
115
113
  `n_iter_` of 0 for a C whose warm start is already converged, which
116
114
  scikit-learn's own `LogisticRegressionCV` reports on the same data).
117
115
  scikit-learn stays optional: without it a numpy-only stand-in gives
@@ -645,6 +643,15 @@ matrix (`KernelSVM`) or transposing X into columns
645
643
  | `L1LogisticRegression`, 20,000 x 500, C=0.05 | 1.20 s | 2.23 s | 1.9x | 106.77913 / 106.77915 | 100% |
646
644
  | `L1LogisticRegression`, 100,000 x 200, C=0.05 | 9.06 s | 18.7 s | 2.1x | 349.61154 / 349.61216 | 100% |
647
645
 
646
+ On 2,000 x 20,000 neither side reaches the optimum at tol 1e-4 (the
647
+ objective at tol 1e-10 is 0.0519588), and where each stops depends on
648
+ the coordinate order: over eight seeds ours stops at 0.05240 to
649
+ 0.05251 (0.9 to 1.1% above the optimum), `LinearSVC`, whose order is
650
+ random unless `random_state` is given, at 0.05242 to 0.05319 (0.9 to
651
+ 2.4%). When `LinearSVC` draws one of its worse orders the gap passes
652
+ the script's 0.5% bound and the row prints `<-- disagrees`; ours is
653
+ then the better solution of the two, so the flag there is not a fault.
654
+
648
655
  The regressors, from the same script (C = 1, epsilon 0.1):
649
656
 
650
657
  | problem | ours | scikit-learn | ratio | agreement |
@@ -91,9 +91,7 @@ from scikit-learn's `BaseEstimator` and the matching mixin, so `clone`,
91
91
  `get_params` / `set_params`, `GridSearchCV`, `Pipeline` and
92
92
  `cross_val_score` take them, and all 44 pass
93
93
  `sklearn.utils.estimator_checks.check_estimator` (`check-sklearn.py`
94
- runs it; the expected failures are `DesignLasso`'s missing `n_iter_`,
95
- since the derived kernel does not count its sweeps, and
96
- `LBFGSLogisticRegressionCV`'s
94
+ runs it; the one expected failure is `LBFGSLogisticRegressionCV`'s
97
95
  `n_iter_` of 0 for a C whose warm start is already converged, which
98
96
  scikit-learn's own `LogisticRegressionCV` reports on the same data).
99
97
  scikit-learn stays optional: without it a numpy-only stand-in gives
@@ -627,6 +625,15 @@ matrix (`KernelSVM`) or transposing X into columns
627
625
  | `L1LogisticRegression`, 20,000 x 500, C=0.05 | 1.20 s | 2.23 s | 1.9x | 106.77913 / 106.77915 | 100% |
628
626
  | `L1LogisticRegression`, 100,000 x 200, C=0.05 | 9.06 s | 18.7 s | 2.1x | 349.61154 / 349.61216 | 100% |
629
627
 
628
+ On 2,000 x 20,000 neither side reaches the optimum at tol 1e-4 (the
629
+ objective at tol 1e-10 is 0.0519588), and where each stops depends on
630
+ the coordinate order: over eight seeds ours stops at 0.05240 to
631
+ 0.05251 (0.9 to 1.1% above the optimum), `LinearSVC`, whose order is
632
+ random unless `random_state` is given, at 0.05242 to 0.05319 (0.9 to
633
+ 2.4%). When `LinearSVC` draws one of its worse orders the gap passes
634
+ the script's 0.5% bound and the row prints `<-- disagrees`; ours is
635
+ then the better solution of the two, so the flag there is not a fault.
636
+
630
637
  The regressors, from the same script (C = 1, epsilon 0.1):
631
638
 
632
639
  | problem | ours | scikit-learn | ratio | agreement |
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scm2cpp-lasso"
7
- version = "0.15.0"
7
+ version = "0.15.1"
8
8
  description = "scikit-learn estimators (lasso, elastic net, ridge, ARD, SVM, SVR, logistic regression, GLMs, Huber, Theil-Sen, F-score selection, RFE, NMF, Gaussian mixture, FastICA, PCA, 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"
@@ -56,7 +56,7 @@ __all__ = ["GramLasso", "GramElasticNet", "GramRidge", "CovLasso", "CovRidge", "
56
56
  "GramLogisticRegression", "GramGroupLasso", "GramMultiTaskLasso",
57
57
  "GramMultiTaskElasticNet", "DesignLasso",
58
58
  "cuda_available", "derived_backend", "kernel"]
59
- __version__ = "0.15.0"
59
+ __version__ = "0.15.1"
60
60
 
61
61
  _BATCH = load_batch_lib()
62
62
  _DP = ctypes.POINTER(ctypes.c_double)
@@ -363,16 +363,18 @@ class DerivedLasso:
363
363
  the column norms (folded into the Gram's diagonal when p < n),
364
364
  builds the Gram matrix, walks the penalties, and leaves the
365
365
  coefficient at each in a row of the result. tol is the largest move of
366
- one coefficient in a sweep below which that lambda is done.
366
+ one coefficient in a sweep below which that lambda is done. The
367
+ kernel's value, the sweeps run over the whole path, is kept as
368
+ n_iter_.
367
369
  """
368
370
  lams = np.ascontiguousarray(lambdas, dtype=np.float64).ravel()
369
371
  beta = np.zeros(self.p)
370
372
  resid = np.empty(self.nobs) # filled by the kernel from y
371
373
  xnorm = np.empty(self.p) # the column norms, taken inside
372
374
  betas = np.zeros(lams.size * self.p)
373
- self._kernel.lasso_design(self.X, self.y, resid, xnorm, beta, lams,
374
- betas, int(max_sweeps), float(tol),
375
- self.nobs, self.p, lams.size)
375
+ self.n_iter_ = int(self._kernel.lasso_design(
376
+ self.X, self.y, resid, xnorm, beta, lams, betas, int(max_sweeps), float(tol),
377
+ self.nobs, self.p, lams.size))
376
378
  return betas.reshape(lams.size, self.p)
377
379
 
378
380
 
@@ -382,10 +384,9 @@ class DesignLasso(Tagged, RegressorMixin, BaseEstimator):
382
384
  at one penalty ``alpha``, same objective as GramLasso. ``tol`` is
383
385
  the kernel's (the largest absolute move of one coefficient in a
384
386
  sweep), ``max_iter`` its sweep cap and ``backend`` DerivedLasso's.
385
- The kernel does not report how many sweeps it ran, so there is no
386
- n_iter_.
387
387
 
388
- Attributes after fit: coef_, intercept_, n_features_in_.
388
+ Attributes after fit: coef_, intercept_, n_iter_ (the sweeps the
389
+ kernel ran), n_features_in_.
389
390
  """
390
391
 
391
392
  def __init__(self, alpha=1.0, *, fit_intercept=True, tol=1e-8, max_iter=100000,
@@ -398,6 +399,7 @@ class DesignLasso(Tagged, RegressorMixin, BaseEstimator):
398
399
  Xc, yc, xm, ym = _centered(X, y, self.fit_intercept)
399
400
  m = DerivedLasso(Xc, yc, backend=self.backend)
400
401
  self.coef_ = m.fit(float(self.alpha), tol=float(self.tol), max_sweeps=int(self.max_iter))
402
+ self.n_iter_ = m.n_iter_
401
403
  self.intercept_ = float(ym - xm @ self.coef_)
402
404
  return self
403
405
 
@@ -30,26 +30,28 @@ soft_threshold( double z, double g )
30
30
 
31
31
  inline int
32
32
  lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::span<double> resid, scm2cpp::span<double> xnorm, scm2cpp::span<double> beta, scm2cpp::cspan<double> lams, scm2cpp::span<double> betas, int iters, double tol, int n, int p, int nlam )
33
- { if( p < n ) {
33
+ { int swept = 0;
34
+ if( p < n ) {
34
35
  for( int i = 0 ; !(i == n) ; i = (i+1) ) {
35
36
  resid[ i ] = y[i] ;
36
37
  } ;
37
38
  0 ;
38
- std::vector<double> b024258(p,0.0);
39
- std::vector<double> g24257((p*p),0.0);
40
- std::vector<double> c24256(p,0.0);
41
- scm2cpp::blas_syrk(g24257, x, 1.0, 0.0, 1, p, n) ;
42
- scm2cpp::blas_gemv(c24256, x, resid, 1.0, 0.0, 1, p, n) ;
39
+ std::vector<double> b03446(p,0.0);
40
+ std::vector<double> g3445((p*p),0.0);
41
+ std::vector<double> c3444(p,0.0);
42
+ scm2cpp::blas_syrk(g3445, x, 1.0, 0.0, 1, p, n) ;
43
+ scm2cpp::blas_gemv(c3444, x, resid, 1.0, 0.0, 1, p, n) ;
43
44
  for( int l = 0 ; !(l == nlam) ; l = (l+1) ) {
44
45
  double lam = lams[l];
45
46
  int stop = 0;
46
47
  for( int sweep = 0 ; !((sweep == iters || stop == 1)) ; sweep = (sweep+1) ) {
48
+ swept = (swept+1) ;
47
49
  double maxmove = 0.0;
48
50
  for( int j = 0 ; !(j == p) ; j = (j+1) ) {
49
- double rho = c24256[j];
51
+ double rho = c3444[j];
50
52
  double old = beta[j];
51
- rho = (rho+(old*g24257[((j*p)+j)])) ;
52
- double bnew = (soft_threshold(rho,double((lam*(1.0*n))))/g24257[((j*p)+j)]);
53
+ rho = (rho+(old*g3445[((j*p)+j)])) ;
54
+ double bnew = (soft_threshold(rho,double((lam*(1.0*n))))/g3445[((j*p)+j)]);
53
55
  beta[ j ] = bnew ;
54
56
  if( !(bnew == old) ) {
55
57
  if( (bnew-old) > maxmove ) {
@@ -62,9 +64,9 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
62
64
  } else {
63
65
  0 ;
64
66
  } ;
65
- b024258[ j ] = (b024258[j]+(bnew-old)) ;
66
- for( int k24260 = 0 ; !(k24260 == p) ; k24260 = (k24260+1) ) {
67
- c24256[ k24260 ] = (c24256[k24260]-(g24257[((j*p)+k24260)]*(bnew-old))) ;
67
+ b03446[ j ] = (b03446[j]+(bnew-old)) ;
68
+ for( int k3448 = 0 ; !(k3448 == p) ; k3448 = (k3448+1) ) {
69
+ c3444[ k3448 ] = (c3444[k3448]-(g3445[((j*p)+k3448)]*(bnew-old))) ;
68
70
  } ;
69
71
  } else {
70
72
  false ;
@@ -85,7 +87,7 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
85
87
  } ;
86
88
  ;
87
89
  } ;
88
- scm2cpp::blas_gemv(resid, x, b024258, -1.0, 1.0, 0, n, p) ;
90
+ scm2cpp::blas_gemv(resid, x, b03446, -1.0, 1.0, 0, n, p) ;
89
91
  0 ;
90
92
  ;
91
93
  } else {
@@ -104,6 +106,7 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
104
106
  double lam = lams[l];
105
107
  int stop = 0;
106
108
  for( int sweep = 0 ; !((sweep == iters || stop == 1)) ; sweep = (sweep+1) ) {
109
+ swept = (swept+1) ;
107
110
  double maxmove = 0.0;
108
111
  for( int j = 0 ; !(j == p) ; j = (j+1) ) {
109
112
  double rho = 0.0;
@@ -148,6 +151,6 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
148
151
  ;
149
152
  } ;
150
153
  } ;
151
- return 0 ;
154
+ return swept ;
152
155
  }
153
156
  #endif // LASSO_DESIGN_HPP
@@ -30,27 +30,29 @@ soft_threshold( double z, double g )
30
30
 
31
31
  inline int
32
32
  lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::span<double> resid, scm2cpp::span<double> xnorm, scm2cpp::span<double> beta, scm2cpp::cspan<double> lams, scm2cpp::span<double> betas, int iters, double tol, int n, int p, int nlam )
33
- { if( p < n ) {
33
+ { int swept = 0;
34
+ if( p < n ) {
34
35
  for( int i = 0 ; !(i == n) ; i = (i+1) ) {
35
36
  resid[ i ] = y[i] ;
36
37
  } ;
37
38
  0 ;
38
- std::vector<double> b024258(p,0.0);
39
- std::vector<double> g24257((p*p),0.0);
40
- std::vector<double> c24256(p,0.0);
41
- scm2cpp::device_matrix d24266 = scm2cpp::dmat_upload(x, (n*p), 1);
42
- scm2cpp::blas_syrk(g24257, d24266, 1.0, 0.0, 1, p, n) ;
43
- scm2cpp::blas_gemv(c24256, d24266, resid, 1.0, 0.0, 1, p, n) ;
39
+ std::vector<double> b03446(p,0.0);
40
+ std::vector<double> g3445((p*p),0.0);
41
+ std::vector<double> c3444(p,0.0);
42
+ scm2cpp::device_matrix d3454 = scm2cpp::dmat_upload(x, (n*p), 1);
43
+ scm2cpp::blas_syrk(g3445, d3454, 1.0, 0.0, 1, p, n) ;
44
+ scm2cpp::blas_gemv(c3444, d3454, resid, 1.0, 0.0, 1, p, n) ;
44
45
  for( int l = 0 ; !(l == nlam) ; l = (l+1) ) {
45
46
  double lam = lams[l];
46
47
  int stop = 0;
47
48
  for( int sweep = 0 ; !((sweep == iters || stop == 1)) ; sweep = (sweep+1) ) {
49
+ swept = (swept+1) ;
48
50
  double maxmove = 0.0;
49
51
  for( int j = 0 ; !(j == p) ; j = (j+1) ) {
50
- double rho = c24256[j];
52
+ double rho = c3444[j];
51
53
  double old = beta[j];
52
- rho = (rho+(old*g24257[((j*p)+j)])) ;
53
- double bnew = (soft_threshold(rho,double((lam*(1.0*n))))/g24257[((j*p)+j)]);
54
+ rho = (rho+(old*g3445[((j*p)+j)])) ;
55
+ double bnew = (soft_threshold(rho,double((lam*(1.0*n))))/g3445[((j*p)+j)]);
54
56
  beta[ j ] = bnew ;
55
57
  if( !(bnew == old) ) {
56
58
  if( (bnew-old) > maxmove ) {
@@ -63,9 +65,9 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
63
65
  } else {
64
66
  0 ;
65
67
  } ;
66
- b024258[ j ] = (b024258[j]+(bnew-old)) ;
67
- for( int k24260 = 0 ; !(k24260 == p) ; k24260 = (k24260+1) ) {
68
- c24256[ k24260 ] = (c24256[k24260]-(g24257[((j*p)+k24260)]*(bnew-old))) ;
68
+ b03446[ j ] = (b03446[j]+(bnew-old)) ;
69
+ for( int k3448 = 0 ; !(k3448 == p) ; k3448 = (k3448+1) ) {
70
+ c3444[ k3448 ] = (c3444[k3448]-(g3445[((j*p)+k3448)]*(bnew-old))) ;
69
71
  } ;
70
72
  } else {
71
73
  false ;
@@ -86,7 +88,7 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
86
88
  } ;
87
89
  ;
88
90
  } ;
89
- scm2cpp::blas_gemv(resid, d24266, b024258, -1.0, 1.0, 0, n, p) ;
91
+ scm2cpp::blas_gemv(resid, d3454, b03446, -1.0, 1.0, 0, n, p) ;
90
92
  0 ;
91
93
  ;
92
94
  ;
@@ -106,6 +108,7 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
106
108
  double lam = lams[l];
107
109
  int stop = 0;
108
110
  for( int sweep = 0 ; !((sweep == iters || stop == 1)) ; sweep = (sweep+1) ) {
111
+ swept = (swept+1) ;
109
112
  double maxmove = 0.0;
110
113
  for( int j = 0 ; !(j == p) ; j = (j+1) ) {
111
114
  double rho = 0.0;
@@ -150,6 +153,6 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
150
153
  ;
151
154
  } ;
152
155
  } ;
153
- return 0 ;
156
+ return swept ;
154
157
  }
155
158
  #endif // LASSO_DESIGN_HPP
@@ -29,43 +29,45 @@ soft_threshold( double z, double g )
29
29
 
30
30
  inline int
31
31
  lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::span<double> resid, scm2cpp::span<double> xnorm, scm2cpp::span<double> beta, scm2cpp::cspan<double> lams, scm2cpp::span<double> betas, int iters, double tol, int n, int p, int nlam )
32
- { if( p < n ) {
32
+ { int swept = 0;
33
+ if( p < n ) {
33
34
  for( int i = 0 ; !(i == n) ; i = (i+1) ) {
34
35
  resid[ i ] = y[i] ;
35
36
  } ;
36
37
  0 ;
37
- std::vector<double> b024258(p,0.0);
38
- std::vector<double> g24257((p*p),0.0);
39
- std::vector<double> c24256(p,0.0);
38
+ std::vector<double> b03446(p,0.0);
39
+ std::vector<double> g3445((p*p),0.0);
40
+ std::vector<double> c3444(p,0.0);
40
41
  for( int y2491 = 0 ; !(y2491 == p) ; y2491 = (y2491+1) ) {
41
42
  for( int y2492 = y2491 ; !(y2492 == p) ; y2492 = (y2492+1) ) {
42
- g24257[ ((y2491*p)+y2492) ] = ([&]() -> double { int k2493 = 0; double sum2498 = 0.0; while (!(k2493 == n)) {
43
- int k2493_next24266 = (k2493+1);
44
- double sum2498_next24267 = (sum2498+(x[((k2493*p)+y2491)]*x[((k2493*p)+y2492)]));
45
- k2493 = k2493_next24266;
46
- sum2498 = sum2498_next24267;
43
+ g3445[ ((y2491*p)+y2492) ] = ([&]() -> double { int k2493 = 0; double sum2498 = 0.0; while (!(k2493 == n)) {
44
+ int k2493_next3454 = (k2493+1);
45
+ double sum2498_next3455 = (sum2498+(x[((k2493*p)+y2491)]*x[((k2493*p)+y2492)]));
46
+ k2493 = k2493_next3454;
47
+ sum2498 = sum2498_next3455;
47
48
  } return sum2498; })() ;
48
- g24257[ ((y2492*p)+y2491) ] = g24257[((y2491*p)+y2492)] ;
49
+ g3445[ ((y2492*p)+y2491) ] = g3445[((y2491*p)+y2492)] ;
49
50
  } ;
50
51
  } ;
51
52
  for( int y2494 = 0 ; !(y2494 == p) ; y2494 = (y2494+1) ) {
52
- c24256[ y2494 ] = ([&]() -> double { int k2495 = 0; double sum2500 = 0.0; while (!(k2495 == n)) {
53
- int k2495_next24268 = (k2495+1);
54
- double sum2500_next24269 = (sum2500+(x[((k2495*p)+y2494)]*resid[k2495]));
55
- k2495 = k2495_next24268;
56
- sum2500 = sum2500_next24269;
53
+ c3444[ y2494 ] = ([&]() -> double { int k2495 = 0; double sum2500 = 0.0; while (!(k2495 == n)) {
54
+ int k2495_next3456 = (k2495+1);
55
+ double sum2500_next3457 = (sum2500+(x[((k2495*p)+y2494)]*resid[k2495]));
56
+ k2495 = k2495_next3456;
57
+ sum2500 = sum2500_next3457;
57
58
  } return sum2500; })() ;
58
59
  } ;
59
60
  for( int l = 0 ; !(l == nlam) ; l = (l+1) ) {
60
61
  double lam = lams[l];
61
62
  int stop = 0;
62
63
  for( int sweep = 0 ; !((sweep == iters || stop == 1)) ; sweep = (sweep+1) ) {
64
+ swept = (swept+1) ;
63
65
  double maxmove = 0.0;
64
66
  for( int j = 0 ; !(j == p) ; j = (j+1) ) {
65
- double rho = c24256[j];
67
+ double rho = c3444[j];
66
68
  double old = beta[j];
67
- rho = (rho+(old*g24257[((j*p)+j)])) ;
68
- double bnew = (soft_threshold(rho,double((lam*(1.0*n))))/g24257[((j*p)+j)]);
69
+ rho = (rho+(old*g3445[((j*p)+j)])) ;
70
+ double bnew = (soft_threshold(rho,double((lam*(1.0*n))))/g3445[((j*p)+j)]);
69
71
  beta[ j ] = bnew ;
70
72
  if( !(bnew == old) ) {
71
73
  if( (bnew-old) > maxmove ) {
@@ -78,9 +80,9 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
78
80
  } else {
79
81
  0 ;
80
82
  } ;
81
- b024258[ j ] = (b024258[j]+(bnew-old)) ;
82
- for( int k24260 = 0 ; !(k24260 == p) ; k24260 = (k24260+1) ) {
83
- c24256[ k24260 ] = (c24256[k24260]-(g24257[((j*p)+k24260)]*(bnew-old))) ;
83
+ b03446[ j ] = (b03446[j]+(bnew-old)) ;
84
+ for( int k3448 = 0 ; !(k3448 == p) ; k3448 = (k3448+1) ) {
85
+ c3444[ k3448 ] = (c3444[k3448]-(g3445[((j*p)+k3448)]*(bnew-old))) ;
84
86
  } ;
85
87
  } else {
86
88
  false ;
@@ -103,10 +105,10 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
103
105
  } ;
104
106
  for( int y2496 = 0 ; !(y2496 == n) ; y2496 = (y2496+1) ) {
105
107
  resid[ y2496 ] = (resid[y2496]-([&]() -> double { int k2497 = 0; double sum2502 = 0.0; while (!(k2497 == p)) {
106
- int k2497_next24270 = (k2497+1);
107
- double sum2502_next24271 = (sum2502+(b024258[k2497]*x[((y2496*p)+k2497)]));
108
- k2497 = k2497_next24270;
109
- sum2502 = sum2502_next24271;
108
+ int k2497_next3458 = (k2497+1);
109
+ double sum2502_next3459 = (sum2502+(b03446[k2497]*x[((y2496*p)+k2497)]));
110
+ k2497 = k2497_next3458;
111
+ sum2502 = sum2502_next3459;
110
112
  } return sum2502; })()) ;
111
113
  } ;
112
114
  0 ;
@@ -127,6 +129,7 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
127
129
  double lam = lams[l];
128
130
  int stop = 0;
129
131
  for( int sweep = 0 ; !((sweep == iters || stop == 1)) ; sweep = (sweep+1) ) {
132
+ swept = (swept+1) ;
130
133
  double maxmove = 0.0;
131
134
  for( int j = 0 ; !(j == p) ; j = (j+1) ) {
132
135
  double rho = 0.0;
@@ -171,6 +174,6 @@ lasso_design( scm2cpp::cspan<double> x, scm2cpp::cspan<double> y, scm2cpp::spa
171
174
  ;
172
175
  } ;
173
176
  } ;
174
- return 0 ;
177
+ return swept ;
175
178
  }
176
179
  #endif // LASSO_DESIGN_HPP
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scm2cpp-lasso
3
- Version: 0.15.0
3
+ Version: 0.15.1
4
4
  Summary: scikit-learn estimators (lasso, elastic net, ridge, ARD, SVM, SVR, logistic regression, GLMs, Huber, Theil-Sen, F-score selection, RFE, NMF, Gaussian mixture, FastICA, PCA, 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
@@ -109,9 +109,7 @@ from scikit-learn's `BaseEstimator` and the matching mixin, so `clone`,
109
109
  `get_params` / `set_params`, `GridSearchCV`, `Pipeline` and
110
110
  `cross_val_score` take them, and all 44 pass
111
111
  `sklearn.utils.estimator_checks.check_estimator` (`check-sklearn.py`
112
- runs it; the expected failures are `DesignLasso`'s missing `n_iter_`,
113
- since the derived kernel does not count its sweeps, and
114
- `LBFGSLogisticRegressionCV`'s
112
+ runs it; the one expected failure is `LBFGSLogisticRegressionCV`'s
115
113
  `n_iter_` of 0 for a C whose warm start is already converged, which
116
114
  scikit-learn's own `LogisticRegressionCV` reports on the same data).
117
115
  scikit-learn stays optional: without it a numpy-only stand-in gives
@@ -645,6 +643,15 @@ matrix (`KernelSVM`) or transposing X into columns
645
643
  | `L1LogisticRegression`, 20,000 x 500, C=0.05 | 1.20 s | 2.23 s | 1.9x | 106.77913 / 106.77915 | 100% |
646
644
  | `L1LogisticRegression`, 100,000 x 200, C=0.05 | 9.06 s | 18.7 s | 2.1x | 349.61154 / 349.61216 | 100% |
647
645
 
646
+ On 2,000 x 20,000 neither side reaches the optimum at tol 1e-4 (the
647
+ objective at tol 1e-10 is 0.0519588), and where each stops depends on
648
+ the coordinate order: over eight seeds ours stops at 0.05240 to
649
+ 0.05251 (0.9 to 1.1% above the optimum), `LinearSVC`, whose order is
650
+ random unless `random_state` is given, at 0.05242 to 0.05319 (0.9 to
651
+ 2.4%). When `LinearSVC` draws one of its worse orders the gap passes
652
+ the script's 0.5% bound and the row prints `<-- disagrees`; ours is
653
+ then the better solution of the two, so the flag there is not a fault.
654
+
648
655
  The regressors, from the same script (C = 1, epsilon 0.1):
649
656
 
650
657
  | problem | ours | scikit-learn | ratio | agreement |
File without changes
File without changes