geds-python 0.1.0a2__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.
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.5
2
+ Name: geds-python
3
+ Version: 0.1.0a2
4
+ Summary: Python estimators backed by the GeDS R package
5
+ Project-URL: Homepage, https://github.com/emilioluissaenzguillen/GeDS-python
6
+ Project-URL: Repository, https://github.com/emilioluissaenzguillen/GeDS-python
7
+ Project-URL: Issues, https://github.com/emilioluissaenzguillen/GeDS-python/issues
8
+ Project-URL: Changelog, https://github.com/emilioluissaenzguillen/GeDS-python/blob/main/CHANGELOG.md
9
+ Project-URL: R package, https://github.com/emilioluissaenzguillen/GeDS
10
+ Author: Dimitrina S. Dimitrova, Vladimir K. Kaishev, Andrea Lattuada, Emilio L. Sáenz Guillén, Richard J. Verrall
11
+ Maintainer-email: "Emilio L. Sáenz Guillén" <emilioluissaenzguillen@gmail.com>
12
+ License-Expression: GPL-3.0-only
13
+ License-File: LICENSE
14
+ Keywords: R,regression,scikit-learn,splines,statistics
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Scientific/Engineering
25
+ Requires-Python: >=3.10
26
+ Requires-Dist: numpy>=1.24
27
+ Requires-Dist: pandas>=2.0
28
+ Requires-Dist: rpy2<3.7,>=3.6.7
29
+ Requires-Dist: scikit-learn>=1.4
30
+ Provides-Extra: dev
31
+ Requires-Dist: build>=1.2; extra == 'dev'
32
+ Requires-Dist: pytest>=8; extra == 'dev'
33
+ Provides-Extra: plot
34
+ Requires-Dist: matplotlib>=3.8; extra == 'plot'
35
+ Provides-Extra: test
36
+ Requires-Dist: pytest>=8; extra == 'test'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # GeDS for Python
40
+
41
+ This package provides a Python interface to the
42
+ [GeDS R package](https://github.com/emilioluissaenzguillen/GeDS). The R package
43
+ is the sole implementation of the statistical methods. Python supplies a
44
+ scikit-learn-style API, pandas/NumPy conversion, environment diagnostics, and
45
+ model serialization.
46
+
47
+ ## Requirements
48
+
49
+ - R 4.4 or newer (R 4.6.1 is used for development)
50
+ - GeDS 0.3.6 or newer
51
+ - Python 3.10 or newer
52
+
53
+ Install the Python package, including the optional plotting dependency used in
54
+ the example:
55
+
56
+ ```console
57
+ python -m pip install "geds-python[plot]"
58
+ ```
59
+
60
+ Install the R package separately, using R 4.6.1 or another supported R
61
+ installation:
62
+
63
+ ```r
64
+ install.packages("GeDS")
65
+ ```
66
+
67
+ The wrapper discovers the newest R installation under `Program Files/R` on
68
+ Windows or uses `Rscript` from `PATH` on other platforms. Set `R_HOME` to select
69
+ a particular R installation. If GeDS is installed in a non-default R library,
70
+ set `GEDS_R_LIBRARY` to that library directory before importing `geds`.
71
+
72
+ The Python and R packages have independent release cycles. `geds-python`
73
+ checks the installed GeDS version when its backend first starts and reports the
74
+ selected R installation and package library through `geds.diagnostics()`.
75
+
76
+ Check the backend before fitting:
77
+
78
+ ```python
79
+ import geds
80
+
81
+ print(geds.diagnostics())
82
+ ```
83
+
84
+ ## Example
85
+
86
+ Install the optional plotting dependency with
87
+ `python -m pip install "geds-python[plot]"`, then fit and visualize a nonlinear
88
+ regression:
89
+
90
+ ```python
91
+ import matplotlib.pyplot as plt
92
+ import numpy as np
93
+ import pandas as pd
94
+
95
+ from geds import GeDSRegressor
96
+
97
+ rng = np.random.RandomState(123)
98
+ n = 500
99
+
100
+
101
+ def f_1(x):
102
+ return (10 * x / (1 + 100 * x**2)) * 4 + 4
103
+
104
+
105
+ x = np.sort(rng.uniform(-2.0, 2.0, size=n))
106
+ means = f_1(x)
107
+ y = rng.normal(means, scale=0.1)
108
+ X = pd.DataFrame({"x": x})
109
+
110
+ model = GeDSRegressor(order=3).fit(X, y)
111
+ grid_x = np.linspace(x.min(), x.max(), 500)
112
+ grid = pd.DataFrame({"x": grid_x})
113
+ fitted = model.predict(grid)
114
+ knots = np.asarray(model.knots_, dtype=float)
115
+
116
+ print("Internal knots:", knots)
117
+
118
+ fig, ax = plt.subplots()
119
+ ax.scatter(x, y, s=12, alpha=0.35, label="Data")
120
+ ax.plot(
121
+ grid_x,
122
+ f_1(grid_x),
123
+ color="0.25",
124
+ linestyle=":",
125
+ linewidth=2,
126
+ label="True mean",
127
+ )
128
+ ax.plot(grid_x, fitted, linewidth=2, label="GeDS fit")
129
+ for index, knot in enumerate(knots):
130
+ ax.axvline(
131
+ knot,
132
+ color="tab:red",
133
+ linestyle="--",
134
+ alpha=0.55,
135
+ label="Internal knots" if index == 0 else None,
136
+ )
137
+ ax.set(xlabel="x", ylabel="y", title="GeDS spline regression")
138
+ ax.legend()
139
+ fig.tight_layout()
140
+ plt.show()
141
+ ```
142
+
143
+ With GeDS 0.3.6 and R 4.6.1, this seeded example fits 16 internal knots.
144
+ The dashed vertical lines show how GeDS places more knots around the sharp
145
+ variation near zero while retaining knots across the wider domain.
146
+
147
+ `GeDSRegressor` delegates to `GeDS::NGeDS()`. For exponential-family models,
148
+ use `GeDSGeneralizedRegressor`, which delegates to `GeDS::GGeDS()`.
149
+
150
+ Choose spline and parametric components explicitly for mixed data:
151
+
152
+ ```python
153
+ model = GeDSRegressor(
154
+ spline_features=["x"],
155
+ linear_features=["group"],
156
+ ).fit(X, y)
157
+ ```
158
+
159
+ Spline features must be numeric. Parametric features may be numeric or
160
+ categorical; their encoding is performed by the R package so fitting and
161
+ prediction use R's native factor semantics.
162
+
163
+ Fitted estimators contain a serialized R model and can be saved with
164
+ `model.save(path)` and restored with `GeDSRegressor.load(path)`. As with any
165
+ pickle-based format, only load files from trusted sources.
166
+
167
+ ## Development
168
+
169
+ Clone the repository, then install the development dependencies and run the
170
+ integration tests with:
171
+
172
+ ```console
173
+ git clone https://github.com/emilioluissaenzguillen/GeDS-python.git
174
+ cd GeDS-python
175
+ python -m pip install -e ".[dev]"
176
+ python -m pytest
177
+ python -m build
178
+ ```
179
+
180
+ The tests start an embedded R session and therefore require a working GeDS
181
+ installation; they do not substitute or reimplement any GeDS calculations.
182
+
183
+ ## Contact
184
+
185
+ For questions about the Python interface, contact Emilio L. Sáenz Guillén at
186
+ [emilioluissaenzguillen@gmail.com](mailto:emilioluissaenzguillen@gmail.com).
@@ -0,0 +1,8 @@
1
+ geds/__init__.py,sha256=1ZZfYqNwv16nJyMhyTPsEjZ1s0ZswD1DYfT8w2xs9vA,311
2
+ geds/_backend.py,sha256=LpxSNTr417Ru4au5w8N-LrgP05nLCuaDMMv5G8tDowQ,10740
3
+ geds/_estimators.py,sha256=Fpt_TWrGjr_IzBJ8sk1X0dmA6m5yODdV0Ac3iRWIkI0,15051
4
+ geds/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
+ geds_python-0.1.0a2.dist-info/METADATA,sha256=5_n2_utWwUlpU3SJFqvmhX2OjRTJNKTZYm_vzjACncE,5902
6
+ geds_python-0.1.0a2.dist-info/WHEEL,sha256=THafob7ofN-NsuMN7Mg4qZyHaQI7KkD-QlcQatYhXPo,87
7
+ geds_python-0.1.0a2.dist-info/licenses/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
8
+ geds_python-0.1.0a2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.3
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any