Skip to main content

A tool to fit data to many distributions and get the best one(s)

Project description

https://badge.fury.io/py/fitter.svg https://github.com/cokelaer/fitter/actions/workflows/main.yml/badge.svg?branch=main https://coveralls.io/repos/github/cokelaer/fitter/badge.svg?branch=main Documentation Status https://zenodo.org/badge/23078551.svg https://img.shields.io/pypi/pyversions/fitter.svg https://img.shields.io/conda/vn/bioconda/fitter.svg https://img.shields.io/pypi/l/fitter.svg

Compatible with Python 3.9, 3.10, 3.11, 3.12, 3.13

What is it ?

The fitter package is a Python library used for fitting probability distributions to data. It provides a straightforward and and intuitive interface to estimate parameters for various types of distributions, both continuous and discrete. Using fitter, you can easily fit a range of distributions to your data and compare their fit, aiding in the selection of the most suitable distribution. The package is designed to be user-friendly and requires minimal setup, making it a useful tool for data scientists and statisticians working with probability distributions.

Installation

pip install fitter

fitter is also available on conda (bioconda channel):

conda install fitter

Usage

standalone

A standalone application (very simple) is also provided and works with input CSV files:

fitter fitdist data.csv --column-number 1 --distributions gamma,normal

It creates a file called fitter.png and a log fitter.log

From Python shell

First, let us create a data samples with N = 10,000 points from a gamma distribution:

from scipy import stats
data = stats.gamma.rvs(2, loc=1.5, scale=2, size=10000)

Now, without any knowledge about the distribution or its parameter, what is the distribution that fits the data best ? Scipy has 80 distributions and the Fitter class will scan all of them, call the fit function for you, ignoring those that fail or run forever and finally give you a summary of the best distributions in the sense of sum of the square errors. The best is to give an example:

from fitter import Fitter
f = Fitter(data)
f.fit()
# may take some time since by default, all distributions are tried
# but you call manually provide a smaller set of distributions
f.summary()
http://pythonhosted.org/fitter/_images/index-1.png

See the online documentation for details.

Contributors

Setting up and maintaining Fitter has been possible thanks to users and contributors. Thanks to all:

https://contrib.rocks/image?repo=cokelaer/fitter

Changelog

Version

Description

1.7.1

  • integrate PR github.com/cokelaer/fitter/pull/100 from @vitorandreazza to speedup multiprocessing run.

1.7.0

  • replace logging with loguru

  • main application update to add missing –output-image option and use rich_click

  • replace pkg_resources with importlib

1.6.0

1.5.2

1.5.1

  • fixed regression putting back joblib

1.5.0

  • removed easydev and replaced by tqdm for progress bar

  • progressbar from tqdm also allows replacement of joblib need

1.4.1

1.4.0

1.3.0

1.2.3

  • remove vervose arguments in Fitter class. Using the logging module instead

  • the Fitter.fit has now a progress bar

  • add a standalone application called … fitter (see the doc)

1.2.2

was not released

1.2.1

adding new class called histfit (see documentation)

1.2

1.1

  • Fixed deprecated warning

  • fitter is now in readthedocs at fitter.readthedocs.io

1.0.9

1.0.6

  • summary() now returns the dataframe (instead of printing it)

1.0.5

https://github.com/cokelaer/fitter/issues

1.0.2

add manifest to fix missing source in the pypi repository.

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

fitter-1.8.0.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

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

fitter-1.8.0-py3-none-any.whl (30.5 kB view details)

Uploaded Python 3

File details

Details for the file fitter-1.8.0.tar.gz.

File metadata

  • Download URL: fitter-1.8.0.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.14 Linux/6.14.5-100.fc40.x86_64

File hashes

Hashes for fitter-1.8.0.tar.gz
Algorithm Hash digest
SHA256 5bb98703907b2a472f3027ea6bb2d03a626c336810626fc75dcadbf402c3a29a
MD5 6a1c6bc29b792f5fdd1830da473a9d99
BLAKE2b-256 543b32bea682adc960ecf86d34db33265a790fd8ad2d85c61f3506fb2081718f

See more details on using hashes here.

File details

Details for the file fitter-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: fitter-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 30.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.14 Linux/6.14.5-100.fc40.x86_64

File hashes

Hashes for fitter-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0e8dbdaa760f58017f45d371cbf7df1962252b90d109b828b658c7dcf1762ab
MD5 6453b76ee229feb9774f0759be917994
BLAKE2b-256 776e1c867fb1502cfaee0c5689835730543146221f37b9dc1e036d93421ce0c5

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