dssg/catwalk

View on GitHub

Showing 19 of 28 total issues

File model_trainers.py has 422 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from sklearn.model_selection import ParameterGrid

from sqlalchemy.orm import sessionmaker

import importlib
Severity: Minor
Found in catwalk/model_trainers.py - About 6 hrs to fix

    File evaluation.py has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import numpy
    from results_schema import Evaluation
    from catwalk.utils import db_retry, sort_predictions_and_labels
    from catwalk.metrics import *
    from sqlalchemy.orm import sessionmaker
    Severity: Minor
    Found in catwalk/evaluation.py - About 2 hrs to fix

      File storage.py has 256 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from .utils import upload_object_to_key, key_exists, model_cache_key, download_object
      import os
      import pickle
      import pandas
      import yaml
      Severity: Minor
      Found in catwalk/storage.py - About 2 hrs to fix

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

            def __init__(self, penalty='l2', dual=False, tol=1e-4, C=1.0,
        Severity: Major
        Found in catwalk/estimators/classifiers.py - About 1 hr to fix

          Function _write_to_db has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def _write_to_db(
                  self,
                  model_id,
                  matrix_store,
                  predictions,
          Severity: Minor
          Found in catwalk/predictors.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 _write_model_to_db has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _write_model_to_db(
          Severity: Major
          Found in catwalk/model_trainers.py - About 50 mins to fix

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

                def _generate_evaluations(
            Severity: Minor
            Found in catwalk/evaluation.py - About 45 mins to fix

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

                  def evaluate(
              Severity: Minor
              Found in catwalk/evaluation.py - About 45 mins to fix

                Function matrix_with_sorted_columns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def matrix_with_sorted_columns(self, columns):
                        columnset = set(self.columns())
                        desired_columnset = set(columns)
                        if columnset == desired_columnset:
                            if self.columns() != columns:
                Severity: Minor
                Found in catwalk/storage.py - About 45 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 _train_and_store_model has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def _train_and_store_model(
                Severity: Minor
                Found in catwalk/model_trainers.py - About 45 mins to fix

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

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

                    Function _entity_feature_values has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def _entity_feature_values(matrix, feature_name, as_of_date=None):
                        """Finds the value of the given feature for each entity in a matrix
                    
                        Args:
                            matrix (pandas.DataFrame), with index either 'entity_id' or 'entity_id'/'as_of_date'
                    Severity: Minor
                    Found in catwalk/individual_importance/uniform.py - About 45 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 _write_to_db has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def _write_to_db(
                    Severity: Minor
                    Found in catwalk/evaluation.py - About 35 mins to fix

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

                          def process_train_task(
                      Severity: Minor
                      Found in catwalk/model_trainers.py - About 35 mins to fix

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

                            def _write_to_db(
                        Severity: Minor
                        Found in catwalk/predictors.py - About 35 mins to fix

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

                          def uniform_distribution(db_engine, model_id, as_of_date, test_matrix_store, n_ranks):
                          Severity: Minor
                          Found in catwalk/individual_importance/uniform.py - About 35 mins to fix

                            Function evaluate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def evaluate(
                                    self,
                                    predictions_proba,
                                    labels,
                                    model_id,
                            Severity: Minor
                            Found in catwalk/evaluation.py - About 35 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 _generate_evaluations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def _generate_evaluations(
                                    self,
                                    metrics,
                                    parameters,
                                    threshold_config,
                            Severity: Minor
                            Found in catwalk/evaluation.py - About 35 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 _write_model_to_db has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def _write_model_to_db(
                                    self,
                                    class_path,
                                    parameters,
                                    feature_names,
                            Severity: Minor
                            Found in catwalk/model_trainers.py - About 25 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

                            Severity
                            Category
                            Status
                            Source
                            Language