Skip to main content

Framework for fitting functions to data with SciPy

Project description

Fitting SciKit

A framework for fitting functions to data with SciPy which unifies the various available interpolation methods and provides a common interface to them based on the following simple methods:

  • Fitter.__init__(p): set parameters of interpolation function, e.g. polynomial degree

  • Fitter.fit(x, y): fit given input-output data

  • Fitter.__call__(x) or Fitter.eval(x): evaluate function on new input data

Each interpolation routine falls in one of two categories: scatter fitting or grid fitting. They share the same interface, only differing in the definition of input data x.

Scatter-fitters operate on unstructured scattered input data (i.e. not on a grid). The input data consists of a sequence of x coordinates and a sequence of corresponding y data, where the order of the x coordinates does not matter and their location can be arbitrary. The x coordinates can have an arbritrary dimension (although most classes are specialised for 1-D or 2-D data). If the dimension is bigger than 1, the coordinates are provided as an array of column vectors. These fitters have ScatterFit as base class.

Grid-fitters operate on input data that lie on a grid. The input data consists of a sequence of x-axis tick sequences and the corresponding array of y data. These fitters have GridFit as base class.

The module is organised as follows:

Scatter fitters

  • ScatterFit: Abstract base class for scatter fitters

  • LinearLeastSquaresFit: Fit linear regression model to data using SVD

  • Polynomial1DFit: Fit polynomial to 1-D data

  • Polynomial2DFit: Fit polynomial to 2-D data

  • PiecewisePolynomial1DFit: Fit piecewise polynomial to 1-D data

  • Independent1DFit: Interpolate N-dimensional matrix along given axis

  • Delaunay2DScatterFit: Interpolate scalar function of 2-D data, based on Delaunay triangulation and cubic / linear interpolation

  • NonLinearLeastSquaresFit: Fit a generic function to data, based on non-linear least squares optimisation

  • GaussianFit: Fit Gaussian curve to multi-dimensional data

  • Spline1DFit: Fit a B-spline to 1-D data

  • Spline2DScatterFit: Fit a B-spline to scattered 2-D data

  • RbfScatterFit: Do radial basis function (RBF) interpolation

Grid fitters

  • GridFit: Abstract base class for grid fitters

  • Spline2DGridFit: Fit a B-spline to 2-D data on a rectangular grid

Helper functions

  • squash: Flatten array, but not necessarily all the way to a 1-D array

  • unsquash: Restore an array that was reshaped by squash

  • sort_grid: Ensure that the coordinates of a rectangular grid are in ascending order

  • desort_grid: Undo the effect of sort_grid

  • vectorize_fit_func: Factory that creates vectorised version of function to be fitted to data

  • randomise: Randomise fitted function parameters by resampling residuals

Source

https://github.com/ska-sa/scikits.fitting

Contact

Ludwig Schwardt <ludwig at ska.ac.za>

History

0.6 (2016-12-05)

  • Fix pip installation, clean up setup procedure, flake8 and add README

  • PiecewisePolynomial1DFit updated to work with scipy 0.18.0

  • Delaunay2DScatterFit now based on scipy.interpolate.griddata, which is orders of magnitude faster, more robust and smoother. Its default interpolation changed from ‘nn’ (natural neighbours - no longer available) to ‘cubic’.

  • Delaunay2DGridFit removed as there is no equivalent anymore

0.5.1 (2012-10-29)

  • Use proper name for np.linalg.LinAlgError

0.5 (2011-09-26)

  • Initial release of scikits.fitting

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scikits.fitting-0.6.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scikits.fitting-0.6-py2-none-any.whl (54.1 kB view details)

Uploaded Python 2

File details

Details for the file scikits.fitting-0.6.tar.gz.

File metadata

  • Download URL: scikits.fitting-0.6.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for scikits.fitting-0.6.tar.gz
Algorithm Hash digest
SHA256 6d2f2c400a7ea3fac6338c2675bfded47ece984fb903f8c256ec0dcac2c4613b
MD5 5168eb4a8d53cd9fc091bd5996fd9a4b
BLAKE2b-256 7b660ddf2e8976ddd8dbac94b03464a511de0bb5b7caf1cee264bcffe909bbf9

See more details on using hashes here.

File details

Details for the file scikits.fitting-0.6-py2-none-any.whl.

File metadata

File hashes

Hashes for scikits.fitting-0.6-py2-none-any.whl
Algorithm Hash digest
SHA256 f764ca61530de5b3a012ff0f20553847708c545f05d5632bf9f27be230c79f48
MD5 badf0dbc9c9982038f7be9cd597c39c4
BLAKE2b-256 8049e830b61648a3d9ee32a52db9260ae27dd33367d4fd55076dda141854e100

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page