Giter Site home page Giter Site logo

ceholden / pysmoothspl Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 1.0 724 KB

Python wrapper around R's lovely `smooth.spline`

License: GNU General Public License v3.0

Makefile 0.08% Python 68.52% C 31.41%
splines python r scikit-learn-api cython-wrapper

pysmoothspl's Introduction

pysmoothspl

Python wrapper around R's lovely smooth.spline

Example

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()

Example

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:

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

  • Object oriented sklearn-esque estimator
  • For function inputs: typed memory views > NumPy buffers
  • Kill the GIL
  • CI service tests
    • Code coverage checks with CI
  • 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...

pysmoothspl's People

Contributors

ceholden avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

oiwen

pysmoothspl's Issues

Guard against 0 length inputs

Commenting for later -- code segfaults Python if given x, y = np.array([]), np.array([]). Guard against this in Python part of wrapper and raise an exception

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.