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

Added a custom verbose option #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lightfm/lightfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,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
-------
Expand Down Expand Up @@ -513,8 +515,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
-------
Expand Down Expand Up @@ -567,7 +571,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,
Expand Down