Skip to main content

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.7.2 (2023-10-10)

  • Remove distutils and move to pkgutil-style namespace package (#12)

  • Remove run_module_suite function (a nose leftover) (#11)

0.7.1 (2023-09-21)

  • Fix deprecated NumPy type alias (np.float) (#10)

0.7 (2018-09-20)

  • Python 3 support (#8)

  • Clean up tests and more flake8 (line lengths) (#9)

0.6 (2016-12-05)

  • Fix pip installation, clean up setup procedure, flake8 and add README (#3)

  • PiecewisePolynomial1DFit updated to work with scipy 0.18.0 (#4)

  • 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’. (#5)

  • Delaunay2DGridFit removed as there is no equivalent anymore (#5)

0.5.1 (2012-10-29)

  • Use proper name for np.linalg.LinAlgError

0.5 (2011-09-26)

  • Initial release of scikits.fitting

Release files for scikits.fitting 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scikits.fitting 0.7.2
File Size Uploaded
scikits.fitting-0.7.2.tar.gz 36.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scikits.fitting 0.7.2
File Interpreter ABI Platform
scikits.fitting-0.7.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 88.3 kB

Release files / scikits.fitting-0.7.2.tar.gz

Download URL scikits.fitting-0.7.2.tar.gz
Size 36.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d2f7ec7ecc2082a346f35d774facb733baba17b77b51c99cb479853b8e8b5dbd
BLAKE2b-256 checksum
How to use checksums
0ec59847273196c7fc7f5e13d84f2082cb0cc7a32ab27a91884f462252cf59bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / scikits.fitting-0.7.2-py2.py3-none-any.whl

Download URL scikits.fitting-0.7.2-py2.py3-none-any.whl
Size 52.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
15798d86f77929bdbe5ce4f88c42c812907d984987db5b8f759c849a9b826361
BLAKE2b-256 checksum
How to use checksums
178c4767f7107cfa41146f62ad6b618fbbcefc81c8ed3b54d586bdf89fa4b9ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.7.2 This release

2 release files

0.7.1

1 release file

0.7

2 release files

0.6

2 release files

0.5.1

1 release file

0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page