medcat.utils.config_utils
Module Contents
Functions
|
|
Attempf fix weighted_average_function. |
|
|
Attributes
- medcat.utils.config_utils.logger
- medcat.utils.config_utils.weighted_average(step, factor)
- Parameters:
step (int) –
factor (float) –
- Return type:
float
- medcat.utils.config_utils.attempt_fix_weighted_average_function(waf)
Attempf fix weighted_average_function.
When saving a model (dill.dump) in older python versions (3.10 and before) and then loading it back up with newer versions of python (3.11 and later) there can be an issue with loading config.linking.weighted_average_function. The value attributed to this is generally a functools.partial. And it loads just fine, but cannot subsequently be called.
This method fixes the issue if the default function is used. It retains the arguments and keyword arguments of the original `partial.
What this method does is recreate the partial function based on the arguments originally provided. Along with the fix, it logs a warning.
However, if a non-default method is used, we are unable to fix it. That is because we do not know which method may have been used. In that case, a warning is logged.
- Parameters:
waf (Callable[[int], float]) – The weighted average function.
- Returns:
Callable[[int], float] – The (potentially) fixed function.
- Return type:
Callable[[int], float]
- medcat.utils.config_utils._fix_waf(waf)