TensorFit
TensorFit is an open source package for curve fitting. This package was designed with the intention of allowing students and researchers to quickly assess parametric functions for explaining experimental data and trends. The package currently only supports univariate functions, i.e. functions with a single independent variable.
Install
pip install tensorfit
Usage
Import packages as needed.
>>> import numpy as np
>>> from tensorfit import TensorFunction
Generate from fake experimental data for the purpose of demonstration.
>>> x = np.linspace(-1, 1, 100)
>>> y = 9.8 * x ** 2 + 6.1 * x + 0.87 * np.random.randn(*x.shape)
Create and initialize TensorFunction instance using a parametric model for your fitting function and a set of starting parameters.
>>> tfunc = TensorFunction()
>>> my_func = "self.a * self.X ** 2 + self.b * self.X + self.c"
>>> init_params = {"a": 0.1, "b": 0.1, "c": 0.1}
>>> tfunc.initialize(func=my_func, params=init_params)
After initialization, you can make a call to .fit() to fit your TensorFunction() to the experimental data.
>>> tfunc.fit(x, y, num_rounds=10000, early_stopping_rounds=10, verbose_eval=0)
Early stopping, best iteration is:
[Episode - 6046] mse: 0.81566346
Fitted parameters and a summary of your fit can then be looked at.
>>> tfunc.Params
{'a': 9.560993, 'b': 6.0437393, 'c': 0.11265278}
>>> tfunc.Summary
{'mse': 0.81566346, 'r2': 0.9623992666602135}
License
This library uses:
- numpy, which is distributed under the BSD 3-Clause license.
- tensorflow, which is distributed under the Apache 2.0 license.
Metadata
Release files for tensorfit 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tensorfit-0.0.6.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tensorfit-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / tensorfit-0.0.6.tar.gz
| Download URL | tensorfit-0.0.6.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a5779cf287b3c0e5ffc65d14ecbde7c7684e3d0d3abf3e713929370f533e08f
|
|
BLAKE2b-256 checksum How to use checksums |
0d3c5bcabd5cb2a1ed0ccc590a430315af6b9b88235f4f7611938b5553e82ba2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9
|
Release files / tensorfit-0.0.6-py3-none-any.whl
| Download URL | tensorfit-0.0.6-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a82c725e46a3f862a7f290a60c7d69147780e67745b59a0999fbe6a91a82d01a
|
|
BLAKE2b-256 checksum How to use checksums |
75066cc1dab7d0d7076a256fa724f4f03fdc19539909c413a98dade242179633
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9
|