LucaCappelletti94/plot_keras_history

View on GitHub

Showing 13 of 13 total issues

Function _plot_history has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring.
Open

def _plot_history(
    histories: List[pd.DataFrame],
    average_history: Optional[pd.DataFrame] = None,
    standard_deviation_history: Optional[pd.DataFrame] = None,
    style: str = "-",
Severity: Minor
Found in plot_keras_history/plot_keras_history.py - About 1 day 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 plot_keras_history.py has 504 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Methods for plotting a keras model training history."""
import warnings
import matplotlib.pyplot as plt
from typing import List, Dict, Union, Tuple, Callable, Optional
import os
Severity: Major
Found in plot_keras_history/plot_keras_history.py - About 1 day to fix

    Function plot_history has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def plot_history(
        histories: Union[History, List[History], Dict[str, List[float]], pd.DataFrame, List[pd.DataFrame], str, List[str]],
        style: str = "-",
        interpolate: bool = False,
        side: float = 5,
    Severity: Minor
    Found in plot_keras_history/plot_keras_history.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 _plot_history has 17 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _plot_history(
    Severity: Major
    Found in plot_keras_history/plot_keras_history.py - About 2 hrs to fix

      Function plot_history has 17 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def plot_history(
      Severity: Major
      Found in plot_keras_history/plot_keras_history.py - About 2 hrs to fix

        Function show_history has 17 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def show_history(
        Severity: Major
        Found in plot_keras_history/plot_keras_history.py - About 2 hrs to fix

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

          def to_dataframe(history: Union[History, pd.DataFrame, Dict, str]) -> pd.DataFrame:
              """Return given history normalized to a dataframe.
          
              Parameters
              -----------------------------
          Severity: Minor
          Found in plot_keras_history/utils.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

          Avoid deeply nested control flow statements.
          Open

                              if show_standard_deviation and standard_deviation_history is not None:
                                  axis.fill_between(
                                      col.index.values,
                                      values-standard_deviation_history[name].values,
                                      values+standard_deviation_history[name].values,
          Severity: Major
          Found in plot_keras_history/plot_keras_history.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if min_value < 0.0 or max_value > 1.0:
                                    warnings.warn(
                                        (
                                            "Please be advised that you have provided a metric called `{metric}` "
                                            "that is expected to be normalized, i.e. between 0 and 1. The values "
            Severity: Major
            Found in plot_keras_history/plot_keras_history.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if min_value < -1.0 or max_value > 1.0:
                                      warnings.warn(
                                          (
                                              "Please be advised that you have provided a metric called `{metric}` "
                                              "that is expected to be absolutely normalized, i.e. between -1 and 1. The values "
              Severity: Major
              Found in plot_keras_history/plot_keras_history.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if best_point_x is not None:
                                        best_point_y = col.values[best_point_x]
                                        axis.scatter(
                                            [best_point_x],
                                            [best_point_y],
                Severity: Major
                Found in plot_keras_history/plot_keras_history.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if best_point_x is not None:
                                          best_point_y = col.values[best_point_x]
                                          if len(kind) == 0:
                                              kind = f"Best value ({monitor})"
                                          else:
                  Severity: Major
                  Found in plot_keras_history/plot_keras_history.py - About 45 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return pd.read_json(history)
                    Severity: Major
                    Found in plot_keras_history/utils.py - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language