Python package for univariate curve fitting using TensorFlow.
Project description
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.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tensorfit-0.0.6.tar.gz.
File metadata
- Download URL: tensorfit-0.0.6.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a5779cf287b3c0e5ffc65d14ecbde7c7684e3d0d3abf3e713929370f533e08f
|
|
| MD5 |
42025d8cfc150c3bfdab1f9b33666514
|
|
| BLAKE2b-256 |
0d3c5bcabd5cb2a1ed0ccc590a430315af6b9b88235f4f7611938b5553e82ba2
|
File details
Details for the file tensorfit-0.0.6-py3-none-any.whl.
File metadata
- Download URL: tensorfit-0.0.6-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a82c725e46a3f862a7f290a60c7d69147780e67745b59a0999fbe6a91a82d01a
|
|
| MD5 |
a6180e2d5b388af6203315a53da08614
|
|
| BLAKE2b-256 |
75066cc1dab7d0d7076a256fa724f4f03fdc19539909c413a98dade242179633
|