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.1.0.tar.gz (37.5 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.1.0-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ffit-1.1.0.tar.gz
  • Upload date:
  • Size: 37.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for ffit-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e1e9c5cd2a373e0077b6135eda84b12dc020a3745dd7c601b42fb28fee09ec72
MD5 75fa6c74fddea2d29ef4b33179e25e68
BLAKE2b-256 bf4f47c94b16fafa400ef391514c8bd80b4ac9bac0a8a16cb82a6d6b422e7314

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ffit-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for ffit-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a0f1909ce970779726c81efd336afa3e5658b78b234b9ba9b193d9765c6eb96
MD5 f41404a096d54e965fdbc52676c1759b
BLAKE2b-256 0f6d362b25f5a1341fc7dbaf0b5b29d083f7d38cf0832cc0aa126ae435e963d6

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