yzhao062/Pyod

View on GitHub

Showing 168 of 249 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    class Discriminator(nn.Module):
        def __init__(self, latent_size, data_size):
            super(Discriminator, self).__init__()
            self.layer1 = nn.Linear(latent_size,
                                    math.ceil(math.sqrt(data_size)))
Severity: Major
Found in pyod/models/gaal_base.py and 1 other location - About 1 day to fix
pyod/models/so_gaal.py on lines 42..55

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 166.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

class Discriminator(nn.Module):
    def __init__(self, latent_size, data_size):
        super(Discriminator, self).__init__()
        self.layer1 = nn.Linear(latent_size, math.ceil(math.sqrt(data_size)))
        self.layer2 = nn.Linear(math.ceil(math.sqrt(data_size)), 1)
Severity: Major
Found in pyod/models/so_gaal.py and 1 other location - About 1 day to fix
pyod/models/gaal_base.py on lines 36..50

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 166.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def _parallel_ecdf(n_dims, X):
    """Private method to calculate ecdf in parallel.    
    Parameters
    ----------
    n_dims : int
Severity: Major
Found in pyod/models/copod.py and 1 other location - About 1 day to fix
pyod/models/ecod.py on lines 26..50

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 162.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def _parallel_ecdf(n_dims, X):
    """Private method to calculate ecdf in parallel.
    Parameters
    ----------
    n_dims : int
Severity: Major
Found in pyod/models/ecod.py and 1 other location - About 1 day to fix
pyod/models/copod.py on lines 25..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 162.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

class Generator(nn.Module):
    def __init__(self, latent_size):
        super(Generator, self).__init__()
        self.layer1 = nn.Linear(latent_size, latent_size)
        self.layer2 = nn.Linear(latent_size, latent_size)
Severity: Major
Found in pyod/models/so_gaal.py and 1 other location - About 1 day to fix
pyod/models/gaal_base.py on lines 70..81

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 127.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    class Generator(nn.Module):
        def __init__(self, latent_size):
            super(Generator, self).__init__()
            self.layer1 = nn.Linear(latent_size, latent_size)
            self.layer2 = nn.Linear(latent_size, latent_size)
Severity: Major
Found in pyod/models/gaal_base.py and 1 other location - About 1 day to fix
pyod/models/so_gaal.py on lines 28..39

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 127.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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 374 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 5 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 326 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 325 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 317 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    if self.n_neighbors >= self.n_train_:
                        self.n_neighbors = self.n_train_ - 1
                        warnings.warn("n_neighbors is set to the number of "
                                      "training points minus 1: {0}".format(self.n_train_))
            
            
            Severity: Major
            Found in pyod/models/abod.py and 1 other location - About 3 hrs to fix
            pyod/models/cof.py on lines 110..116

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 66.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                            if dist <= bin_width * tol:
                                outlier_scores[j, i] = out_score_i[n_bins - 1]
                            else:
                                outlier_scores[j, i] = np.min(out_score_i)
            Severity: Major
            Found in pyod/models/hbos.py and 1 other location - About 3 hrs to fix
            pyod/models/hbos.py on lines 258..261

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 63.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                            if dist <= bin_width * tol:
                                outlier_scores[j, i] = out_score_i[optimal_n_bins - 1]
                            else:
                                outlier_scores[j, i] = np.min(out_score_i)
            Severity: Major
            Found in pyod/models/hbos.py and 1 other location - About 3 hrs to fix
            pyod/models/hbos.py on lines 344..347

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 63.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            File ae1svm.py has 292 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            """Using AE-1SVM with Outlier Detection (PyTorch)
               Source: https://arxiv.org/pdf/1804.04888
               There is another implementation of this model by Minh Nghia: https://github.com/minh-nghia/AE-1SVM (Tensorflow)
            """
            Severity: Minor
            Found in pyod/models/ae1svm.py - About 3 hrs to fix

              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

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                    def fit(self, X, y=None):
                        """Fit detector. y is ignored in unsupervised methods.
                        Parameters
                        ----------
                        X : numpy array of shape (n_samples, n_features)
                Severity: Major
                Found in pyod/models/copod.py and 1 other location - About 2 hrs to fix
                pyod/models/ecod.py on lines 94..112

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                    def fit(self, X, y=None):
                        """Fit detector. y is ignored in unsupervised methods.
                        Parameters
                        ----------
                        X : numpy array of shape (n_samples, n_features)
                Severity: Major
                Found in pyod/models/ecod.py and 1 other location - About 2 hrs to fix
                pyod/models/copod.py on lines 92..110

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language