ak-gupta/bayte

View on GitHub

Showing 27 of 27 total issues

File ensemble.py has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""BayesianTargetEstimator.

Ensemble estimator that creates multiple models through sampling.
"""

Severity: Minor
Found in bayte/ensemble.py - About 4 hrs to fix

    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
    
    
    Severity: Minor
    Found in bayte/encoder.py - About 4 hrs to fix

      Function fit has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def fit(
              self,
              X,
              y,
              categorical_feature: Union[List[str], List[int], str] = "auto",
      Severity: Minor
      Found in bayte/ensemble.py - About 3 hrs to fix

      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 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
          ----------
      Severity: Minor
      Found in bayte/encoder.py - About 2 hrs to fix

      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_model has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def init_model(algorithm: str, metadata: Dict, seed: int = 42):
          """Initialize a model object.
      
          Parameters
          ----------
      Severity: Minor
      Found in experiments/tasks/model.py - About 1 hr to fix

      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__(
      Severity: Major
      Found in bayte/encoder.py - About 1 hr to fix

        Function init_encoder has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def init_encoder(algorithm: str, metadata: Dict, residual: bool = False):
            """Initialize a categorical encoder.
        
            Parameters
            ----------
        Severity: Minor
        Found in experiments/tasks/encode.py - About 1 hr to fix

        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 gen_flow has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def gen_flow(
        Severity: Major
        Found in experiments/flow.py - About 1 hr to fix

          Function transform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def transform(self, X):
                  """Transform the input dataset.
          
                  Parameters
                  ----------
          Severity: Minor
          Found in bayte/encoder.py - About 55 mins to fix

          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 _sample_and_fit has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def _sample_and_fit(
          Severity: Major
          Found in bayte/ensemble.py - About 50 mins to fix

            Function compare has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def compare(dataset, algorithm, encoder, n_estimators, seeds, marginal, residual):
            Severity: Major
            Found in run_experiments.py - About 50 mins to fix

              Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(
              Severity: Major
              Found in bayte/ensemble.py - About 50 mins to fix

                Function train has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def train(
                Severity: Minor
                Found in experiments/tasks/model.py - About 45 mins to fix

                  Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(
                  Severity: Minor
                  Found in bayte/ensemble.py - About 45 mins to fix

                    Function fit_encoder has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def fit_encoder(
                    Severity: Minor
                    Found in experiments/tasks/encode.py - About 45 mins to fix

                      Function _encode_level has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def _encode_level(mask, dist, sample, params, random_state):
                      Severity: Minor
                      Found in bayte/encoder.py - About 35 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return y.shape[0] * alpha, 0, np.sum(y)
                        Severity: Major
                        Found in bayte/encoder.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return LGBMClassifier(random_state=seed)
                          Severity: Major
                          Found in experiments/tasks/model.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return TargetEncoder()
                            Severity: Major
                            Found in experiments/tasks/encode.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return GradientBoostingClassifier(random_state=seed)
                              Severity: Major
                              Found in experiments/tasks/model.py - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language