https://github.com/ceholden/pysmoothspl
Python wrapper around R's lovely `smooth.spline`
https://github.com/ceholden/pysmoothspl
cython-wrapper python r scikit-learn-api splines
Last synced: about 2 months ago
JSON representation
Python wrapper around R's lovely `smooth.spline`
- Host: GitHub
- URL: https://github.com/ceholden/pysmoothspl
- Owner: ceholden
- License: gpl-3.0
- Created: 2017-06-05T23:41:14.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-20T13:41:24.000Z (over 8 years ago)
- Last Synced: 2025-03-27T06:33:06.309Z (about 1 year ago)
- Topics: cython-wrapper, python, r, scikit-learn-api, splines
- Language: Python
- Size: 707 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pysmoothspl
Python wrapper around R's lovely `smooth.spline`
## Example
``` python
import matplotlib.pyplot as plt
import numpy as np
from pysmoothspl import SmoothSpline
n = 1000
x = np.arange(n).astype(np.float)
y = 100 + 50 * np.sin(2 * np.pi * x / 365.0) + np.random.normal(0, 25, n)
spl = SmoothSpline(spar=0.2).fit(x, y)
yhat = spl.predict(x)
spl_smoother = SmoothSpline(spar=0.5).fit(x, y)
yhat_smoother = spl_smoother.predict(x)
fig, ax = plt.subplots(1, figsize=(16, 9))
ax.plot(x, y, 'ro', label='Points')
ax.plot(x, yhat, 'g-', label='Less smooth')
ax.plot(x, yhat_smoother, 'b-', label='Smoother')
ax.legend()
fig.show()
```

## Install
You will need `Cython` (unless/until this repo includes the `*.c` files) and
`numpy`.
### Anaconda
There are two Conda `environment.yaml` files to help guide the installation:
1. `environment.yaml` contains just the needed packages for installation
2. `tests/environment.yaml` contains the packages needed to install and test
this package
## Tests
This package uses `py.test` to run tests, and you will also need `pandas`:
``` bash
py.test tests/
```
If `rpy2` is installed, the tests will actually calculate the expected values
of calculations using the copy of R it is installed against. For users without
`rpy2`, the test data also contains "cached" answers calculated using R code.
## TODO
* [x] Object oriented sklearn-esque estimator
* [ ] For function inputs: typed memory views > NumPy buffers
* [ ] Kill the GIL
* [ ] CI service tests
* [ ] Code coverage checks with CI
* [x] Check output against literal R output via rpy2
* [ ] Implement more features
* [ ] Cross validation
* [ ] Derivatives (hint: check `bvalue` code for commented out)
* [ ] Work back from fresh copy of R code...