File encoder.py
has 335 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Bayesian target encoder."""
import logging
from typing import Callable, ClassVar, List, Optional, Tuple, Union
Function _encode_level
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def _encode_level(mask, dist, sample, params, random_state):
"""Encode a given level.
Parameters
----------
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __init__
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function transform
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def transform(self, X):
"""Transform the input dataset.
Parameters
----------
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _encode_level
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _encode_level(mask, dist, sample, params, random_state):
Avoid too many return
statements within this function. Open
return np.sum(mask) * alpha + params[0], 0, params[2] / (1 + np.sum(y[mask]))
Avoid too many return
statements within this function. Open
return y.shape[0] * alpha, 0, np.sum(y)
Function _init_prior
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _init_prior(dist: str, y) -> Tuple:
"""Initialize the prior distribution based on the input likelihood.
Parameters
----------
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _update_posterior
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _update_posterior(y, mask, dist, params) -> Tuple:
"""Generate the parameters for the posterior distribution.
Parameters
----------
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"