0

I would like to hide the log info below when I run any code in Pycaret using Google Colab.

compare_models()

enter image description here

I've tried passing the parameter verbose = False, but no difference.

I've also tried:

import logging
logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.CRITICAL)

But no difference.

unstuck
  • 563
  • 2
  • 12
  • 29
  • Is the log info going to `sys.stdout` ? (Or stderr?) Can you redirect that? Also, isn't there a configured [logger](https://docs.python.org/3/library/logging.html#logger-objects) for which you could `setLevel()` to debug instead of info? [Let us know](https://stackoverflow.com/help/self-answer) what solution you settle upon. – J_H Dec 14 '22 at 18:36
  • Actually, I don't know. Where can I find where the log info is going to? – unstuck Dec 14 '22 at 18:38
  • Refer to the cited logger documentation to track down how logging is configured in your particular project. Consider defining a _new_ logger that logs to a file -- that will help you to understand what's going on. – J_H Dec 14 '22 at 18:41
  • Thank, I guess this is not related with python but with Google colab? – unstuck Dec 14 '22 at 18:54
  • No, it should work the same when run within Terminal.app or within colab. You might start by changing the config of [DashboardLogger](https://github.com/pycaret/pycaret/blob/master/pycaret/loggers/dashboard_logger.py). All through the code we see a common idiom of `LOGGER = get_logger()` (from the internal.logging module). That should give you a handle on how to `.setLevel()` to your desired verbosity, or how to silently redirect all of a logger's output to a file. You must read the builtin [logger](https://docs.python.org/3/library/logging.html#logger-objects) docs to solve this. – J_H Dec 14 '22 at 19:02
  • OK, thanks for the links to the docs – unstuck Dec 14 '22 at 19:20

1 Answers1

0

Add this to the top of your notebook.

import os
os.environ["PYCARET_CUSTOM_LOGGING_LEVEL"] = "CRITICAL"

More info can be found in this GitHub Issue: https://github.com/pycaret/pycaret/issues/2440

Nikhil Gupta
  • 1,436
  • 12
  • 15