From eb58a145c1e40a57b7126a432f80940c694d1e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20M=2E=20Camacho?= Date: Thu, 18 Aug 2016 12:35:42 +0200 Subject: [PATCH] Added a custom verbose option --- lightfm/lightfm.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lightfm/lightfm.py b/lightfm/lightfm.py index d537c77a..7d394c8b 100644 --- a/lightfm/lightfm.py +++ b/lightfm/lightfm.py @@ -347,8 +347,10 @@ def fit(self, interactions, num_threads: int, optional Number of parallel computation threads to use. Should not be higher than the number of physical cores. - verbose: bool, optional - whether to print progress messages. + verbose: bool or function, optional + if it's a bool, whether to print progress messages; + if it's a function, the print or logging function for printing + progress messages. Returns ------- @@ -404,8 +406,10 @@ def fit_partial(self, interactions, num_threads: int, optional Number of parallel computation threads to use. Should not be higher than the number of physical cores. - verbose: bool, optional - whether to print progress messages. + verbose: bool or function, optional + if it's a bool, whether to print progress messages; + if it's a function, the print or logging function for printing + progress messages. Returns ------- @@ -455,7 +459,9 @@ def fit_partial(self, interactions, for epoch in range(epochs): - if verbose: + if hasattr(verbose, '__call__'): + verbose('Epoch %s' % epoch) + elif verbose: print('Epoch %s' % epoch) self._run_epoch(item_features,