Bases: decida.ItclObjectx.ItclObjectx
fit parameterized equation set to data.
synopsis:
Fitter is a wrapper around the Levenberg-Marquardt least-squares optimization class LevMar. One model equation set is specified, and one parameter set is specified when the instance is created.
constructor arguments:
- model_eqns (string)
Set of equations involving data columns, and specified parameters equation set produces one data column, specified by the model_col configuration option.
- par_specs (string)
Set of specifications for a set of model parameters. The specifications are parameter name, initial value, the keyword include if the parameter is to be included in the optimization, lower_limit=value and upper_limit=value. The last two specifications are optional, and if not specified the parameter is unbounded on the respective end.
- **kwargs (dict)
keyword=value specifications: configuration-options
configuration options:
- data (Data, default=None)
Data object which contains data to be fitted to the model equations. Model and residual columns are created in the Data object.
- meast_col (string, default="")
The data column which contains the data to be fitted.
- model_col (string, default="")
The data column which is to be created to fit the meast_col data.
- error_col (string, default="")
The relative or absolute error between the model_col and meast_col data
- residual (string, default="relative")
Specify whether residual is relative or absolute. It must be one of these two values.
- quiet (bool, default=False)
If True, do not print as much information from the LevMar class instance.
example (from test_Fitter):
d=Data()
d.read("icp_tr_diff.report")
ftr=Fitter(
"""
dicp_mod = a0 + a1*sign(dt)*(1-(1+(abs(dt/u0))^x0)/(1+(abs(dt/u1))^x1))
""",
"""
a0 0 include lower_limit=-1 upper_limit=1
a1 6e-3 include lower_limit=1e-8 upper_limit=1
u0 2.3e-10 include lower_limit=1e-12
u1 2.3e-10 include lower_limit=1e-12
x0 1.05 include lower_limit=1
x1 1.05 include lower_limit=1
""",
meast_col="dicp",
model_col="dicp_mod",
error_col="residual",
residual="relative",
data=d
)
ftr.fit()
print ftr.par_values()
DataViewx(data=d, command=[["dt residual"], ["dt dicp dicp_mod"]])
public methods:
- public methods from ItclObjectx
fit the meast_col data to model equations.
results:
- A LevMar instance is created and used to fit the meast_col data to the specified model equations.
return array of parameter name, value
results:
- An array of the values of the parameters is returned.
reset parameter values to initial values
results:
- parameters are set to initial values
return the current model parameter values.
results:
- A list of the values of the parameters is returned. The parameter values are in the same order as they were specified.