statgpu 0.1.0__py3-none-any.whl

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 (168) hide show
  1. statgpu/__init__.py +174 -0
  2. statgpu/_base.py +544 -0
  3. statgpu/_config.py +127 -0
  4. statgpu/anova/__init__.py +5 -0
  5. statgpu/anova/_oneway.py +194 -0
  6. statgpu/backends/__init__.py +83 -0
  7. statgpu/backends/_array_ops.py +529 -0
  8. statgpu/backends/_base.py +184 -0
  9. statgpu/backends/_cupy.py +453 -0
  10. statgpu/backends/_factory.py +65 -0
  11. statgpu/backends/_gpu_inference_cupy.py +214 -0
  12. statgpu/backends/_gpu_inference_torch.py +422 -0
  13. statgpu/backends/_numpy.py +324 -0
  14. statgpu/backends/_torch.py +685 -0
  15. statgpu/backends/_torch_safe.py +47 -0
  16. statgpu/backends/_utils.py +423 -0
  17. statgpu/core/__init__.py +10 -0
  18. statgpu/core/formula/__init__.py +33 -0
  19. statgpu/core/formula/_design.py +99 -0
  20. statgpu/core/formula/_parser.py +191 -0
  21. statgpu/core/formula/_terms.py +70 -0
  22. statgpu/core/formula/tests/__init__.py +0 -0
  23. statgpu/core/formula/tests/test_parser.py +194 -0
  24. statgpu/covariance/__init__.py +6 -0
  25. statgpu/covariance/_empirical.py +310 -0
  26. statgpu/covariance/_shrinkage.py +248 -0
  27. statgpu/cross_validation/__init__.py +31 -0
  28. statgpu/cross_validation/_base.py +410 -0
  29. statgpu/cross_validation/_engine.py +167 -0
  30. statgpu/diagnostics/__init__.py +7 -0
  31. statgpu/diagnostics/_regression_diagnostics.py +188 -0
  32. statgpu/feature_selection/__init__.py +24 -0
  33. statgpu/feature_selection/_knockoff.py +870 -0
  34. statgpu/feature_selection/_knockoff_utils.py +1003 -0
  35. statgpu/feature_selection/_stepwise.py +300 -0
  36. statgpu/glm_core/__init__.py +81 -0
  37. statgpu/glm_core/_base.py +202 -0
  38. statgpu/glm_core/_family.py +362 -0
  39. statgpu/glm_core/_fused.py +149 -0
  40. statgpu/glm_core/_gamma.py +111 -0
  41. statgpu/glm_core/_inverse_gaussian.py +62 -0
  42. statgpu/glm_core/_irls.py +561 -0
  43. statgpu/glm_core/_logistic.py +82 -0
  44. statgpu/glm_core/_negative_binomial.py +68 -0
  45. statgpu/glm_core/_poisson.py +60 -0
  46. statgpu/glm_core/_solver_legacy.py +100 -0
  47. statgpu/glm_core/_squared.py +53 -0
  48. statgpu/glm_core/_tweedie.py +74 -0
  49. statgpu/inference/__init__.py +239 -0
  50. statgpu/inference/_distributions_backend.py +2610 -0
  51. statgpu/inference/_multiple_testing.py +391 -0
  52. statgpu/inference/_resampling.py +1400 -0
  53. statgpu/inference/_results.py +265 -0
  54. statgpu/linear_model/__init__.py +75 -0
  55. statgpu/linear_model/_gaussian_inference.py +306 -0
  56. statgpu/linear_model/_glm_base.py +1261 -0
  57. statgpu/linear_model/_ordered_logit.py +52 -0
  58. statgpu/linear_model/_ordered_probit.py +50 -0
  59. statgpu/linear_model/_stats.py +170 -0
  60. statgpu/linear_model/cv/__init__.py +13 -0
  61. statgpu/linear_model/cv/_elasticnet_cv.py +892 -0
  62. statgpu/linear_model/cv/_lasso_cv.py +253 -0
  63. statgpu/linear_model/cv/_logistic_cv.py +895 -0
  64. statgpu/linear_model/cv/_ridge_cv.py +1160 -0
  65. statgpu/linear_model/legacy/__init__.py +1 -0
  66. statgpu/linear_model/legacy/_distributions_legacy_gpu.py +340 -0
  67. statgpu/linear_model/legacy/_elasticnet_legacy.py +936 -0
  68. statgpu/linear_model/legacy/_lasso_legacy.py +4876 -0
  69. statgpu/linear_model/legacy/_penalized_legacy.py +1174 -0
  70. statgpu/linear_model/legacy/_ridge_legacy.py +863 -0
  71. statgpu/linear_model/legacy/_solver_legacy.py +104 -0
  72. statgpu/linear_model/penalized/__init__.py +25 -0
  73. statgpu/linear_model/penalized/_base.py +437 -0
  74. statgpu/linear_model/penalized/_fit_mixin.py +1877 -0
  75. statgpu/linear_model/penalized/_inference_mixin.py +1179 -0
  76. statgpu/linear_model/penalized/_penalized_cv.py +2699 -0
  77. statgpu/linear_model/penalized/_penalized_gamma.py +86 -0
  78. statgpu/linear_model/penalized/_penalized_inverse_gaussian.py +62 -0
  79. statgpu/linear_model/penalized/_penalized_linear.py +236 -0
  80. statgpu/linear_model/penalized/_penalized_logistic.py +100 -0
  81. statgpu/linear_model/penalized/_penalized_negative_binomial.py +65 -0
  82. statgpu/linear_model/penalized/_penalized_poisson.py +62 -0
  83. statgpu/linear_model/penalized/_penalized_tweedie.py +65 -0
  84. statgpu/linear_model/penalized/_predict_mixin.py +182 -0
  85. statgpu/linear_model/wrappers/__init__.py +31 -0
  86. statgpu/linear_model/wrappers/_adaptive_lasso.py +63 -0
  87. statgpu/linear_model/wrappers/_elasticnet.py +75 -0
  88. statgpu/linear_model/wrappers/_gamma.py +67 -0
  89. statgpu/linear_model/wrappers/_inverse_gaussian.py +47 -0
  90. statgpu/linear_model/wrappers/_lasso.py +2124 -0
  91. statgpu/linear_model/wrappers/_linear.py +1127 -0
  92. statgpu/linear_model/wrappers/_logistic.py +1435 -0
  93. statgpu/linear_model/wrappers/_mcp.py +58 -0
  94. statgpu/linear_model/wrappers/_negative_binomial.py +58 -0
  95. statgpu/linear_model/wrappers/_poisson.py +48 -0
  96. statgpu/linear_model/wrappers/_ridge.py +166 -0
  97. statgpu/linear_model/wrappers/_scad.py +58 -0
  98. statgpu/linear_model/wrappers/_tweedie.py +57 -0
  99. statgpu/metrics/__init__.py +21 -0
  100. statgpu/metrics/_classification.py +591 -0
  101. statgpu/nonparametric/__init__.py +50 -0
  102. statgpu/nonparametric/kernel_methods/__init__.py +25 -0
  103. statgpu/nonparametric/kernel_methods/_kernels.py +246 -0
  104. statgpu/nonparametric/kernel_methods/_krr.py +234 -0
  105. statgpu/nonparametric/kernel_methods/_krr_cv.py +380 -0
  106. statgpu/nonparametric/kernel_smoothing/__init__.py +39 -0
  107. statgpu/nonparametric/kernel_smoothing/_bandwidth_selection.py +1083 -0
  108. statgpu/nonparametric/kernel_smoothing/_kde.py +761 -0
  109. statgpu/nonparametric/kernel_smoothing/_kernel_common.py +348 -0
  110. statgpu/nonparametric/kernel_smoothing/_kernel_regression.py +748 -0
  111. statgpu/nonparametric/splines/__init__.py +5 -0
  112. statgpu/nonparametric/splines/_bspline_basis.py +336 -0
  113. statgpu/nonparametric/splines/_penalized.py +349 -0
  114. statgpu/panel/__init__.py +19 -0
  115. statgpu/panel/_covariance.py +140 -0
  116. statgpu/panel/_fixed_effects.py +420 -0
  117. statgpu/panel/_random_effects.py +385 -0
  118. statgpu/panel/_utils.py +482 -0
  119. statgpu/penalties/__init__.py +139 -0
  120. statgpu/penalties/_adaptive_l1.py +313 -0
  121. statgpu/penalties/_base.py +261 -0
  122. statgpu/penalties/_categories.py +39 -0
  123. statgpu/penalties/_elasticnet.py +98 -0
  124. statgpu/penalties/_group_lasso.py +678 -0
  125. statgpu/penalties/_group_mcp.py +553 -0
  126. statgpu/penalties/_group_scad.py +605 -0
  127. statgpu/penalties/_l1.py +107 -0
  128. statgpu/penalties/_l2.py +77 -0
  129. statgpu/penalties/_mcp.py +237 -0
  130. statgpu/penalties/_scad.py +260 -0
  131. statgpu/semiparametric/__init__.py +5 -0
  132. statgpu/semiparametric/_gam.py +401 -0
  133. statgpu/solvers/__init__.py +24 -0
  134. statgpu/solvers/_admm.py +241 -0
  135. statgpu/solvers/_constants.py +15 -0
  136. statgpu/solvers/_convergence.py +6 -0
  137. statgpu/solvers/_fista.py +436 -0
  138. statgpu/solvers/_fista_bb.py +513 -0
  139. statgpu/solvers/_fista_lla.py +541 -0
  140. statgpu/solvers/_lbfgs.py +206 -0
  141. statgpu/solvers/_newton.py +149 -0
  142. statgpu/solvers/_utils.py +277 -0
  143. statgpu/survival/__init__.py +14 -0
  144. statgpu/survival/_cox.py +3974 -0
  145. statgpu/survival/_cox_breslow_triton_kernel.py +106 -0
  146. statgpu/survival/_cox_cv.py +1159 -0
  147. statgpu/survival/_cox_efron_cuda.py +1280 -0
  148. statgpu/survival/_cox_efron_triton.py +359 -0
  149. statgpu/unsupervised/__init__.py +29 -0
  150. statgpu/unsupervised/_agglomerative.py +307 -0
  151. statgpu/unsupervised/_dbscan.py +263 -0
  152. statgpu/unsupervised/_dbscan_cpu.pyx +125 -0
  153. statgpu/unsupervised/_gmm.py +332 -0
  154. statgpu/unsupervised/_incremental_pca.py +176 -0
  155. statgpu/unsupervised/_kmeans.py +261 -0
  156. statgpu/unsupervised/_minibatch_kmeans.py +299 -0
  157. statgpu/unsupervised/_minibatch_nmf.py +252 -0
  158. statgpu/unsupervised/_nmf.py +190 -0
  159. statgpu/unsupervised/_pca.py +189 -0
  160. statgpu/unsupervised/_truncated_svd.py +132 -0
  161. statgpu/unsupervised/_tsne.py +192 -0
  162. statgpu/unsupervised/_umap.py +224 -0
  163. statgpu/unsupervised/_utils.py +134 -0
  164. statgpu-0.1.0.dist-info/METADATA +245 -0
  165. statgpu-0.1.0.dist-info/RECORD +168 -0
  166. statgpu-0.1.0.dist-info/WHEEL +5 -0
  167. statgpu-0.1.0.dist-info/licenses/LICENSE +199 -0
  168. statgpu-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1 @@
1
+ """Legacy implementations kept for reference. Not part of public API."""
@@ -0,0 +1,340 @@
1
+ """Function-style distribution compatibility API.
2
+
3
+ This module keeps backward compatibility while the canonical API is object-
4
+ based (for example ``norm.cdf`` and ``t.ppf``).
5
+
6
+ Policy:
7
+ - R-style compatibility names (for example ``pnorm_gpu`` / ``qnorm_gpu``) are
8
+ retained as compatibility aliases.
9
+ - Non-R historical names (for example ``norm_cdf_gpu`` / ``t_ppf_gpu``) are
10
+ legacy and emit ``DeprecationWarning``.
11
+ """
12
+
13
+ import warnings
14
+
15
+
16
+ def _warn_deprecated(name: str, replacement: str):
17
+ warnings.warn(
18
+ (
19
+ f"`{name}` is deprecated and will be removed in a future release; "
20
+ f"use `{replacement}` instead."
21
+ ),
22
+ category=DeprecationWarning,
23
+ stacklevel=2,
24
+ )
25
+
26
+
27
+ def t_cdf_gpu(x, df):
28
+ _warn_deprecated("t_cdf_gpu", "t.cdf")
29
+ from statgpu.inference._distributions_backend import t
30
+
31
+ return t.cdf(x, df=df)
32
+
33
+
34
+ def t_sf_gpu(x, df):
35
+ _warn_deprecated("t_sf_gpu", "t.sf")
36
+ from statgpu.inference._distributions_backend import t
37
+
38
+ return t.sf(x, df=df)
39
+
40
+
41
+ def t_ppf_gpu(q, df, *, max_bisect_steps=60):
42
+ _warn_deprecated("t_ppf_gpu", "t.ppf")
43
+ from statgpu.inference._distributions_backend import t
44
+
45
+ return t.ppf(q, df=df, max_bisect_steps=max_bisect_steps)
46
+
47
+
48
+ def t_two_sided_pvalue_gpu(stat_abs, df):
49
+ _warn_deprecated("t_two_sided_pvalue_gpu", "t.two_sided_pvalue")
50
+ from statgpu.inference._distributions_backend import t
51
+
52
+ return t.two_sided_pvalue(stat_abs, df=df)
53
+
54
+
55
+ def t_two_sided_critical_value_gpu(alpha, df, *, max_bisect_steps=60):
56
+ _warn_deprecated("t_two_sided_critical_value_gpu", "t.two_sided_critical_value")
57
+ from statgpu.inference._distributions_backend import t
58
+
59
+ return t.two_sided_critical_value(alpha, df=df, max_bisect_steps=max_bisect_steps)
60
+
61
+
62
+ def norm_cdf_gpu(x):
63
+ _warn_deprecated("norm_cdf_gpu", "norm.cdf")
64
+ from statgpu.inference._distributions_backend import norm
65
+
66
+ return norm.cdf(x)
67
+
68
+
69
+ def norm_sf_gpu(x):
70
+ _warn_deprecated("norm_sf_gpu", "norm.sf")
71
+ from statgpu.inference._distributions_backend import norm
72
+
73
+ return norm.sf(x)
74
+
75
+
76
+ def norm_ppf_gpu(q):
77
+ _warn_deprecated("norm_ppf_gpu", "norm.ppf")
78
+ from statgpu.inference._distributions_backend import norm
79
+
80
+ return norm.ppf(q)
81
+
82
+
83
+ def norm_isf_gpu(q):
84
+ _warn_deprecated("norm_isf_gpu", "norm.isf")
85
+ from statgpu.inference._distributions_backend import norm
86
+
87
+ return norm.isf(q)
88
+
89
+
90
+ def norm_two_sided_pvalue_gpu(stat_abs):
91
+ _warn_deprecated("norm_two_sided_pvalue_gpu", "norm.two_sided_pvalue")
92
+ from statgpu.inference._distributions_backend import norm
93
+
94
+ return norm.two_sided_pvalue(stat_abs)
95
+
96
+
97
+ def norm_two_sided_critical_value_gpu(alpha):
98
+ _warn_deprecated("norm_two_sided_critical_value_gpu", "norm.two_sided_critical_value")
99
+ from statgpu.inference._distributions_backend import norm
100
+
101
+ return norm.two_sided_critical_value(alpha)
102
+
103
+
104
+ def rnorm_gpu(size=None, loc=0.0, scale=1.0, dtype=None):
105
+ from statgpu.inference._distributions_backend import norm
106
+
107
+ return norm.rvs(size=size, loc=loc, scale=scale, dtype=dtype)
108
+
109
+
110
+ def dnorm_gpu(x, *, loc=0.0, scale=1.0):
111
+ from statgpu.inference._distributions_backend import norm
112
+
113
+ return norm.pdf(x, loc=loc, scale=scale)
114
+
115
+
116
+ def dt_gpu(x, df, *, loc=0.0, scale=1.0):
117
+ from statgpu.inference._distributions_backend import t
118
+
119
+ return t.pdf(x, df=df, loc=loc, scale=scale)
120
+
121
+
122
+ def rt_gpu(df, size=None, dtype=None):
123
+ from statgpu.inference._distributions_backend import t
124
+
125
+ return t.rvs(df=df, size=size, dtype=dtype)
126
+
127
+
128
+ def pnorm_gpu(x):
129
+ from statgpu.inference._distributions_backend import norm
130
+
131
+ return norm.cdf(x)
132
+
133
+
134
+ def qnorm_gpu(q):
135
+ from statgpu.inference._distributions_backend import norm
136
+
137
+ return norm.ppf(q)
138
+
139
+
140
+ def pt_gpu(x, df):
141
+ from statgpu.inference._distributions_backend import t
142
+
143
+ return t.cdf(x, df=df)
144
+
145
+
146
+ def qt_gpu(q, df, *, max_bisect_steps=60):
147
+ from statgpu.inference._distributions_backend import t
148
+
149
+ return t.ppf(q, df=df, max_bisect_steps=max_bisect_steps)
150
+
151
+
152
+ def dchisq_gpu(x, *shape_args, **kwargs):
153
+ from statgpu.inference._distributions_backend import chi2
154
+
155
+ return chi2.pdf(x, *shape_args, **kwargs)
156
+
157
+
158
+ def pchisq_gpu(x, *shape_args, **kwargs):
159
+ from statgpu.inference._distributions_backend import chi2
160
+
161
+ return chi2.cdf(x, *shape_args, **kwargs)
162
+
163
+
164
+ def qchisq_gpu(q, *shape_args, **kwargs):
165
+ from statgpu.inference._distributions_backend import chi2
166
+
167
+ return chi2.ppf(q, *shape_args, **kwargs)
168
+
169
+
170
+ def rchisq_gpu(*shape_args, **kwargs):
171
+ from statgpu.inference._distributions_backend import chi2
172
+
173
+ return chi2.rvs(*shape_args, **kwargs)
174
+
175
+
176
+ def dgamma_gpu(x, *shape_args, **kwargs):
177
+ from statgpu.inference._distributions_backend import gamma
178
+
179
+ return gamma.pdf(x, *shape_args, **kwargs)
180
+
181
+
182
+ def pgamma_gpu(x, *shape_args, **kwargs):
183
+ from statgpu.inference._distributions_backend import gamma
184
+
185
+ return gamma.cdf(x, *shape_args, **kwargs)
186
+
187
+
188
+ def qgamma_gpu(q, *shape_args, **kwargs):
189
+ from statgpu.inference._distributions_backend import gamma
190
+
191
+ return gamma.ppf(q, *shape_args, **kwargs)
192
+
193
+
194
+ def rgamma_gpu(*shape_args, **kwargs):
195
+ from statgpu.inference._distributions_backend import gamma
196
+
197
+ return gamma.rvs(*shape_args, **kwargs)
198
+
199
+
200
+ def dbeta_gpu(x, *shape_args, **kwargs):
201
+ from statgpu.inference._distributions_backend import beta
202
+
203
+ return beta.pdf(x, *shape_args, **kwargs)
204
+
205
+
206
+ def pbeta_gpu(x, *shape_args, **kwargs):
207
+ from statgpu.inference._distributions_backend import beta
208
+
209
+ return beta.cdf(x, *shape_args, **kwargs)
210
+
211
+
212
+ def qbeta_gpu(q, *shape_args, **kwargs):
213
+ from statgpu.inference._distributions_backend import beta
214
+
215
+ return beta.ppf(q, *shape_args, **kwargs)
216
+
217
+
218
+ def rbeta_gpu(*shape_args, **kwargs):
219
+ from statgpu.inference._distributions_backend import beta
220
+
221
+ return beta.rvs(*shape_args, **kwargs)
222
+
223
+
224
+ def df_gpu(x, *shape_args, **kwargs):
225
+ from statgpu.inference._distributions_backend import f
226
+
227
+ return f.pdf(x, *shape_args, **kwargs)
228
+
229
+
230
+ def pf_gpu(x, *shape_args, **kwargs):
231
+ from statgpu.inference._distributions_backend import f
232
+
233
+ return f.cdf(x, *shape_args, **kwargs)
234
+
235
+
236
+ def qf_gpu(q, *shape_args, **kwargs):
237
+ from statgpu.inference._distributions_backend import f
238
+
239
+ return f.ppf(q, *shape_args, **kwargs)
240
+
241
+
242
+ def rf_gpu(*shape_args, **kwargs):
243
+ from statgpu.inference._distributions_backend import f
244
+
245
+ return f.rvs(*shape_args, **kwargs)
246
+
247
+
248
+ def dpois_gpu(k, *shape_args, **kwargs):
249
+ from statgpu.inference._distributions_backend import poisson
250
+
251
+ return poisson.pmf(k, *shape_args, **kwargs)
252
+
253
+
254
+ def ppois_gpu(k, *shape_args, **kwargs):
255
+ from statgpu.inference._distributions_backend import poisson
256
+
257
+ return poisson.cdf(k, *shape_args, **kwargs)
258
+
259
+
260
+ def qpois_gpu(q, *shape_args, **kwargs):
261
+ from statgpu.inference._distributions_backend import poisson
262
+
263
+ return poisson.ppf(q, *shape_args, **kwargs)
264
+
265
+
266
+ def rpois_gpu(*shape_args, **kwargs):
267
+ from statgpu.inference._distributions_backend import poisson
268
+
269
+ return poisson.rvs(*shape_args, **kwargs)
270
+
271
+
272
+ def dbinom_gpu(k, *shape_args, **kwargs):
273
+ from statgpu.inference._distributions_backend import binom
274
+
275
+ return binom.pmf(k, *shape_args, **kwargs)
276
+
277
+
278
+ def pbinom_gpu(k, *shape_args, **kwargs):
279
+ from statgpu.inference._distributions_backend import binom
280
+
281
+ return binom.cdf(k, *shape_args, **kwargs)
282
+
283
+
284
+ def qbinom_gpu(q, *shape_args, **kwargs):
285
+ from statgpu.inference._distributions_backend import binom
286
+
287
+ return binom.ppf(q, *shape_args, **kwargs)
288
+
289
+
290
+ def rbinom_gpu(*shape_args, **kwargs):
291
+ from statgpu.inference._distributions_backend import binom
292
+
293
+ return binom.rvs(*shape_args, **kwargs)
294
+
295
+
296
+ __all__ = [
297
+ "t_cdf_gpu",
298
+ "t_sf_gpu",
299
+ "t_ppf_gpu",
300
+ "t_two_sided_pvalue_gpu",
301
+ "t_two_sided_critical_value_gpu",
302
+ "norm_cdf_gpu",
303
+ "norm_sf_gpu",
304
+ "norm_ppf_gpu",
305
+ "norm_isf_gpu",
306
+ "norm_two_sided_pvalue_gpu",
307
+ "norm_two_sided_critical_value_gpu",
308
+ "rnorm_gpu",
309
+ "dnorm_gpu",
310
+ "dt_gpu",
311
+ "rt_gpu",
312
+ "pnorm_gpu",
313
+ "qnorm_gpu",
314
+ "pt_gpu",
315
+ "qt_gpu",
316
+ "dchisq_gpu",
317
+ "pchisq_gpu",
318
+ "qchisq_gpu",
319
+ "rchisq_gpu",
320
+ "dgamma_gpu",
321
+ "pgamma_gpu",
322
+ "qgamma_gpu",
323
+ "rgamma_gpu",
324
+ "dbeta_gpu",
325
+ "pbeta_gpu",
326
+ "qbeta_gpu",
327
+ "rbeta_gpu",
328
+ "df_gpu",
329
+ "pf_gpu",
330
+ "qf_gpu",
331
+ "rf_gpu",
332
+ "dpois_gpu",
333
+ "ppois_gpu",
334
+ "qpois_gpu",
335
+ "rpois_gpu",
336
+ "dbinom_gpu",
337
+ "pbinom_gpu",
338
+ "qbinom_gpu",
339
+ "rbinom_gpu",
340
+ ]