yzhao062/Pyod

View on GitHub

Showing 84 of 258 total issues

File thresholds.py has 467 lines of code (exceeds 250 allowed). Consider refactoring.
Open

def AUCP(**kwargs):
    """AUCP class for Area Under Curve Precentage thresholder.

       Use the area under the curve to evaluate a non-parametric means
       to threshold scores generated by the decision_scores where outliers
Severity: Minor
Found in pyod/models/thresholds.py - About 7 hrs to fix

    File torch_utility.py has 365 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    """Utility functions for PyTorch models
    """
    # Author: Tiankai Yang <tiankaiy@usc.edu>
    # License: BSD 2 clause
    Severity: Minor
    Found in pyod/utils/torch_utility.py - About 4 hrs to fix

      Function generate_data_clusters has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      def generate_data_clusters(n_train=1000, n_test=500, n_clusters=2,
                                 n_features=2, contamination=0.1, size='same',
                                 density='same', dist=0.25, random_state=None,
                                 return_in_clusters=False):
          """Utility function to generate synthesized data in clusters.
      Severity: Minor
      Found in pyod/utils/data.py - About 4 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

      File dif.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      """Deep Isolation Forest for Anomaly Detection (DIF)
      """
      # Author: Hongzuo Xu <hongzuoxu@126.edu>
      # License: BSD 2 clause
      Severity: Minor
      Found in pyod/models/dif.py - About 3 hrs to fix

        File kpca.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        """Kernel Principal Component Analysis (KPCA) Outlier Detector
        """
        # Author: Akira Tamamori <tamamori5917@gmail.com>
        # License: BSD 2 clause
        Severity: Minor
        Found in pyod/models/kpca.py - About 3 hrs to fix

          File deep_svdd.py has 318 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          """Deep One-Class Classification for outlier detection
          """
          # Author: Rafal Bodziony <bodziony.rafal@gmail.com> for the TensorFlow version
          # Author: Yuehan Qin <yuehanqi@usc.edu> for the PyTorch version
          Severity: Minor
          Found in pyod/models/deep_svdd.py - About 3 hrs to fix

            Function generate_data_categorical has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

            def generate_data_categorical(n_train=1000, n_test=500, n_features=2,
                                          n_informative=2, n_category_in=2,
                                          n_category_out=2, contamination=0.1,
                                          shuffle=True, random_state=None):
                """Utility function to generate synthesized categorical data.
            Severity: Minor
            Found in pyod/utils/data.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

            Consider simplifying this complex logical expression.
            Open

                if (include_left and include_right) and (param < low or param > high):
                    raise ValueError(
                        '{param_name} is set to {param}. '
                        'Not in the range of [{low}, {high}].'.format(
                            param=param, low=low, high=high, param_name=param_name))
            Severity: Critical
            Found in pyod/utils/utility.py - About 3 hrs to fix

              Function decision_function has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def decision_function(self, X):
                      """Predict raw anomaly score of X using the fitted detector.
              
                      The anomaly score of an input sample is computed based on different
                      detector algorithms. For consistency, outliers are assigned with
              Severity: Minor
              Found in pyod/models/rgraph.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 _calculate_outlier_scores_auto has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              def _calculate_outlier_scores_auto(X, bin_edges, hist, alpha,
                                                 tol):  # pragma: no cover
                  """The internal function to calculate the outlier scores based on
                  the bins and histograms constructed with the training data. The program
                  is optimized through numba. It is excluded from coverage test for
              Severity: Minor
              Found in pyod/models/hbos.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 _calculate_outlier_scores has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              def _calculate_outlier_scores(X, bin_edges, hist, n_bins, alpha,
                                            tol):  # pragma: no cover
                  """The internal function to calculate the outlier scores based on
                  the bins and histograms constructed with the training data. The program
                  is optimized through numba. It is excluded from coverage test for
              Severity: Minor
              Found in pyod/models/hbos.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_weights has 19 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def init_weights(layer, name='kaiming_uniform',
              Severity: Major
              Found in pyod/utils/torch_utility.py - About 2 hrs to fix

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

                    def fit(self, X, y=None):
                        """Fit detector. y is ignored in unsupervised methods.
                
                        Parameters
                        ----------
                Severity: Minor
                Found in pyod/models/deep_svdd.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__ has 18 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(
                Severity: Major
                Found in pyod/models/kpca.py - About 2 hrs to fix

                  Function train has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def train(self, train_loader):
                          """Train the deep learning model.
                  
                          Parameters
                          ----------
                  Severity: Minor
                  Found in pyod/models/base_dl.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_weights has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def init_weights(layer, name='kaiming_uniform',
                                   uniform_a=0.0, uniform_b=1.0,
                                   normal_mean=0.0, normal_std=1.0,
                                   constant_val=0.0,
                                   xavier_gain=1.0,
                  Severity: Minor
                  Found in pyod/utils/torch_utility.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 scale_angles has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def scale_angles(gammas, scaler1=None, scaler2=None):
                      """
                      Scale all angles in which angles <= 90
                      degree will be scaled within [0 - 54.7] and
                      angles > 90 will be scaled within [90 - 126]
                  Severity: Minor
                  Found in pyod/models/rod.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 _build_model has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def _build_model(self):
                  
                          #### Decoder #####
                          dec_in = Input(shape=(self.latent_dim,), name='I1')
                          dec_1 = Dropout(self.dropout_rate)(dec_in)
                  Severity: Major
                  Found in pyod/models/alad.py - About 2 hrs to fix

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

                        def __init__(self, n_features, c=None, use_ae=False, hidden_neurons=None,
                    Severity: Major
                    Found in pyod/models/deep_svdd.py - About 2 hrs to fix

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

                          def __init__(
                      Severity: Major
                      Found in pyod/models/kpca.py - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language