A tool for adaptive selection of curve-fitting models.
Project description
Adaptive Curvefitting Tool
Adaptive curvefitting is a tool to find potentially optimal models for your research data. It's based on scipy, numpy, and matplotlib.
Table of contents
Why is this tool
The very difference of adaptive-curvefitting with numpy.polyfit, scipy.optimize.curve_fit or scipy.optimize.least_squares is the hypothesis you don’t know which model to fit. If you already have the expected model, the methods in scipy and numpy are fantastic tools and better than this one. When you explore something unknown, this will be a maybe.
Installation, update and uninstallation
To install
Quick installation with pip:
pip install adaptive-curvefitting
Or from github:
pip install git+https://github.com/longavailable/adaptive-curvefitting
To update
pip install --upgrade adaptive-curvefitting
To uninstall
pip uninstall adaptive-curvefitting
Usage
Import the required module
In general,
import longscurvefitting
or import the specified function:
from longscurvefitting import oneClickCurveFitting
from longscurvefitting import generateFunction
from longscurvefitting import generateModels
Do the curvefitting
oneClickCurveFitting(xdata, ydata)
There are some optional arguments of oneClickCurveFitting
.
- functions: specified or all (default) basic models(name of models) to fit.
- Type: list of string
- Default: basicModels_nameList
- piecewise: if consider custom a piecewise function. It is mandatory not to 'piecewise' when the data size is less than 20.
- Type: bool
- Default: False
- operator: operatation between basic models.
- Type: string
- Default: '+'
- maxCombination: max number of combination of basic models.
- Type: integer
- Default: 2
- plot_opt: the number of plot for optimal models.
- Type: integer
- Default: 10
- xscale: one of {"linear", "log", "symlog", "logit", ...}
- Type: string
- Default: None
- yscale: one of {"linear", "log", "symlog", "logit", ...}
- Type: string
- Default: None
- filename_startwith: a custom string mark as part of output filename
- Type: string
- Default: 'curvefit'
- silent: minimal output to monitor
- Type: boolean
- Default: False
- feedback: if True, return the optimal model(function object), parameters
- Type: boolean
- Default: False
- kwargs: keyword arguments passed to
curve_fit_m
. Note thatbounds
andp0
will take no effect when multi-models.- Type: dict
See the complete example "/tests/curvefitting.py".
Generate a expected model
Create a model composited by gaussian and erf function:
funcs = ['gaussian','erf']
myfunc = generateFunction(funcs, functionName='myfunc', operator='+')['model']
See the complete example "/tests/custom_a_model.py".
Re-use the fitted curve
See the complete example "/tests/reuse_the_fitted_model.py".
Shortages
- Based on scipy.optimize.least_squares, it cannot enhance the estimate of specified model. Evenmore, it has more limit than scipy.optimize.least_squares.
For example, arguments of
bounds
,x0
orp0
were not supported due to the basic hypothesis.
How to cite
If this tool is useful to your research, star and cite it as below:
Xiaolong Liu, & Meixiu Yu. (2020, June 14). longavailable/adaptive-curvefitting. Zenodo.
http://doi.org/10.5281/zenodo.3893596
Easily, you can import it to Mendeley.
Changelog
v0.1.3
- First release.
v0.1.4
- Add
queryModel()
to simplify the reuse of a fitted model. - Replace
from scipy._lib._util import getargspec_no_self as _getargspec
withfrom ._helpers import funcArgsNr
v0.1.5
- Updated the outdated module of sci.
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
Built Distribution
File details
Details for the file adaptive-curvefitting-0.1.5.tar.gz
.
File metadata
- Download URL: adaptive-curvefitting-0.1.5.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fca153baf2f7f2e18dcf9b7b66f9f9dc9426f3365742561b11d6b4375b90b80f |
|
MD5 | fbc68a84db469f5a3993a6d5fa015cae |
|
BLAKE2b-256 | 7a3c7e4170ae3a16090f5939fbc17f866e57f194ff721b4d917dbca1d4b94533 |
File details
Details for the file adaptive_curvefitting-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: adaptive_curvefitting-0.1.5-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccdc2f1a88410dc7aded4d00630248eb784e40fb51eb12887af4f7b8bc748706 |
|
MD5 | 90bcf5efd87e1a8bd71c4cabb56a395a |
|
BLAKE2b-256 | 7b0b3c2549ee7c35a6c86b3143566c60abbd9825eda2beb87f93a868d52471f8 |