Package: scipy-data_fitting
Built frommakenew/python-package.DescriptionComplete pipeline for easy data fitting with Python 3.Check out theexample fits on Fitalyzer.
See theFitalyzer READMEfor details on how to use Fitalyzer for
visualizing your fits.InstallationThis package is registered on thePython Package Index (PyPI)asscipy_data_fitting.Add this line to your application’s requirements.txtscipy_data_fittingand install it with$ pip install -r requirements.txtIf you are writing a Python package which will depend on this,
add this to your requirements insetup.py.Alternatively, install it directly using pip with$ pip install scipy_data_fittingDocumentationDocumentation is generated from source withpdoc.
The latest version is hosted atpythonhosted.org/scipy-data_fitting/.To get started quickly, check out theexamples.Then, refer to the source documentation for details on how to use each class.Basic Usagefromscipy_data_fittingimportData,Model,Fit,Plot# Load data from a CSV file.data=Data('linear')data.path='linear.csv'data.error=(0.5,None)# Create a linear model.model=Model('linear')model.add_symbols('t','v','x_0')t,v,x_0=model.get_symbols('t','v','x_0')model.expressions['line']=v*t+x_0# Create the fit using the data and model.fit=Fit('linear',data=data,model=model)fit.expression='line'fit.independent={'symbol':'t','name':'Time','units':'s'}fit.dependent={'name':'Distance','units':'m'}fit.parameters=[{'symbol':'v','guess':1,'units':'m/s'},{'symbol':'x_0','value':1,'units':'m'},]# Save the fit result to a json file.fit.to_json(fit.name+'.json',meta=fit.metadata)# Save a plot of the fit to an image file.plot=Plot(fit)plot.save(fit.name+'.svg')plot.close()Controlling the fitting processThe above example will fit the line using the default algorithmscipy.optimize.curve_fit.For a linear fit, it may be more desirable to use a more efficient
algorithm.For example, to usenumpy.polyfit, one could set afit_functionand allow both parameters to vary,fit.parameters=[{'symbol':'v','guess':1,'units':'m/s'},{'symbol':'x_0','guess':1,'units':'m'},]fit.options['fit_function']=\lambdaf,x,y,p0,**op:(numpy.polyfit(x,y,1),)Controlling the fitting process this way allows, for example,
incorporating error values and computing and returning goodness of fit
information.Seescipy_data_fitting.Fit.optionsfor further details on how to
control the fit and also how to uselmfit.Development and TestingSource CodeThescipy-data_fitting sourceis hosted on GitHub.
Clone the project with$ git clone https://github.com/razor-x/scipy-data_fitting.gitRequirementsYou will needPython 3withpip.Install the development dependencies with$ pip install -r requirements.devel.txtTestsLint code with$ python setup.py lintRun tests with$ python setup.py testor$ make testDocumentationGenerate documentation with pdoc by running$ make docsExamplesRun an example with$ python examples/example_fit.pyor run all the examples with$ make examplesContributingPlease submit and comment on bug reports and feature requests.To submit a patch:Fork it (https://github.com/razor-x/scipy-data_fitting/fork).Create your feature branch (git checkout-bmy-new-feature).Make changes. Write and run tests.Commit your changes (git commit-am'Add some feature').Push to the branch (git push originmy-new-feature).Create a new Pull Request.LicenseThis Python package is licensed under the MIT license.WarrantyThis software is provided “as is” and without any express or implied
warranties, including, without limitation, the implied warranties of
merchantibility and fitness for a particular purpose.