prophet
prophet copied to clipboard
Removing logs of optimization in cross_validation
I am getting lots of logs while running the cross_validation using dask, Does anyone know a workaround for that thing?. I tried to follow the solution from issue #223 , but I am unable to hide the log.
I was using this like this.
with self.suppress_stdout_stderr(): df_cv = cross_validation(m, horizon='7 days', period='7 days', initial='500 days', parallel='dask')
I have the same problem, did you ever find a solution?
This method can avoid outputting logs in the terminal or jupyter notebook. But it makes the code look a little strange.
import sys
# Create a file to save the output of stdout
stdout_file_path = 'path/to/stdout_file.txt' # Replace with the path where you want to save stdout
stdout_file = open(stdout_file_path, 'w')
# Create a file to save the output of stderr
stderr_file_path = 'path/to/stderr_file.txt' # Replace with the path where you want to save stderr
stderr_file = open(stderr_file_path, 'w')
# Redirecting stdout and stderr
sys.stdout = stdout_file
sys.stderr = stderr_file
# Your code here!!!
print("This is stdout message.")
print("This is stderr message.", file=sys.stderr)
# Restore stdout and stderr to default output.
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
# Close file
stdout_file.close()
stderr_file.close()
print("The stdout and stderr outputs have been successfully imported into the file.")