statgpu 0.1.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 (175) hide show
  1. statgpu-0.1.0/LICENSE +199 -0
  2. statgpu-0.1.0/MANIFEST.in +1 -0
  3. statgpu-0.1.0/PKG-INFO +245 -0
  4. statgpu-0.1.0/README.md +195 -0
  5. statgpu-0.1.0/pyproject.toml +60 -0
  6. statgpu-0.1.0/setup.cfg +4 -0
  7. statgpu-0.1.0/setup.py +47 -0
  8. statgpu-0.1.0/statgpu/__init__.py +174 -0
  9. statgpu-0.1.0/statgpu/_base.py +544 -0
  10. statgpu-0.1.0/statgpu/_config.py +127 -0
  11. statgpu-0.1.0/statgpu/anova/__init__.py +5 -0
  12. statgpu-0.1.0/statgpu/anova/_oneway.py +194 -0
  13. statgpu-0.1.0/statgpu/backends/__init__.py +83 -0
  14. statgpu-0.1.0/statgpu/backends/_array_ops.py +529 -0
  15. statgpu-0.1.0/statgpu/backends/_base.py +184 -0
  16. statgpu-0.1.0/statgpu/backends/_cupy.py +453 -0
  17. statgpu-0.1.0/statgpu/backends/_factory.py +65 -0
  18. statgpu-0.1.0/statgpu/backends/_gpu_inference_cupy.py +214 -0
  19. statgpu-0.1.0/statgpu/backends/_gpu_inference_torch.py +422 -0
  20. statgpu-0.1.0/statgpu/backends/_numpy.py +324 -0
  21. statgpu-0.1.0/statgpu/backends/_torch.py +685 -0
  22. statgpu-0.1.0/statgpu/backends/_torch_safe.py +47 -0
  23. statgpu-0.1.0/statgpu/backends/_utils.py +423 -0
  24. statgpu-0.1.0/statgpu/core/__init__.py +10 -0
  25. statgpu-0.1.0/statgpu/core/formula/__init__.py +33 -0
  26. statgpu-0.1.0/statgpu/core/formula/_design.py +99 -0
  27. statgpu-0.1.0/statgpu/core/formula/_parser.py +191 -0
  28. statgpu-0.1.0/statgpu/core/formula/_terms.py +70 -0
  29. statgpu-0.1.0/statgpu/core/formula/tests/__init__.py +0 -0
  30. statgpu-0.1.0/statgpu/core/formula/tests/test_parser.py +194 -0
  31. statgpu-0.1.0/statgpu/covariance/__init__.py +6 -0
  32. statgpu-0.1.0/statgpu/covariance/_empirical.py +310 -0
  33. statgpu-0.1.0/statgpu/covariance/_shrinkage.py +248 -0
  34. statgpu-0.1.0/statgpu/cross_validation/__init__.py +31 -0
  35. statgpu-0.1.0/statgpu/cross_validation/_base.py +410 -0
  36. statgpu-0.1.0/statgpu/cross_validation/_engine.py +167 -0
  37. statgpu-0.1.0/statgpu/diagnostics/__init__.py +7 -0
  38. statgpu-0.1.0/statgpu/diagnostics/_regression_diagnostics.py +188 -0
  39. statgpu-0.1.0/statgpu/feature_selection/__init__.py +24 -0
  40. statgpu-0.1.0/statgpu/feature_selection/_knockoff.py +870 -0
  41. statgpu-0.1.0/statgpu/feature_selection/_knockoff_utils.py +1003 -0
  42. statgpu-0.1.0/statgpu/feature_selection/_stepwise.py +300 -0
  43. statgpu-0.1.0/statgpu/glm_core/__init__.py +81 -0
  44. statgpu-0.1.0/statgpu/glm_core/_base.py +202 -0
  45. statgpu-0.1.0/statgpu/glm_core/_family.py +362 -0
  46. statgpu-0.1.0/statgpu/glm_core/_fused.py +149 -0
  47. statgpu-0.1.0/statgpu/glm_core/_gamma.py +111 -0
  48. statgpu-0.1.0/statgpu/glm_core/_inverse_gaussian.py +62 -0
  49. statgpu-0.1.0/statgpu/glm_core/_irls.py +561 -0
  50. statgpu-0.1.0/statgpu/glm_core/_logistic.py +82 -0
  51. statgpu-0.1.0/statgpu/glm_core/_negative_binomial.py +68 -0
  52. statgpu-0.1.0/statgpu/glm_core/_poisson.py +60 -0
  53. statgpu-0.1.0/statgpu/glm_core/_solver_legacy.py +100 -0
  54. statgpu-0.1.0/statgpu/glm_core/_squared.py +53 -0
  55. statgpu-0.1.0/statgpu/glm_core/_tweedie.py +74 -0
  56. statgpu-0.1.0/statgpu/inference/__init__.py +239 -0
  57. statgpu-0.1.0/statgpu/inference/_distributions_backend.py +2610 -0
  58. statgpu-0.1.0/statgpu/inference/_multiple_testing.py +391 -0
  59. statgpu-0.1.0/statgpu/inference/_resampling.py +1400 -0
  60. statgpu-0.1.0/statgpu/inference/_results.py +265 -0
  61. statgpu-0.1.0/statgpu/linear_model/__init__.py +75 -0
  62. statgpu-0.1.0/statgpu/linear_model/_gaussian_inference.py +306 -0
  63. statgpu-0.1.0/statgpu/linear_model/_glm_base.py +1261 -0
  64. statgpu-0.1.0/statgpu/linear_model/_ordered_logit.py +52 -0
  65. statgpu-0.1.0/statgpu/linear_model/_ordered_probit.py +50 -0
  66. statgpu-0.1.0/statgpu/linear_model/_stats.py +170 -0
  67. statgpu-0.1.0/statgpu/linear_model/cv/__init__.py +13 -0
  68. statgpu-0.1.0/statgpu/linear_model/cv/_elasticnet_cv.py +892 -0
  69. statgpu-0.1.0/statgpu/linear_model/cv/_lasso_cv.py +253 -0
  70. statgpu-0.1.0/statgpu/linear_model/cv/_logistic_cv.py +895 -0
  71. statgpu-0.1.0/statgpu/linear_model/cv/_ridge_cv.py +1160 -0
  72. statgpu-0.1.0/statgpu/linear_model/legacy/__init__.py +1 -0
  73. statgpu-0.1.0/statgpu/linear_model/legacy/_distributions_legacy_gpu.py +340 -0
  74. statgpu-0.1.0/statgpu/linear_model/legacy/_elasticnet_legacy.py +936 -0
  75. statgpu-0.1.0/statgpu/linear_model/legacy/_lasso_legacy.py +4876 -0
  76. statgpu-0.1.0/statgpu/linear_model/legacy/_penalized_legacy.py +1174 -0
  77. statgpu-0.1.0/statgpu/linear_model/legacy/_ridge_legacy.py +863 -0
  78. statgpu-0.1.0/statgpu/linear_model/legacy/_solver_legacy.py +104 -0
  79. statgpu-0.1.0/statgpu/linear_model/penalized/__init__.py +25 -0
  80. statgpu-0.1.0/statgpu/linear_model/penalized/_base.py +437 -0
  81. statgpu-0.1.0/statgpu/linear_model/penalized/_fit_mixin.py +1877 -0
  82. statgpu-0.1.0/statgpu/linear_model/penalized/_inference_mixin.py +1179 -0
  83. statgpu-0.1.0/statgpu/linear_model/penalized/_penalized_cv.py +2699 -0
  84. statgpu-0.1.0/statgpu/linear_model/penalized/_penalized_gamma.py +86 -0
  85. statgpu-0.1.0/statgpu/linear_model/penalized/_penalized_inverse_gaussian.py +62 -0
  86. statgpu-0.1.0/statgpu/linear_model/penalized/_penalized_linear.py +236 -0
  87. statgpu-0.1.0/statgpu/linear_model/penalized/_penalized_logistic.py +100 -0
  88. statgpu-0.1.0/statgpu/linear_model/penalized/_penalized_negative_binomial.py +65 -0
  89. statgpu-0.1.0/statgpu/linear_model/penalized/_penalized_poisson.py +62 -0
  90. statgpu-0.1.0/statgpu/linear_model/penalized/_penalized_tweedie.py +65 -0
  91. statgpu-0.1.0/statgpu/linear_model/penalized/_predict_mixin.py +182 -0
  92. statgpu-0.1.0/statgpu/linear_model/wrappers/__init__.py +31 -0
  93. statgpu-0.1.0/statgpu/linear_model/wrappers/_adaptive_lasso.py +63 -0
  94. statgpu-0.1.0/statgpu/linear_model/wrappers/_elasticnet.py +75 -0
  95. statgpu-0.1.0/statgpu/linear_model/wrappers/_gamma.py +67 -0
  96. statgpu-0.1.0/statgpu/linear_model/wrappers/_inverse_gaussian.py +47 -0
  97. statgpu-0.1.0/statgpu/linear_model/wrappers/_lasso.py +2124 -0
  98. statgpu-0.1.0/statgpu/linear_model/wrappers/_linear.py +1127 -0
  99. statgpu-0.1.0/statgpu/linear_model/wrappers/_logistic.py +1435 -0
  100. statgpu-0.1.0/statgpu/linear_model/wrappers/_mcp.py +58 -0
  101. statgpu-0.1.0/statgpu/linear_model/wrappers/_negative_binomial.py +58 -0
  102. statgpu-0.1.0/statgpu/linear_model/wrappers/_poisson.py +48 -0
  103. statgpu-0.1.0/statgpu/linear_model/wrappers/_ridge.py +166 -0
  104. statgpu-0.1.0/statgpu/linear_model/wrappers/_scad.py +58 -0
  105. statgpu-0.1.0/statgpu/linear_model/wrappers/_tweedie.py +57 -0
  106. statgpu-0.1.0/statgpu/metrics/__init__.py +21 -0
  107. statgpu-0.1.0/statgpu/metrics/_classification.py +591 -0
  108. statgpu-0.1.0/statgpu/nonparametric/__init__.py +50 -0
  109. statgpu-0.1.0/statgpu/nonparametric/kernel_methods/__init__.py +25 -0
  110. statgpu-0.1.0/statgpu/nonparametric/kernel_methods/_kernels.py +246 -0
  111. statgpu-0.1.0/statgpu/nonparametric/kernel_methods/_krr.py +234 -0
  112. statgpu-0.1.0/statgpu/nonparametric/kernel_methods/_krr_cv.py +380 -0
  113. statgpu-0.1.0/statgpu/nonparametric/kernel_smoothing/__init__.py +39 -0
  114. statgpu-0.1.0/statgpu/nonparametric/kernel_smoothing/_bandwidth_selection.py +1083 -0
  115. statgpu-0.1.0/statgpu/nonparametric/kernel_smoothing/_kde.py +761 -0
  116. statgpu-0.1.0/statgpu/nonparametric/kernel_smoothing/_kernel_common.py +348 -0
  117. statgpu-0.1.0/statgpu/nonparametric/kernel_smoothing/_kernel_regression.py +748 -0
  118. statgpu-0.1.0/statgpu/nonparametric/splines/__init__.py +5 -0
  119. statgpu-0.1.0/statgpu/nonparametric/splines/_bspline_basis.py +336 -0
  120. statgpu-0.1.0/statgpu/nonparametric/splines/_penalized.py +349 -0
  121. statgpu-0.1.0/statgpu/panel/__init__.py +19 -0
  122. statgpu-0.1.0/statgpu/panel/_covariance.py +140 -0
  123. statgpu-0.1.0/statgpu/panel/_fixed_effects.py +420 -0
  124. statgpu-0.1.0/statgpu/panel/_random_effects.py +385 -0
  125. statgpu-0.1.0/statgpu/panel/_utils.py +482 -0
  126. statgpu-0.1.0/statgpu/penalties/__init__.py +139 -0
  127. statgpu-0.1.0/statgpu/penalties/_adaptive_l1.py +313 -0
  128. statgpu-0.1.0/statgpu/penalties/_base.py +261 -0
  129. statgpu-0.1.0/statgpu/penalties/_categories.py +39 -0
  130. statgpu-0.1.0/statgpu/penalties/_elasticnet.py +98 -0
  131. statgpu-0.1.0/statgpu/penalties/_group_lasso.py +678 -0
  132. statgpu-0.1.0/statgpu/penalties/_group_mcp.py +553 -0
  133. statgpu-0.1.0/statgpu/penalties/_group_scad.py +605 -0
  134. statgpu-0.1.0/statgpu/penalties/_l1.py +107 -0
  135. statgpu-0.1.0/statgpu/penalties/_l2.py +77 -0
  136. statgpu-0.1.0/statgpu/penalties/_mcp.py +237 -0
  137. statgpu-0.1.0/statgpu/penalties/_scad.py +260 -0
  138. statgpu-0.1.0/statgpu/semiparametric/__init__.py +5 -0
  139. statgpu-0.1.0/statgpu/semiparametric/_gam.py +401 -0
  140. statgpu-0.1.0/statgpu/solvers/__init__.py +24 -0
  141. statgpu-0.1.0/statgpu/solvers/_admm.py +241 -0
  142. statgpu-0.1.0/statgpu/solvers/_constants.py +15 -0
  143. statgpu-0.1.0/statgpu/solvers/_convergence.py +6 -0
  144. statgpu-0.1.0/statgpu/solvers/_fista.py +436 -0
  145. statgpu-0.1.0/statgpu/solvers/_fista_bb.py +513 -0
  146. statgpu-0.1.0/statgpu/solvers/_fista_lla.py +541 -0
  147. statgpu-0.1.0/statgpu/solvers/_lbfgs.py +206 -0
  148. statgpu-0.1.0/statgpu/solvers/_newton.py +149 -0
  149. statgpu-0.1.0/statgpu/solvers/_utils.py +277 -0
  150. statgpu-0.1.0/statgpu/survival/__init__.py +14 -0
  151. statgpu-0.1.0/statgpu/survival/_cox.py +3974 -0
  152. statgpu-0.1.0/statgpu/survival/_cox_breslow_triton_kernel.py +106 -0
  153. statgpu-0.1.0/statgpu/survival/_cox_cv.py +1159 -0
  154. statgpu-0.1.0/statgpu/survival/_cox_efron_cuda.py +1280 -0
  155. statgpu-0.1.0/statgpu/survival/_cox_efron_triton.py +359 -0
  156. statgpu-0.1.0/statgpu/unsupervised/__init__.py +29 -0
  157. statgpu-0.1.0/statgpu/unsupervised/_agglomerative.py +307 -0
  158. statgpu-0.1.0/statgpu/unsupervised/_dbscan.py +263 -0
  159. statgpu-0.1.0/statgpu/unsupervised/_dbscan_cpu.pyx +125 -0
  160. statgpu-0.1.0/statgpu/unsupervised/_gmm.py +332 -0
  161. statgpu-0.1.0/statgpu/unsupervised/_incremental_pca.py +176 -0
  162. statgpu-0.1.0/statgpu/unsupervised/_kmeans.py +261 -0
  163. statgpu-0.1.0/statgpu/unsupervised/_minibatch_kmeans.py +299 -0
  164. statgpu-0.1.0/statgpu/unsupervised/_minibatch_nmf.py +252 -0
  165. statgpu-0.1.0/statgpu/unsupervised/_nmf.py +190 -0
  166. statgpu-0.1.0/statgpu/unsupervised/_pca.py +189 -0
  167. statgpu-0.1.0/statgpu/unsupervised/_truncated_svd.py +132 -0
  168. statgpu-0.1.0/statgpu/unsupervised/_tsne.py +192 -0
  169. statgpu-0.1.0/statgpu/unsupervised/_umap.py +224 -0
  170. statgpu-0.1.0/statgpu/unsupervised/_utils.py +134 -0
  171. statgpu-0.1.0/statgpu.egg-info/PKG-INFO +245 -0
  172. statgpu-0.1.0/statgpu.egg-info/SOURCES.txt +173 -0
  173. statgpu-0.1.0/statgpu.egg-info/dependency_links.txt +1 -0
  174. statgpu-0.1.0/statgpu.egg-info/requires.txt +31 -0
  175. statgpu-0.1.0/statgpu.egg-info/top_level.txt +1 -0
statgpu-0.1.0/LICENSE ADDED
@@ -0,0 +1,199 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including
48
+ the original version of the Work and any modifications or additions
49
+ to that Work or Derivative Works thereof, that is intentionally
50
+ submitted to the Licensor for inclusion in the Work by the copyright owner
51
+ or by an individual or Legal Entity authorized to submit on behalf of
52
+ the copyright owner. For the purposes of this definition, "submitted"
53
+ means any form of electronic, verbal, or written communication sent
54
+ to the Licensor or its representatives, including but not limited to
55
+ communication on electronic mailing lists, source code control systems,
56
+ and issue tracking systems that are managed by, or on behalf of, the
57
+ Licensor for the purpose of discussing and improving the Work, but
58
+ excluding communication that is conspicuously marked or otherwise
59
+ designated in writing by the copyright owner as "Not a Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity
62
+ on behalf of whom a Contribution has been received by the Licensor and
63
+ subsequently incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of
66
+ this License, each Contributor hereby grants to You a perpetual,
67
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
68
+ copyright license to reproduce, prepare Derivative Works of,
69
+ publicly display, publicly perform, sublicense, and distribute the
70
+ Work and such Derivative Works in Source or Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ (except as stated in this section) patent license to make, have made,
76
+ use, offer to sell, sell, import, and otherwise transfer the Work,
77
+ where such license applies only to those patent claims licensable
78
+ by such Contributor that are necessarily infringed by their
79
+ Contribution(s) alone or by combination of their Contribution(s)
80
+ with the Work to which such Contribution(s) was submitted. If You
81
+ institute patent litigation against any entity (including a
82
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
83
+ or a Contribution incorporated within the Work constitutes direct
84
+ or contributory patent infringement, then any patent licenses
85
+ granted to You under this License for that Work shall terminate
86
+ as of the date such litigation is filed.
87
+
88
+ 4. Redistribution. You may reproduce and distribute copies of the
89
+ Work or Derivative Works thereof in any medium, with or without
90
+ modifications, and in Source or Object form, provided that You
91
+ meet the following conditions:
92
+
93
+ (a) You must give any other recipients of the Work or
94
+ Derivative Works a copy of this License; and
95
+
96
+ (b) You must cause any modified files to carry prominent notices
97
+ stating that You changed the files; and
98
+
99
+ (c) You must retain, in the Source form of any Derivative Works
100
+ that You distribute, all copyright, patent, trademark, and
101
+ attribution notices from the Source form of the Work,
102
+ excluding those notices that do not pertain to any part of
103
+ the Derivative Works; and
104
+
105
+ (d) If the Work includes a "NOTICE" text file as part of its
106
+ distribution, then any Derivative Works that You distribute must
107
+ include a readable copy of the attribution notices contained
108
+ within such NOTICE file, excluding any notices that do not
109
+ pertain to any part of the Derivative Works, in at least one
110
+ of the following places: within a NOTICE text file distributed
111
+ as part of the Derivative Works; within the Source form or
112
+ documentation, if provided along with the Derivative Works; or,
113
+ within a display generated by the Derivative Works, if and
114
+ wherever such third-party notices normally appear. The contents
115
+ of the NOTICE file are for informational purposes only and
116
+ do not modify the License. You may add Your own attribution
117
+ notices within Derivative Works that You distribute, alongside
118
+ or as an addendum to the NOTICE text from the Work, provided
119
+ that such additional attribution notices cannot be construed
120
+ as modifying the License.
121
+
122
+ You may add Your own copyright statement to Your modifications and
123
+ may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your modifications, or
125
+ for any such Derivative Works as a whole, provided Your use,
126
+ reproduction, and distribution of the Work otherwise complies with
127
+ the conditions stated in this License.
128
+
129
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
130
+ any Contribution intentionally submitted for inclusion in the Work
131
+ by You to the Licensor shall be under the terms and conditions of
132
+ this License, without any additional terms or conditions.
133
+ Notwithstanding the above, nothing herein shall supersede or modify
134
+ the terms of any separate license agreement you may have executed
135
+ with Licensor regarding such Contributions.
136
+
137
+ 6. Trademarks. This License does not grant permission to use the trade
138
+ names, trademarks, service marks, or product names of the Licensor,
139
+ except as required for reasonable and customary use in describing the
140
+ origin of the Work and reproducing the content of the NOTICE file.
141
+
142
+ 7. Disclaimer of Warranty. Unless required by applicable law or
143
+ agreed to in writing, Licensor provides the Work (and each
144
+ Contributor provides its Contributions) on an "AS IS" BASIS,
145
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
146
+ implied, including, without limitation, any warranties or conditions
147
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
148
+ PARTICULAR PURPOSE. You are solely responsible for determining the
149
+ appropriateness of using or redistributing the Work and assume any
150
+ risks associated with Your exercise of permissions under this License.
151
+
152
+ 8. Limitation of Liability. In no event and under no legal theory,
153
+ whether in tort (including negligence), contract, or otherwise,
154
+ unless required by applicable law (such as deliberate and grossly
155
+ negligent acts) or agreed to in writing, shall any Contributor be
156
+ liable to You for damages, including any direct, indirect, special,
157
+ incidental, or consequential damages of any character arising as a
158
+ result of this License or out of the use or inability to use the
159
+ Work (including but not limited to damages for loss of goodwill,
160
+ work stoppage, computer failure or malfunction, or any and all
161
+ other commercial damages or losses), even if such Contributor
162
+ has been advised of the possibility of such damages.
163
+
164
+ 9. Accepting Warranty or Additional Liability. While redistributing
165
+ the Work or Derivative Works thereof, You may choose to offer,
166
+ and charge a fee for, acceptance of support, warranty, indemnity,
167
+ or other liability obligations and/or rights consistent with this
168
+ License. However, in accepting such obligations, You may act only
169
+ on Your own behalf and on Your sole responsibility, not on behalf
170
+ of any other Contributor, and only if You agree to indemnify,
171
+ defend, and hold each Contributor harmless for any liability
172
+ incurred by, or claims asserted against, such Contributor by reason
173
+ of your accepting any such warranty or additional liability.
174
+
175
+ END OF TERMS AND CONDITIONS
176
+
177
+ APPENDIX: How to apply the Apache License to your work.
178
+
179
+ To apply the Apache License to your work, attach the following
180
+ boilerplate notice, with the fields enclosed by brackets "[]"
181
+ replaced with your own identifying information. (Don't include
182
+ the brackets!) The text should be enclosed in the appropriate
183
+ comment syntax for the file format. Please also get an
184
+ "Applicable Licenses" webpage at apache.org/licenses to confirm
185
+ the Apache 2.0 license is acceptable for your project.
186
+
187
+ Copyright 2026 TheHiddenObserver
188
+
189
+ Licensed under the Apache License, Version 2.0 (the "License");
190
+ you may not use this file except in compliance with the License.
191
+ You may obtain a copy of the License at
192
+
193
+ http://www.apache.org/licenses/LICENSE-2.0
194
+
195
+ Unless required by applicable law or agreed to in writing, software
196
+ distributed under the License is distributed on an "AS IS" BASIS,
197
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
198
+ See the License for the specific language governing permissions and
199
+ limitations under the License.
@@ -0,0 +1 @@
1
+ include statgpu/unsupervised/_dbscan_cpu.pyx
statgpu-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,245 @@
1
+ Metadata-Version: 2.4
2
+ Name: statgpu
3
+ Version: 0.1.0
4
+ Summary: GPU-accelerated statistical methods with sklearn-compatible API
5
+ Author: TheHiddenObserver
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/TheHiddenObserver/statgpu
8
+ Project-URL: Repository, https://github.com/TheHiddenObserver/statgpu
9
+ Keywords: statistics,gpu,cuda,machine-learning,sklearn
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
21
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.20
26
+ Requires-Dist: joblib>=1.0
27
+ Requires-Dist: scipy>=1.7
28
+ Provides-Extra: gpu11
29
+ Requires-Dist: cupy-cuda11x>=13.0; extra == "gpu11"
30
+ Provides-Extra: gpu12
31
+ Requires-Dist: cupy-cuda12x>=13.0; extra == "gpu12"
32
+ Provides-Extra: torch
33
+ Requires-Dist: torch>=2.0; extra == "torch"
34
+ Requires-Dist: scipy>=1.7; extra == "torch"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=6.0; extra == "dev"
37
+ Requires-Dist: black; extra == "dev"
38
+ Requires-Dist: flake8; extra == "dev"
39
+ Requires-Dist: mypy; extra == "dev"
40
+ Provides-Extra: validation
41
+ Requires-Dist: pytest>=6.0; extra == "validation"
42
+ Requires-Dist: scikit-learn>=1.0; extra == "validation"
43
+ Requires-Dist: statsmodels>=0.13; extra == "validation"
44
+ Provides-Extra: formula
45
+ Requires-Dist: patsy>=0.5.3; extra == "formula"
46
+ Requires-Dist: pandas>=1.5; extra == "formula"
47
+ Provides-Extra: cpu-ext
48
+ Requires-Dist: Cython>=3.0; extra == "cpu-ext"
49
+ Dynamic: license-file
50
+
51
+ # statgpu
52
+
53
+ [![PyPI version](https://img.shields.io/pypi/v/statgpu.svg)](https://pypi.org/project/statgpu/)
54
+ [![Python versions](https://img.shields.io/pypi/pyversions/statgpu.svg)](https://pypi.org/project/statgpu/)
55
+ [![License](https://img.shields.io/github/license/TheHiddenObserver/statgpu.svg)](https://github.com/TheHiddenObserver/statgpu/blob/master/LICENSE)
56
+ [![GitHub stars](https://img.shields.io/github/stars/TheHiddenObserver/statgpu.svg)](https://github.com/TheHiddenObserver/statgpu/stargazers)
57
+ [![Downloads](https://img.shields.io/pypi/dm/statgpu.svg)](https://pypi.org/project/statgpu/)
58
+
59
+ GPU-accelerated statistical methods with sklearn-compatible API.
60
+
61
+ ## Why statgpu?
62
+
63
+ | Feature | statgpu | sklearn | glmnet (R) |
64
+ |---------|---------|---------|------------|
65
+ | GPU acceleration | ✅ CuPy + PyTorch | ❌ | ❌ |
66
+ | 7 GLM families | ✅ | Partial | ✅ |
67
+ | 10 penalty types | ✅ (SCAD, MCP, Group) | L1/L2 only | L1/L2 only |
68
+ | sklearn API | ✅ | ✅ | ❌ |
69
+ | Debiased Lasso inference | ✅ | ❌ | ❌ |
70
+ | Cross-backend | ✅ NumPy/CuPy/Torch | NumPy only | R only |
71
+
72
+ ## Quick Start
73
+
74
+ ```python
75
+ import numpy as np
76
+ from statgpu.linear_model import Lasso, LassoCV, PenalizedGLM_CV
77
+
78
+ # Lasso with cross-validation
79
+ X, y = np.random.randn(1000, 50), np.random.randn(1000)
80
+ model = LassoCV(cv=5).fit(X, y)
81
+ print(f"Optimal alpha: {model.alpha_:.4f}")
82
+
83
+ # Penalized GLM: Poisson + SCAD on GPU
84
+ model = PenalizedGLM_CV(
85
+ loss="poisson", penalty="scad", cv=5, device="cuda"
86
+ ).fit(X, y_counts)
87
+ ```
88
+
89
+ ## Documentation
90
+
91
+ - **English docs**: [docs/en/](docs/en/) — full documentation index
92
+ - **Chinese docs**: [docs/](docs/) — 中文文档
93
+ - **Quickstart**: [Quickstart](docs/en/getting-started/quickstart.md)
94
+ - **GLM + Penalty**: [Generalized Linear Model](docs/en/models/generalized-linear-model.md) — 7 families × 10 penalties × 3 backends
95
+ - **Cross-Validation**: [Cross-Validation Guide](docs/en/guides/cross-validation.md) — PenalizedGLM_CV, LassoCV, RidgeCV
96
+ - **Solver-Penalty Matrix**: [Solver × Penalty](docs/en/guides/solver-penalty-matrix.md) — solver dispatch and penalty routing
97
+ - **Device & Memory**: [Device and GPU Memory](docs/en/guides/device-and-memory.md)
98
+ - **PyTorch Backend**: [PyTorch Backend](docs/en/guides/pytorch-backend.md)
99
+ - **Distribution API**: [Distribution API](docs/en/guides/distribution-api.md) — 15 distributions across 3 backends
100
+ - **Multiple Testing**: [Multiple Testing](docs/en/guides/multiple-testing-combine-pvalues.md) — p-value adjustment and combination
101
+ - **Changelog**: [Changelog](docs/en/changelog.md)
102
+
103
+ ## Features
104
+
105
+ - 🚀 **3 Backends**: NumPy (CPU), CuPy (CUDA), PyTorch (CUDA) — automatic device selection
106
+ - 🔧 **sklearn-compatible**: `fit`/`predict`/`score` API, `sklearn.base.clone()` supported
107
+ - 📊 **7 GLM Families**: squared_error, logistic, poisson, gamma, inverse_gaussian, negative_binomial, tweedie
108
+ - 🔥 **10 Penalties**: l1, l2, elasticnet, scad, mcp, adaptive_l1, group_lasso, group_mcp, group_scad
109
+ - ⚡ **6 Solvers**: exact, newton, lbfgs, irls, fista, fista_bb — `solver="auto"` selects optimal
110
+ - 🧮 **Inference**: HC0-HC3/HAC robust SE, debiased Lasso, bootstrap, simultaneous CI
111
+ - 📈 **Nonparametric**: KDE, kernel regression, B-splines, GAM
112
+ - 🧬 **Unsupervised**: PCA, KMeans, DBSCAN, GMM, UMAP, t-SNE (12 classes)
113
+ - 📐 **Distributions**: 15 distributions across 3 backends via `get_distribution()` — [API docs](docs/en/guides/distribution-api.md)
114
+ - 🧪 **Multiple Testing**: `adjust_pvalues` + `combine_pvalues` + `permutation_test`
115
+ - 🔥 **Cross-Validation**: PenalizedGLM_CV (all 7 losses × 10 penalties), RidgeCV, LassoCV, ElasticNetCV
116
+
117
+ ## Implemented Methods
118
+
119
+ > **[Full method list with solvers, penalties, link functions →](docs/en/guides/implemented-methods.md)**
120
+
121
+ | Category | Classes | Highlights |
122
+ |---|---|---|
123
+ | **Regression & GLM** | 12 classes | LinearRegression, Ridge, Lasso, ElasticNet, Logistic, Poisson, Gamma, InvGauss, NB, Tweedie, Ordered models |
124
+ | **Penalized GLM** | 8 classes | PenalizedGLM + 7 family wrappers (Linear, Logistic, Poisson, Gamma, InvGauss, NB, Tweedie) × 10 penalties × 6 solvers |
125
+ | **Cross-Validation** | 6 classes | RidgeCV, LassoCV, ElasticNetCV, LogisticCV, PenalizedGLM_CV, CoxPHCV |
126
+ | **ANOVA** | 1 function | `f_oneway` — GPU-accelerated |
127
+ | **Covariance** | 3 classes | EmpiricalCovariance, LedoitWolf, OAS |
128
+ | **Panel Data** | 2 classes | PanelOLS, RandomEffects |
129
+ | **Nonparametric** | 5 classes | KernelRidge, KernelRidgeCV, pairwise_kernels, bspline_basis, natural_cubic_spline_basis |
130
+ | **Semiparametric** | 1 class | GAM (penalized B-splines + GCV) |
131
+ | **Unsupervised** | 12 classes | PCA, SVD, NMF, UMAP, t-SNE, KMeans, DBSCAN, GMM, AgglomerativeClustering |
132
+ | **Survival** | 1 class | CoxPH (Breslow/Efron ties, robust SE) |
133
+ | **Feature Selection** | 2 functions | fixed-X / model-X knockoff filters |
134
+ | **Multiple Testing** | 3 functions | adjust_pvalues, combine_pvalues, permutation_test |
135
+
136
+ ## Installation
137
+
138
+ ```bash
139
+ # CPU only
140
+ pip install statgpu
141
+
142
+ # With GPU support (choose by CUDA major version)
143
+ # CUDA 11.x runtime:
144
+ pip install statgpu[gpu11]
145
+
146
+ # CUDA 12.x runtime:
147
+ pip install statgpu[gpu12]
148
+
149
+ # With PyTorch backend (CUDA 11.x)
150
+ pip install statgpu[torch]
151
+
152
+ # Development
153
+ pip install statgpu[dev]
154
+
155
+ # Formula interface
156
+ pip install statgpu[formula]
157
+ ```
158
+
159
+ ## Quick Start
160
+
161
+ ```python
162
+ import numpy as np
163
+ from statgpu.inference import norm, poisson
164
+ from statgpu.linear_model import LinearRegression, PenalizedGLM_CV
165
+ from statgpu import adjust_pvalues, combine_pvalues
166
+
167
+ # Generate data using statgpu distributions (scipy-compatible API)
168
+ X = norm.rvs(size=(10000, 100))
169
+ y = X @ norm.rvs(size=100) + norm.rvs(size=10000) * 0.5
170
+
171
+ # Linear regression with GPU
172
+ model = LinearRegression(device='cuda')
173
+ model.fit(X, y)
174
+ print(f"R²: {model.score(X, y):.4f}")
175
+
176
+ # Penalized GLM with cross-validation
177
+ y_pois = poisson.rvs(mu=np.exp(X[:, :5] @ np.ones(5) * 0.1), size=X.shape[0])
178
+ cv_model = PenalizedGLM_CV(
179
+ loss="poisson", penalty="elasticnet", l1_ratio=0.5,
180
+ cv=5, device="cpu",
181
+ )
182
+ cv_model.fit(X[:, :5], y_pois)
183
+ print(f"Best alpha: {cv_model.alpha_:.4f}")
184
+
185
+ # Multiple-testing correction
186
+ reject, pvals_adj = adjust_pvalues(np.array([0.003, 0.02, 0.5]), method='bh')
187
+
188
+ # Global p-value combination
189
+ stat, p_global = combine_pvalues(np.array([0.01, 0.07, 0.03, 0.40]), method='fisher')
190
+ ```
191
+
192
+ ## Device Control
193
+
194
+ ```python
195
+ import statgpu as sg
196
+
197
+ # Global setting
198
+ sg.set_device('cuda') # Force GPU
199
+ sg.set_device('cpu') # Force CPU
200
+ sg.set_device('auto') # Auto-detect (default)
201
+
202
+ # Per-model setting
203
+ from statgpu.linear_model import LinearRegression
204
+ model = LinearRegression(device='cuda', n_jobs=4)
205
+ ```
206
+
207
+ ## Benchmark Results (RTX 4090)
208
+
209
+ Full report: `dev/tests/_bench_realdata_report.md`
210
+
211
+ Test environment: RTX 4090 (24GB), CuPy 14.1.0, PyTorch 2.8.0+cu128, scikit-learn 1.8.0, statsmodels 0.14.6, lifelines 0.30.3
212
+
213
+ ### Real-Data Performance
214
+
215
+ | Module | Dataset | n | p | Best Speedup | Precision |
216
+ |--------|---------|---|---|-------------|-----------|
217
+ | Poisson GLM | freMTPL2 | 678K | 42 | 196.9x vs sklearn | coef_corr=1.000000 |
218
+ | Gamma GLM | synthetic | 678K | 42 | 97.9x vs sklearn | coef_corr=0.9995 |
219
+ | CoxPH | synthetic | 1.9K | 500 | 1.2x vs CPU | coef_corr=1.000 |
220
+ | adjust_pvalues (BH) | synthetic | — | 1M | 0.55x | 100% agreement |
221
+ | PenalizedPoisson(L1) | freMTPL2 | 678K | 42 | — | OK |
222
+ | PenalizedCoxPH(L2) | synthetic | 1.9K | 500 | — | C-index match |
223
+
224
+ ### Precision Summary
225
+
226
+ | Module | Metric | Result |
227
+ |--------|--------|--------|
228
+ | Poisson GLM | coef correlation vs sklearn | 1.000000 (full freMTPL2) |
229
+ | Gamma GLM | coef correlation vs sklearn | 0.9995 |
230
+ | CoxPH | coef correlation vs lifelines | 1.000 |
231
+ | adjust_pvalues (BH) | reject agreement vs statsmodels | 100% (100K to 5M p-values) |
232
+ | Penalized (L1/L2) | self-consistency | C-index match across penalties |
233
+
234
+ ## Requirements
235
+
236
+ - Python >= 3.8
237
+ - NumPy >= 1.20
238
+ - CuPy (optional, for GPU; choose wheel matching CUDA major version)
239
+ - CUDA 11.x: `cupy-cuda11x`
240
+ - CUDA 12.x: `cupy-cuda12x`
241
+ - CUDA runtime compatible with selected CuPy wheel
242
+
243
+ ## License
244
+
245
+ Apache License 2.0 — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,195 @@
1
+ # statgpu
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/statgpu.svg)](https://pypi.org/project/statgpu/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/statgpu.svg)](https://pypi.org/project/statgpu/)
5
+ [![License](https://img.shields.io/github/license/TheHiddenObserver/statgpu.svg)](https://github.com/TheHiddenObserver/statgpu/blob/master/LICENSE)
6
+ [![GitHub stars](https://img.shields.io/github/stars/TheHiddenObserver/statgpu.svg)](https://github.com/TheHiddenObserver/statgpu/stargazers)
7
+ [![Downloads](https://img.shields.io/pypi/dm/statgpu.svg)](https://pypi.org/project/statgpu/)
8
+
9
+ GPU-accelerated statistical methods with sklearn-compatible API.
10
+
11
+ ## Why statgpu?
12
+
13
+ | Feature | statgpu | sklearn | glmnet (R) |
14
+ |---------|---------|---------|------------|
15
+ | GPU acceleration | ✅ CuPy + PyTorch | ❌ | ❌ |
16
+ | 7 GLM families | ✅ | Partial | ✅ |
17
+ | 10 penalty types | ✅ (SCAD, MCP, Group) | L1/L2 only | L1/L2 only |
18
+ | sklearn API | ✅ | ✅ | ❌ |
19
+ | Debiased Lasso inference | ✅ | ❌ | ❌ |
20
+ | Cross-backend | ✅ NumPy/CuPy/Torch | NumPy only | R only |
21
+
22
+ ## Quick Start
23
+
24
+ ```python
25
+ import numpy as np
26
+ from statgpu.linear_model import Lasso, LassoCV, PenalizedGLM_CV
27
+
28
+ # Lasso with cross-validation
29
+ X, y = np.random.randn(1000, 50), np.random.randn(1000)
30
+ model = LassoCV(cv=5).fit(X, y)
31
+ print(f"Optimal alpha: {model.alpha_:.4f}")
32
+
33
+ # Penalized GLM: Poisson + SCAD on GPU
34
+ model = PenalizedGLM_CV(
35
+ loss="poisson", penalty="scad", cv=5, device="cuda"
36
+ ).fit(X, y_counts)
37
+ ```
38
+
39
+ ## Documentation
40
+
41
+ - **English docs**: [docs/en/](docs/en/) — full documentation index
42
+ - **Chinese docs**: [docs/](docs/) — 中文文档
43
+ - **Quickstart**: [Quickstart](docs/en/getting-started/quickstart.md)
44
+ - **GLM + Penalty**: [Generalized Linear Model](docs/en/models/generalized-linear-model.md) — 7 families × 10 penalties × 3 backends
45
+ - **Cross-Validation**: [Cross-Validation Guide](docs/en/guides/cross-validation.md) — PenalizedGLM_CV, LassoCV, RidgeCV
46
+ - **Solver-Penalty Matrix**: [Solver × Penalty](docs/en/guides/solver-penalty-matrix.md) — solver dispatch and penalty routing
47
+ - **Device & Memory**: [Device and GPU Memory](docs/en/guides/device-and-memory.md)
48
+ - **PyTorch Backend**: [PyTorch Backend](docs/en/guides/pytorch-backend.md)
49
+ - **Distribution API**: [Distribution API](docs/en/guides/distribution-api.md) — 15 distributions across 3 backends
50
+ - **Multiple Testing**: [Multiple Testing](docs/en/guides/multiple-testing-combine-pvalues.md) — p-value adjustment and combination
51
+ - **Changelog**: [Changelog](docs/en/changelog.md)
52
+
53
+ ## Features
54
+
55
+ - 🚀 **3 Backends**: NumPy (CPU), CuPy (CUDA), PyTorch (CUDA) — automatic device selection
56
+ - 🔧 **sklearn-compatible**: `fit`/`predict`/`score` API, `sklearn.base.clone()` supported
57
+ - 📊 **7 GLM Families**: squared_error, logistic, poisson, gamma, inverse_gaussian, negative_binomial, tweedie
58
+ - 🔥 **10 Penalties**: l1, l2, elasticnet, scad, mcp, adaptive_l1, group_lasso, group_mcp, group_scad
59
+ - ⚡ **6 Solvers**: exact, newton, lbfgs, irls, fista, fista_bb — `solver="auto"` selects optimal
60
+ - 🧮 **Inference**: HC0-HC3/HAC robust SE, debiased Lasso, bootstrap, simultaneous CI
61
+ - 📈 **Nonparametric**: KDE, kernel regression, B-splines, GAM
62
+ - 🧬 **Unsupervised**: PCA, KMeans, DBSCAN, GMM, UMAP, t-SNE (12 classes)
63
+ - 📐 **Distributions**: 15 distributions across 3 backends via `get_distribution()` — [API docs](docs/en/guides/distribution-api.md)
64
+ - 🧪 **Multiple Testing**: `adjust_pvalues` + `combine_pvalues` + `permutation_test`
65
+ - 🔥 **Cross-Validation**: PenalizedGLM_CV (all 7 losses × 10 penalties), RidgeCV, LassoCV, ElasticNetCV
66
+
67
+ ## Implemented Methods
68
+
69
+ > **[Full method list with solvers, penalties, link functions →](docs/en/guides/implemented-methods.md)**
70
+
71
+ | Category | Classes | Highlights |
72
+ |---|---|---|
73
+ | **Regression & GLM** | 12 classes | LinearRegression, Ridge, Lasso, ElasticNet, Logistic, Poisson, Gamma, InvGauss, NB, Tweedie, Ordered models |
74
+ | **Penalized GLM** | 8 classes | PenalizedGLM + 7 family wrappers (Linear, Logistic, Poisson, Gamma, InvGauss, NB, Tweedie) × 10 penalties × 6 solvers |
75
+ | **Cross-Validation** | 6 classes | RidgeCV, LassoCV, ElasticNetCV, LogisticCV, PenalizedGLM_CV, CoxPHCV |
76
+ | **ANOVA** | 1 function | `f_oneway` — GPU-accelerated |
77
+ | **Covariance** | 3 classes | EmpiricalCovariance, LedoitWolf, OAS |
78
+ | **Panel Data** | 2 classes | PanelOLS, RandomEffects |
79
+ | **Nonparametric** | 5 classes | KernelRidge, KernelRidgeCV, pairwise_kernels, bspline_basis, natural_cubic_spline_basis |
80
+ | **Semiparametric** | 1 class | GAM (penalized B-splines + GCV) |
81
+ | **Unsupervised** | 12 classes | PCA, SVD, NMF, UMAP, t-SNE, KMeans, DBSCAN, GMM, AgglomerativeClustering |
82
+ | **Survival** | 1 class | CoxPH (Breslow/Efron ties, robust SE) |
83
+ | **Feature Selection** | 2 functions | fixed-X / model-X knockoff filters |
84
+ | **Multiple Testing** | 3 functions | adjust_pvalues, combine_pvalues, permutation_test |
85
+
86
+ ## Installation
87
+
88
+ ```bash
89
+ # CPU only
90
+ pip install statgpu
91
+
92
+ # With GPU support (choose by CUDA major version)
93
+ # CUDA 11.x runtime:
94
+ pip install statgpu[gpu11]
95
+
96
+ # CUDA 12.x runtime:
97
+ pip install statgpu[gpu12]
98
+
99
+ # With PyTorch backend (CUDA 11.x)
100
+ pip install statgpu[torch]
101
+
102
+ # Development
103
+ pip install statgpu[dev]
104
+
105
+ # Formula interface
106
+ pip install statgpu[formula]
107
+ ```
108
+
109
+ ## Quick Start
110
+
111
+ ```python
112
+ import numpy as np
113
+ from statgpu.inference import norm, poisson
114
+ from statgpu.linear_model import LinearRegression, PenalizedGLM_CV
115
+ from statgpu import adjust_pvalues, combine_pvalues
116
+
117
+ # Generate data using statgpu distributions (scipy-compatible API)
118
+ X = norm.rvs(size=(10000, 100))
119
+ y = X @ norm.rvs(size=100) + norm.rvs(size=10000) * 0.5
120
+
121
+ # Linear regression with GPU
122
+ model = LinearRegression(device='cuda')
123
+ model.fit(X, y)
124
+ print(f"R²: {model.score(X, y):.4f}")
125
+
126
+ # Penalized GLM with cross-validation
127
+ y_pois = poisson.rvs(mu=np.exp(X[:, :5] @ np.ones(5) * 0.1), size=X.shape[0])
128
+ cv_model = PenalizedGLM_CV(
129
+ loss="poisson", penalty="elasticnet", l1_ratio=0.5,
130
+ cv=5, device="cpu",
131
+ )
132
+ cv_model.fit(X[:, :5], y_pois)
133
+ print(f"Best alpha: {cv_model.alpha_:.4f}")
134
+
135
+ # Multiple-testing correction
136
+ reject, pvals_adj = adjust_pvalues(np.array([0.003, 0.02, 0.5]), method='bh')
137
+
138
+ # Global p-value combination
139
+ stat, p_global = combine_pvalues(np.array([0.01, 0.07, 0.03, 0.40]), method='fisher')
140
+ ```
141
+
142
+ ## Device Control
143
+
144
+ ```python
145
+ import statgpu as sg
146
+
147
+ # Global setting
148
+ sg.set_device('cuda') # Force GPU
149
+ sg.set_device('cpu') # Force CPU
150
+ sg.set_device('auto') # Auto-detect (default)
151
+
152
+ # Per-model setting
153
+ from statgpu.linear_model import LinearRegression
154
+ model = LinearRegression(device='cuda', n_jobs=4)
155
+ ```
156
+
157
+ ## Benchmark Results (RTX 4090)
158
+
159
+ Full report: `dev/tests/_bench_realdata_report.md`
160
+
161
+ Test environment: RTX 4090 (24GB), CuPy 14.1.0, PyTorch 2.8.0+cu128, scikit-learn 1.8.0, statsmodels 0.14.6, lifelines 0.30.3
162
+
163
+ ### Real-Data Performance
164
+
165
+ | Module | Dataset | n | p | Best Speedup | Precision |
166
+ |--------|---------|---|---|-------------|-----------|
167
+ | Poisson GLM | freMTPL2 | 678K | 42 | 196.9x vs sklearn | coef_corr=1.000000 |
168
+ | Gamma GLM | synthetic | 678K | 42 | 97.9x vs sklearn | coef_corr=0.9995 |
169
+ | CoxPH | synthetic | 1.9K | 500 | 1.2x vs CPU | coef_corr=1.000 |
170
+ | adjust_pvalues (BH) | synthetic | — | 1M | 0.55x | 100% agreement |
171
+ | PenalizedPoisson(L1) | freMTPL2 | 678K | 42 | — | OK |
172
+ | PenalizedCoxPH(L2) | synthetic | 1.9K | 500 | — | C-index match |
173
+
174
+ ### Precision Summary
175
+
176
+ | Module | Metric | Result |
177
+ |--------|--------|--------|
178
+ | Poisson GLM | coef correlation vs sklearn | 1.000000 (full freMTPL2) |
179
+ | Gamma GLM | coef correlation vs sklearn | 0.9995 |
180
+ | CoxPH | coef correlation vs lifelines | 1.000 |
181
+ | adjust_pvalues (BH) | reject agreement vs statsmodels | 100% (100K to 5M p-values) |
182
+ | Penalized (L1/L2) | self-consistency | C-index match across penalties |
183
+
184
+ ## Requirements
185
+
186
+ - Python >= 3.8
187
+ - NumPy >= 1.20
188
+ - CuPy (optional, for GPU; choose wheel matching CUDA major version)
189
+ - CUDA 11.x: `cupy-cuda11x`
190
+ - CUDA 12.x: `cupy-cuda12x`
191
+ - CUDA runtime compatible with selected CuPy wheel
192
+
193
+ ## License
194
+
195
+ Apache License 2.0 — see [LICENSE](LICENSE) for details.