Creates a _pre_fit function to bridge the gap between __init__ and fit: Everything which initializes some state, but does not actually depend on the data, belongs there. This separates concerns a bit and makes it possible to inherit those initializations.
I thought about making this an implicit wrapper (a wrapper defined in learner that inherits signature & docs and automatically prepends a call to pre_fit to every fit call). This might be possible with wrapt and a meta-class, but it would be a little complex. Since it would also be less explicit, it might be a bit confusing for people who are not very familiar with the code. So I just went with an explicit call to _pre_fit for now.
I could imagine to automate the calls to initialize_optimizer and initiialize_regularizer in the future, but again I'm not entirely certain its desirable because it would feel a little "magic".
Description
Creates a
_pre_fit
function to bridge the gap between__init__
andfit
: Everything which initializes some state, but does not actually depend on the data, belongs there. This separates concerns a bit and makes it possible to inherit those initializations.I thought about making this an implicit wrapper (a wrapper defined in
learner
that inherits signature & docs and automatically prepends a call topre_fit
to everyfit
call). This might be possible withwrapt
and a meta-class, but it would be a little complex. Since it would also be less explicit, it might be a bit confusing for people who are not very familiar with the code. So I just went with an explicit call to_pre_fit
for now.I could imagine to automate the calls to
initialize_optimizer
andinitiialize_regularizer
in the future, but again I'm not entirely certain its desirable because it would feel a little "magic".Motivation and Context
https://github.com/kiudee/cs-ranking/pull/157#issuecomment-690261372
How Has This Been Tested?
Pre-commit & test suite.
Does this close/impact existing issues?
Impacts #94, #116, #146.
Types of changes
Checklist: