Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verbose = True #7

Open
Blaxzter opened this issue Dec 22, 2021 · 2 comments
Open

Verbose = True #7

Blaxzter opened this issue Dec 22, 2021 · 2 comments

Comments

@Blaxzter
Copy link

Blaxzter commented Dec 22, 2021

The SUOD library clutters my console.
After a bit of digging, I found that in the Parallel(...) call, the parameter verbose is just set to true instead of self.verbose.

Would be nice if it's controlled through the objects verbose parameter.

Thanks for your work.

@Blaxzter
Copy link
Author

If we are at it.
There is a weird print statement.

@gradientsky
Copy link

gradientsky commented Apr 7, 2023

I've made a pull request to address the issue: #12

Workaround

@Blaxzter joblib logs clutter can be addressed via context manager:

import contextlib
import joblib
import builtins as __builtin__

@contextlib.contextmanager
def _joblib_silent_print():
    orig_fn = joblib.Parallel._print
    orig_print = __builtin__.print

    def silent_print(self, msg, msg_args):
        return

    @staticmethod
    def _silent_print():
        pass

    joblib.Parallel._print = silent_print
    __builtin__.print = _silent_print
    try:
        yield
    finally:
        joblib.Parallel._print = orig_fn
        __builtin__.print = orig_print

The call will look like this:

with _joblib_silent_print():
    detector = SUOD(**self.suod_kwargs)
    self.detectors.append(detector.fit(x_train))
    y_val_scores = detector.decision_function(x_val)  # outlier scores

This will remove following lines:

[Parallel(n_jobs=2)]: Using backend LokyBackend with 2 concurrent workers.
[Parallel(n_jobs=2)]: Done   2 out of   2 | elapsed:    1.0s remaining:    0.0s
[Parallel(n_jobs=2)]: Done   2 out of   2 | elapsed:    1.0s finished

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants