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.2.tar.gz (38.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.1.2-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ffit-1.1.2.tar.gz
Algorithm Hash digest
SHA256 3f8bc3f765c02df263d372505518bdfd2b06763fd01f3c68fc63f37ff0fb5b15
MD5 0d4aa62f8ba83046129dc26da05c9b22
BLAKE2b-256 e183c26609d6dfabba383623ffeee2efc69dbeab41174e6be00a09b3613b14c3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ffit-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2d71dfb51126feb6b716f009862cef7e9e9a8b12306003e8cb988d10c0f6b370
MD5 0953a9ae91286bf4f0ae224b983502e2
BLAKE2b-256 15439f25dcd5ec5870cc515caa5972c4404913629bc305c65832d5419f71c408

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