By default, sklearn's GridSearchCV() writes its outputs to the console. I want to save the output of each iteration in an output file. How can I put the following outputs to a file?
Fitting 5 folds for each of 1 candidates, totalling 5 fits
[CV] colsample_bytree=0.5, eta=0.05, gamma=0.01, learning_rate=0.1, max_depth=7, min_child_weight=0, subsample=0.8
[CV] colsample_bytree=0.5, eta=0.05, gamma=0.01, learning_rate=0.1, max_depth=7, min_child_weight=0, subsample=0.8, score=0.961, total= 4.4s
[CV] colsample_bytree=0.5, eta=0.05, gamma=0.01, learning_rate=0.1, max_depth=7, min_child_weight=0, subsample=0.8
[CV] colsample_bytree=0.5, eta=0.05, gamma=0.01, learning_rate=0.1, max_depth=7, min_child_weight=0, subsample=0.8, score=1.000, total= 2.9s
[CV] colsample_bytree=0.5, eta=0.05, gamma=0.01, learning_rate=0.1, max_depth=7, min_child_weight=0, subsample=0.8
[CV] colsample_bytree=0.5, eta=0.05, gamma=0.01, learning_rate=0.1, max_depth=7, min_child_weight=0, subsample=0.8, score=0.994, total= 2.9s
[CV] colsample_bytree=0.5, eta=0.05, gamma=0.01, learning_rate=0.1, max_depth=7, min_child_weight=0, subsample=0.8
[CV] colsample_bytree=0.5, eta=0.05, gamma=0.01, learning_rate=0.1, max_depth=7, min_child_weight=0, subsample=0.8, score=0.950, total= 2.8s
[CV] colsample_bytree=0.5, eta=0.05, gamma=0.01, learning_rate=0.1, max_depth=7, min_child_weight=0, subsample=0.8
[CV] colsample_bytree=0.5, eta=0.05, gamma=0.01, learning_rate=0.1, max_depth=7, min_child_weight=0, subsample=0.8, score=0.984, total= 2.9s