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.2.0.tar.gz (44.8 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.2.0-py3-none-any.whl (44.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ffit-1.2.0.tar.gz
  • Upload date:
  • Size: 44.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for ffit-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e392da6914a1f581c3b64d28206151bdd62dc77af2ab00ea9949d23f7d09dad3
MD5 8d9a690f2e5d77435031594197c58c20
BLAKE2b-256 f6474695f78d0f37a24ee5f37c1f2b78cd0161cea88672e12facc5565c2cf9ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ffit-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 44.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for ffit-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4235a8e59ce2be6056c3dbf8649e19af651758bf2aa7e09970028ae81aa2201a
MD5 6fd496a9640cc38704a5270f311dd43a
BLAKE2b-256 6badda01b862d5a3c7af5be05d1d4f6d3fc5a6920677b8c7e1eb3f890034d742

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