pythonoptimizationlmfit

printing variable values using lmfit


am trying to print variable values from lmfit minimization algorithm.am using lmfit.printfuncs.report_fit(res.params) am getting

[[Variables]]
    a:   123 (init= 123)
    b:   456 (init= 456)
    c:   789 (init= 789)
    d:   012 (init= 012)
[[Correlations]] (unreported correlations are <  0.100)

Can i print just the outcome values like

123
456
789
012

Solution

  • result.params is an ordered dictionary of Parameter objects, each of which has the best value stored in the value attribute, and several other attributes. Basically, fit_report does something like:

    for param in result.params.values():
        print("%s:  %f +/- %f (init = %f)" % (param.name, param.value, param.stderr, param.init_value)
    

    You can modify that any way you'd like.