Skip to main content

Fit python library

Project description

FFit. Fit python library.


Pypi Python 3.10+ 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.2.tar.gz (34.9 kB view details)

Uploaded Source

Built Distribution

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

ffit-1.0.2-py3-none-any.whl (33.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ffit-1.0.2.tar.gz
  • Upload date:
  • Size: 34.9 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.2.tar.gz
Algorithm Hash digest
SHA256 a0df5e9fc4e36fba8f0e62582f30ad1fad6d7382d966b2d60e6ba85bb90a6df3
MD5 539ffcff867658c6bd413ac469ca69b5
BLAKE2b-256 0a7a98c4536412ed902e111e1b41b6db4df78e052b84d774d34b0c17cb8a3ba7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ffit-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 33.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ec5912495091c1d6373a4c428890935079697b329c066f869505e841cbc3c6e6
MD5 5d10f777e37916251d6185ebc9fcf79e
BLAKE2b-256 b1b8d5a8d48013b10c2af232de1e1f172367e05fd80c60cebec6653f8177a429

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