Fitter

class decida.Fitter.Fitter(model_eqns, par_specs, **kwargs)

Bases: decida.ItclObjectx.ItclObjectx

synopsis:

Fit parameterized equation set to data.

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 (str)

Set of equations involving data columns, and specified parameters equation set produces one data column, specified by the model_col configuration option.

par_specs (str)

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 object handle, 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 (str, default=””)

The data column which contains the data to be fitted.

model_col (str, default=””)

The data column which is to be created to fit the meast_col data.

error_col (str, default=””)

The relative or absolute error between the model_col and meast_col data

residual (str, 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()

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.
par_name_values()

return array of parameter name, value

results:

  • An array of the values of the parameters is returned.
par_object()
par_reset()

reset parameter values to initial values

results:

  • parameters are set to initial values
par_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.