Skip to main content

A tool to fit data to many distributions and 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/cokelaer/fitter/badge.png?branch=main Documentation Status https://zenodo.org/badge/23078551.svg

Compatible with Python 3.6, 3.7, and 3.8, 3.9

What is it ?

fitter package provides a simple class to identify the distribution from which a data samples is generated from. It uses 80 distributions from Scipy and allows you to plot the results to check what is the most probable distribution and the best parameters.

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.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.5.0.tar.gz (905.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: fitter-1.5.0.tar.gz
  • Upload date:
  • Size: 905.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.3

File hashes

Hashes for fitter-1.5.0.tar.gz
Algorithm Hash digest
SHA256 3f96cd707baef48cbf5bd5573e8c65ec86e903be92cf6de33c955a85f6cc195c
MD5 e6cd979023a85873fd38769a21b697cb
BLAKE2b-256 312858ee5dad2e2229b6284690203307efcb082e64bffdea33c0dc56c0270b22

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page