Showing 2,238 of 2,238 total issues

File model_trainers.py has 453 lines of code (exceeds 400 allowed). Consider refactoring.
Open

import copy
import datetime
import importlib

import verboselogs, logging
Severity: Minor
Found in src/triage/component/catwalk/model_trainers.py - About 3 hrs to fix

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

        def evaluate(
            self, predictions_proba, matrix_store, model_id, protected_df=None, subset=None
        ):
            """Evaluate a model based on predictions, and save the results
    
    
    Severity: Minor
    Found in src/triage/component/catwalk/evaluation.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

    ModelGroupEvaluator has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ModelGroupEvaluator:
        '''
        ModelGroup class calls the model group metadata from the database
        and hold metadata features on each of the class attibutes.
        This class will contain any information about the model_group, and
    Severity: Minor
    Found in src/triage/component/postmodeling/contrast/model_group_evaluator.py - About 3 hrs to fix

      Function plot_cats has 24 arguments (exceeds 5 allowed). Consider refactoring.
      Open

      def plot_cats(
      Severity: Major
      Found in src/triage/component/audition/plotting.py - About 2 hrs to fix

        MatrixStore has 25 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class MatrixStore:
            """Base class for classes that allow access of a matrix and its metadata.
        
            Subclasses should be scoped to a storage format (e.g. CSV)
                and implement the _load, save, and head_of_matrix methods for that storage format
        Severity: Minor
        Found in src/triage/component/catwalk/storage.py - About 2 hrs to fix

          Function populate_crosstabs_table has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          def populate_crosstabs_table(
              model_id,
              as_of_date,
              df,
              thresholds=None,
          Severity: Minor
          Found in src/triage/component/postmodeling/crosstabs.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_matrix has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def build_matrix(
                  self,
                  as_of_times,
                  label_name,
                  label_type,
          Severity: Minor
          Found in src/triage/component/architect/builders.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 _get_impute_select has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def _get_impute_select(self, impute_cols, nonimpute_cols, partitionby=None):
          
                  imprules = self.get_imputation_rules()
          
                  # check if we're missing any columns relative to the full set and raise an
          Severity: Minor
          Found in src/triage/component/collate/collate.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 test_imputation_output has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def test_imputation_output(feat_list, exp_imp_cols, feat_table):
              with testing.postgresql.Postgresql() as psql:
                  engine = sqlalchemy.create_engine(psql.url())
          
                  engine.execute("create table states (entity_id int, as_of_date date)")
          Severity: Minor
          Found in src/tests/collate_tests/test_imputation_output.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

          Aggregation has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Aggregation:
              def __init__(
                  self,
                  aggregates,
                  groups,
          Severity: Minor
          Found in src/triage/component/collate/collate.py - About 2 hrs to fix

            File selection_rules.py has 413 lines of code (exceeds 400 allowed). Consider refactoring.
            Open

            import inspect
            import verboselogs, logging
            logger = verboselogs.VerboseLogger(__name__)
            
            from numpy import exp, log, average
            Severity: Minor
            Found in src/triage/component/audition/selection_rules.py - About 2 hrs to fix

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

                  def validate(self, conn):
                      """
                      SpacetimeAggregations ensure that no intervals extend beyond the absolute
                      minimum time.
                      """
              Severity: Minor
              Found in src/triage/component/collate/spacetime.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 test_ModelEvaluator_needs_evaluation_no_bias_audit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

              def test_ModelEvaluator_needs_evaluation_no_bias_audit(db_engine_with_results_schema):
                  # TEST SETUP:
              
                  # create two models: one that has zero evaluations,
                  # one that has an evaluation for precision@100_abs
              Severity: Minor
              Found in src/tests/catwalk_tests/test_evaluation.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 stitch_csvs has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def stitch_csvs(self, features_queries, label_query, matrix_store, matrix_uuid):
                      """
                      Get all features related this matrix_uuid as CSV files, as well as the labels. 
                      Join all the csv elements columnwise and create the final matrix. 
                      The last column is the label. 
              Severity: Major
              Found in src/triage/component/architect/builders.py - About 2 hrs to fix

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

                    def plot_jaccard_preds(self,
                                           param_type=None,
                                           param=None,
                                           model_subset=None,
                                           temporal_comparison=False,
                Severity: Minor
                Found in src/triage/component/postmodeling/contrast/model_group_evaluator.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 retrain has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def retrain(self, prediction_date):
                        """Retrain a model by going back one split from prediction_date, so the as_of_date for training would be (prediction_date - training_label_timespan)
                        
                        Args:
                            prediction_date(str) 
                Severity: Minor
                Found in src/triage/predictlist/__init__.py - About 1 hr to fix

                  Function generate_plans has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def generate_plans(self, matrix_set_definitions, feature_dictionaries):
                          """Create build tasks and update the matrix definitions with UUIDs
                  
                          :param matrix_set_definitions: the temporal information needed to generate each matrix
                          :param feature_dictionaries: combinations of features to include in matrices
                  Severity: Minor
                  Found in src/triage/component/architect/planner.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 _final_model_group_args has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _final_model_group_args(self, class_path, parameters, matrix_metadata):
                          """Generates model grouping arguments based on input.
                  
                          Applies a set of default or custom grouping keys depending on the object's
                          configuration.
                  Severity: Minor
                  Found in src/triage/component/catwalk/model_grouping.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 colname_aggregate_lookup has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def colname_aggregate_lookup(self):
                          """A reverse lookup from column name to the source collate.Aggregate
                  
                          Will error if the Aggregation contains duplicate column names
                          """
                  Severity: Minor
                  Found in src/triage/component/collate/spacetime.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 test_model_trainer has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  def test_model_trainer(grid_config, default_model_trainer):
                      trainer = default_model_trainer
                      db_engine = trainer.db_engine
                      project_storage = trainer.model_storage_engine.project_storage
                      model_storage_engine = trainer.model_storage_engine
                  Severity: Minor
                  Found in src/tests/catwalk_tests/test_model_trainers.py - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language