lmfit
Non-Linear Least Squares Minimization, with flexible Parameter settings, based on scipy.optimize, and with many additional classes and methods for curve fitting.
Science Score: 77.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 2 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
✓Committers with academic emails
17 of 96 committers (17.7%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.7%) to scientific vocabulary
Keywords
curve-fitting
least-squares
python
scipy
Keywords from Contributors
closember
gtk
qt
tk
wx
conda
package-management
optimizing-compiler
astronomy
robust-estimation
Last synced: 4 months ago
·
JSON representation
·
Repository
Non-Linear Least Squares Minimization, with flexible Parameter settings, based on scipy.optimize, and with many additional classes and methods for curve fitting.
Basic Info
- Host: GitHub
- Owner: lmfit
- License: other
- Language: Python
- Default Branch: master
- Homepage: https://lmfit.github.io/lmfit-py/
- Size: 358 MB
Statistics
- Stars: 1,140
- Watchers: 30
- Forks: 286
- Open Issues: 4
- Releases: 0
Topics
curve-fitting
least-squares
python
scipy
Created over 14 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Contributing
License
Citation
Authors
README.rst
LMfit-py
========
.. image:: https://dev.azure.com/lmfit/lmfit-py/_apis/build/status/lmfit.lmfit-py?branchName=master
:target: https://dev.azure.com/lmfit/lmfit-py/_build/latest?definitionId=1&branchName=master
.. image:: https://codecov.io/gh/lmfit/lmfit-py/branch/master/graph/badge.svg
:target: https://codecov.io/gh/lmfit/lmfit-py
.. image:: https://img.shields.io/pypi/v/lmfit.svg
:target: https://pypi.org/project/lmfit
.. image:: https://img.shields.io/pypi/dm/lmfit.svg
:target: https://pypi.org/project/lmfit
.. image:: https://img.shields.io/badge/docs-read-brightgreen
:target: https://lmfit.github.io/lmfit-py/
.. image:: https://zenodo.org/badge/4185/lmfit/lmfit-py.svg
:target: https://doi.org/10.5281/zenodo.598352
.. _LMfit google mailing list: https://groups.google.com/group/lmfit-py
.. _Github Discussions: https://github.com/lmfit/lmfit-py/discussions
.. _Github Issues: https://github.com/lmfit/lmfit-py/issues
..
Note: the Zenodo target should be
https://zenodo.org/badge/latestdoi/4185/lmfit/lmfit-py
but see https://github.com/lmfit/lmfit-py/discussions/862
Overview
---------
The ``lmfit`` Python library provides tools for non-linear least-squares
minimization and curve fitting. The goal is to make these optimization
algorithms more flexible, more comprehensible, and easier to use, with the
key feature of casting variables in minimization and fitting routines as named
parameters that can have many attributes beside just a current value.
LMfit is a pure Python package -- built on top of Scipy and Numpy -- and is easy to
install with ``pip install lmfit``.
For questions, comments, and suggestions, please use the `LMfit google mailing
list`_ or `Github discussions`_. For software issues and bugs, use `Github
Issues`_, but please read `Contributing.md <.github/CONTRIBUTING.md>`_ before
creating an Issue.
Parameters and Minimization
------------------------------
LMfit provides optimization routines similar to (and based on) those from
``scipy.optimize``, but with a simple, flexible approach to parameterizing a
model for fitting to data using named parameters. These named Parameters can be
held fixed or freely adjusted in the fit, or held between lower and upper
bounds. Parameters can also be constrained as a simple mathematical expression
of other Parameters.
A Parameters object (which acts like a Python dictionary) contains named
parameters, and can be built as with::
import lmfit
fit_params = lmfit.Parameters()
fit_params['amp'] = lmfit.Parameter(value=1.2)
fit_params['cen'] = lmfit.Parameter(value=40.0, vary=False)
fit_params['wid'] = lmfit.Parameter(value=4, min=0)
fit_params['fwhm'] = lmfit.Parameter(expr='wid*2.355')
or using the equivalent::
fit_params = lmfit.create_params(amp=1.2,
cen={'value':40, 'vary':False},
wid={'value': 4, 'min':0},
fwhm={'expr': 'wid*2.355'})
In the general minimization case (see below for Curve-fitting), the user will
also write an objective function to be minimized (in the least-squares sense)
with its first argument being this Parameters object, and additional positional
and keyword arguments as desired::
def myfunc(params, x, data, someflag=True):
amp = params['amp'].value
cen = params['cen'].value
wid = params['wid'].value
...
return residual_array
For each call of this function, the values for the ``params`` may have changed,
subject to the bounds and constraint settings for each Parameter. The function
should return the residual (i.e., ``data-model``) array to be minimized.
The advantage here is that the function to be minimized does not have to be
changed if different bounds or constraints are placed on the fitting Parameters.
The fitting model (as described in myfunc) is instead written in terms of
physical parameters of the system, and remains independent of what is
actually varied in the fit. In addition, which parameters are adjusted and which
are fixed happens at run-time, so that changing what is varied and what
constraints are placed on the parameters can easily be modified by the user in
real-time data analysis.
To perform the fit, the user calls::
result = lmfit.minimize(myfunc, fit_params, args=(x, data), kws={'someflag':True}, ....)
After the fit, a ``MinimizerResult`` class is returned that holds the results
of the fit (e.g. fitting statistics and optimized parameters). The dictionary
``result.params`` contains the best-fit values, estimated standard deviations,
and correlations with other variables in the fit.
By default, the underlying fit algorithm is the Levenberg-Marquardt algorithm
with numerically-calculated derivatives from MINPACK's lmdif function, as used
by ``scipy.optimize.leastsq``. Most other solvers that are present in ``scipy``
(e.g. Nelder-Mead, differential_evolution, basin-hopping, and more) are also
supported.
Curve-Fitting with lmfit.Model
----------------------------------
One of the most common use of least-squares minimization is for curve fitting,
where minimization of ``data-model``, or ``(data-model)*weights``. Using
``lmfit.minimize`` as above, the objective function would take ``data`` and
``weights``, effectively calculate the model, and return the value of
``(data-model)*weights``.
To simplify this, and make curve-fitting more flexible, ``lmfit`` provides a ``Model``
class that wraps a *model function* that represents the model (without the data
or weights). Parameters are then automatically found from the named arguments
of the model function. In addition, simple model functions can be readily
combined and reused, and several common model functions are included in ``lmfit``.
Exploration of Confidence Intervals
-------------------------------------
LMfit tries to always estimate uncertainties in fitting parameters and
correlations between them. It does this even for those methods where the
corresponding ``scipy.optimize`` routines do not estimate uncertainties.
LMfit also provides methods to explicitly explore and evaluate the
confidence intervals in fit results.
Owner
- Name: lmfit
- Login: lmfit
- Kind: organization
- Repositories: 4
- Profile: https://github.com/lmfit
High-level Curve Fitting in Python
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software and want to cite it, please use the DOI citation below."
title: "LMFIT: Non-Linear Least-Squares Minimization and Curve-Fitting for Python"
version: 1.3.3
date-released: 2025-03-09
identifiers:
- type: doi
value: 10.5281/zenodo.12785036
authors:
- family-names: Newville
given-names: Matthew
orcid: https://orcid.org/0000-0001-6938-1014
- family-names: Otten
given-names: Renee
orcid: https://orcid.org/0000-0001-7342-6131
- family-names: Nelson
given-names: Andrew
orcid: https://orcid.org/0000-0002-4548-3558
- family-names: Stensitzki
given-names: Till
orcid: https://orcid.org/0000-0003-2317-4874
- family-names: Ingargiola
given-names: Antonino
orcid: https://orcid.org/0000-0002-9348-1397
- family-names: Allan
given-names: Daniel
orcid: https://orcid.org/0000-0002-5947-6017
- family-names: Fox
given-names: Austin
orcid: https://orcid.org/0000-0002-8926-0524
- family-names: Carter
given-names: Faustin
orcid: https://orcid.org/0000-0002-1236-3517
- family-names: Rawlik
given-names: Michal
orcid: https://orcid.org/0000-0002-1232-4497
GitHub Events
Total
- Create event: 9
- Release event: 2
- Issues event: 13
- Watch event: 91
- Delete event: 4
- Issue comment event: 69
- Push event: 31
- Pull request review comment event: 10
- Pull request review event: 10
- Pull request event: 29
- Fork event: 14
Last Year
- Create event: 9
- Release event: 2
- Issues event: 13
- Watch event: 91
- Delete event: 4
- Issue comment event: 69
- Push event: 31
- Pull request review comment event: 10
- Pull request review event: 10
- Pull request event: 29
- Fork event: 14
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Matt Newville | n****e@c****u | 1,258 |
| reneeotten | r****n | 685 |
| Andrew Nelson | a****f@g****m | 79 |
| Antonino Ingargiola | t****o@g****m | 58 |
| Till Stensitzki | m****l@g****e | 54 |
| danielballan | d****n@g****m | 35 |
| Austin Fox | o****x@g****m | 26 |
| Faustin Carter | f****r@g****m | 23 |
| Michał Rawlik | m****k@p****h | 22 |
| François Boulogne | f****g | 12 |
| Ray Osborn | r****n@m****m | 8 |
| dpustakhod | d****d@t****l | 8 |
| s-weigand | s****y@g****m | 6 |
| François Boulogne | f****g | 6 |
| licode | l****i@b****v | 6 |
| Yoav Ram | y****b@g****m | 6 |
| gitj | g****h@g****m | 5 |
| Leonhard | l****s@g****m | 5 |
| aaristov | a****v@p****r | 5 |
| Colin-N. Brosseau | c****u@g****m | 4 |
| Merlin | m****n@n****k | 4 |
| Christoph Deil | D****h@g****m | 4 |
| mgunyho | m****o@g****m | 4 |
| Mark | m****n@g****m | 4 |
| Allan L. R. Hansen | a****h@g****m | 3 |
| Leon Foks | n****s@c****v | 3 |
| Gustavo Pasquevich | g****v@f****r | 3 |
| Nicholas Zobrist | n****t@p****u | 3 |
| julian stuermer | j****r@o****e | 3 |
| Oliver Frost | o****t@g****t | 3 |
| and 66 more... | ||
Committer Domains (Top 20 + Academic)
mac.com: 2
gmaill.com: 1
columbia.edu: 1
ias.u-psud.fr: 1
torrinos.com: 1
trialphaenergy.com: 1
anazazi.imp.fu-berlin.de: 1
uni-ulm.de: 1
gmx.net: 1
online.de: 1
physics.ucsb.edu: 1
fisica.unlp.edu.ar: 1
contractor.usgs.gov: 1
nbi.dk: 1
pasteur.fr: 1
bnl.gov: 1
tue.nl: 1
psi.ch: 1
gmx.de: 1
cars.uchicago.edu: 1
inserm.fr: 1
tudelft.nl: 1
lbl.gov: 1
tu-dortmund.de: 1
fu-berlin.de: 1
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 77
- Total pull requests: 121
- Average time to close issues: about 2 months
- Average time to close pull requests: 16 days
- Total issue authors: 50
- Total pull request authors: 41
- Average comments per issue: 3.94
- Average comments per pull request: 4.4
- Merged pull requests: 92
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 11
- Pull requests: 28
- Average time to close issues: about 1 month
- Average time to close pull requests: 7 days
- Issue authors: 10
- Pull request authors: 12
- Average comments per issue: 2.45
- Average comments per pull request: 2.0
- Merged pull requests: 17
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- newville (13)
- nomeata (4)
- jcjaskula-aws (4)
- schtandard (4)
- yurivict (2)
- paulmueller (2)
- Julian-Hochhaus (2)
- edr-choi (1)
- earthshrink (1)
- GuillermoAbadLopez (1)
- tillea (1)
- bennyrowland (1)
- parejkoj (1)
- SilentStorming (1)
- Emily-Linden (1)
Pull Request Authors
- newville (55)
- reneeotten (15)
- jcjaskula-aws (4)
- Anselmoo (3)
- schtandard (3)
- eendebakpt (2)
- Timothy-J-Warner (2)
- lellid (2)
- matpompili (2)
- stuart-cls (2)
- paulmueller (2)
- imnotgonnasithereandtryallday (2)
- vyrjana (2)
- mstekiel (2)
- peendebak (2)
Top Labels
Issue Labels
rude user - did not follow instructions (1)
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 945,719 last-month
- Total docker downloads: 82,030
-
Total dependent packages: 289
(may contain duplicates) -
Total dependent repositories: 694
(may contain duplicates) - Total versions: 59
- Total maintainers: 1
pypi.org: lmfit
Least-Squares Minimization with Bounds and Constraints
- Homepage: https://lmfit.github.io//lmfit-py/
- Documentation: https://lmfit.github.io/lmfit-py/
- License: other
-
Latest release: 1.3.4
published 6 months ago
Rankings
Dependent packages count: 0.1%
Dependent repos count: 0.5%
Downloads: 0.7%
Docker downloads count: 1.1%
Average: 1.3%
Stargazers count: 2.1%
Forks count: 3.2%
Maintainers (1)
Last synced:
4 months ago
conda-forge.org: lmfit
- Homepage: http://lmfit.github.io/lmfit-py/
- License: BSD-3-Clause
-
Latest release: 1.0.3
published about 4 years ago
Rankings
Dependent packages count: 2.1%
Dependent repos count: 6.4%
Average: 8.3%
Forks count: 11.3%
Stargazers count: 13.6%
Last synced:
5 months ago