30

When I want to fit some model in python, I often use fit() method in statsmodels. And some cases I write a script for automating fitting:

import statsmodels.formula.api as smf
import pandas as pd
df = pd.read_csv('mydata.csv')  # contains column x and y
fitted = smf.poisson('y ~ x', df).fit()

My question is how to silence the fit() method. In my environment it outputs some information about fitting to standard output like:

Optimization terminated successfully.
         Current function value: 2.397867
         Iterations 11

but I don't need it. I couldn't find the argument which controls standard output printing. How can I silence fit() method?

Python 3.3.4, IPython 2.0.0, pandas 0.13.1, statsmodels 0.5.0.

vaultah
  • 44,105
  • 12
  • 114
  • 143
keisuke
  • 2,123
  • 4
  • 20
  • 31

1 Answers1

46

Use the disp argument to fit. It controls the verbosity of the optimizers in scipy.

mod.fit(disp=0)

See the documentation for fit.

jseabold
  • 7,903
  • 2
  • 39
  • 53
  • 1
    `disp` is exactly what I needed. Of course I saw the documentation for `fit` but I missed it. Please excuse my stupidity. – keisuke Apr 12 '14 at 01:59