1

I've got an issue with

save_modelresult(result, 'S:\Doc\Python\Results\modelresult.csv')

Well the save is complete, but the organization of this data is very poor. Does anyone know of any tricks/ways how to store my results in organized columns?

Cheers!

fmw42
  • 46,825
  • 10
  • 62
  • 80
Hiddenguy
  • 547
  • 13
  • 33

1 Answers1

3

Lmfit's model.save_modelresult() function saves the ModelResult as JSON that is intended to be loaded with load_modelresult which will turn that saved representation into a working ModelResult in another Python session. It's not necessarily meant to be human-readable. Then again, it can be read in with the json library if you want.

For organizing that output in a human-readable form, I would suggest looking at the fit_report() method of ModelResult and the lmfit.printfuncs.fit_report() function that it uses. The simplest thing to do is probably just save that fit report to a file, say like this:

# save fit report to a file:
with open('fit_result.txt', 'w') as fh:
    fh.write(result.fit_report())
M Newville
  • 7,486
  • 2
  • 16
  • 29
  • Thank You for comment. I'd like to ask You about Your last suggestion, which is saving report to a file, can You suggest how to do this? – Hiddenguy Jun 06 '18 at 15:43
  • 1
    I updated the answer to include more explicit instructions on how to save the text report to a file. – M Newville Jun 06 '18 at 19:01