Skip to main content

Fit python library

Project description

FFit. Fit python library.


Pypi Python 3.7+ License Code style: black CodeFactor Codecov Download Stats Documentation

FFit - Python library for easier fitting.

Install

pip install ffit

For more installation details, please refer to the How to install

How to use

The aim of this library is to simplify the fit routine. Here are some examples of how to use it.

Simple syntax

import ffit as ff

x = np.linspace(1, 10, 100)
y = 2 * np.sin(x) + 3

res = ff.Cos().fit(x, y).res

Plotting result

import ffit as ff
import matplotlib.pyplot as plt

x = np.linspace(1, 10, 100)
y = 2 * np.sin(x) + 3

plt.plot(x, y, '.')

res = ff.Cos().fit(x, y).plot().res

Plotting guess

The quality of fitting is heavily dependent on the initial guess. This library provides initial guesses for various popular functions to ensure effectiveness. However, if something goes awry, you can verify the guess and set it manually.

ff.Cos().guess(x, y).plot()

ff.Cos().guess(x, y, guess=[1,2,3,4]).plot()

ff.Cos().fit(x, y, guess=[1,2,3,4]).plot()

Other functions

Numerous functions are available out of the box. You can refer to the documentation for more details.

Moreover, you can use your custom functions with familiar syntax and still benefit from existing routines.

Any custom function

For any custom function, you can create a custom class for a guessing algorithm or use curve_fit or least_square like this:

def line_func(x, amp, offset):
    return amp * x + offset

fit_amp = ff.curve_fit(line_func, x, y).plot().res.amp

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

ffit-1.0.0.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

ffit-1.0.0-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file ffit-1.0.0.tar.gz.

File metadata

  • Download URL: ffit-1.0.0.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ffit-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a4bb8cc1cbfe63eff287efedcf422cfc5d7d7cf9d6f33ba9a06e12d9c3310b8d
MD5 451065e869ee7cebd372505fde32d986
BLAKE2b-256 ebe9e9dec05180903a658872e1bb78bccc4b34022af79b7c8e541bd64673018b

See more details on using hashes here.

File details

Details for the file ffit-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ffit-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ffit-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7967eef2a9c5f8895b649ac4979e6b178bae0972209911fb5e94ba95b0de123b
MD5 39b0d3cbc9a7a347d48aedc7b04d047f
BLAKE2b-256 3f7c49e32230f351df4fa8bf38cd3afe08d613a86be9b8d050eba882750b66d3

See more details on using hashes here.

Supported by

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