Thanks, I fixed it for SGD. l-bfgs however, doesn't store the output in StringIO - it simply outputs the progress on the screen, using this snippet,
`
 old_stdout = sys.stdout
 sys.stdout = output = StringIO()
 clf.fit(X, y)
 sys.stdout = old_stdout`

 I guess there must be another way to force storing output.