File metrics_impl.py
has 3204 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
Function _remove_squeezable_dimensions
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def _remove_squeezable_dimensions(predictions, labels, weights):
"""Squeeze or expand last dim if needed.
Squeezes last dim of `predictions` or `labels` if their rank differs by 1
(using confusion_matrix.remove_squeezable_dimensions).
- Read upRead up
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 auc
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def auc(labels,
Function _maybe_expand_labels
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _maybe_expand_labels(labels, predictions):
"""If necessary, expand `labels` along last dimension to match `predictions`.
Args:
labels: `Tensor` or `SparseTensor` with shape
- Read upRead up
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 compute_auc
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def compute_auc(tp, fn, tn, fp, name):
"""Computes the roc-auc or pr-auc based on confusion counts."""
if curve == 'PR':
if summation_method == 'trapezoidal':
logging.warning(
- Read upRead up
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 recall_at_top_k
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def recall_at_top_k(labels,
Function recall_at_k
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def recall_at_k(labels,
Function sparse_precision_at_k
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def sparse_precision_at_k(labels,
Function precision_at_k
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def precision_at_k(labels,
Function specificity_at_sensitivity
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def specificity_at_sensitivity(labels,
Function precision_at_top_k
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def precision_at_top_k(labels,
Function sensitivity_at_specificity
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def sensitivity_at_specificity(labels,
Function mean_iou
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def mean_iou(labels,
Function precision_at_thresholds
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def precision_at_thresholds(labels,
Function mean_per_class_accuracy
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def mean_per_class_accuracy(labels,
Function false_negatives_at_thresholds
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def false_negatives_at_thresholds(labels,
Function mean_relative_error
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def mean_relative_error(labels,
Function true_positives_at_thresholds
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def true_positives_at_thresholds(labels,
Function recall_at_thresholds
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def recall_at_thresholds(labels,
Function true_negatives_at_thresholds
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def true_negatives_at_thresholds(labels,
Function mean_cosine_distance
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def mean_cosine_distance(labels,
Function sparse_average_precision_at_k
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def sparse_average_precision_at_k(labels,
Function false_positives_at_thresholds
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def false_positives_at_thresholds(labels,
Function average_precision_at_k
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def average_precision_at_k(labels,
Function _streaming_sparse_true_positive_at_k
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _streaming_sparse_true_positive_at_k(labels,
Function percentage_below
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def percentage_below(values,
Function true_negatives
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def true_negatives(labels,
Function precision
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def precision(labels,
Function mean_squared_error
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def mean_squared_error(labels,
Function accuracy
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def accuracy(labels,
Function false_negatives
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def false_negatives(labels,
Function true_positives
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def true_positives(labels,
Function _streaming_sparse_average_precision_at_top_k
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _streaming_sparse_average_precision_at_top_k(labels,
Function false_positives
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def false_positives(labels,
Function recall
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def recall(labels,
Function _streaming_sparse_false_negative_at_k
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _streaming_sparse_false_negative_at_k(labels,
Function root_mean_squared_error
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def root_mean_squared_error(labels,
Function mean_absolute_error
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def mean_absolute_error(labels,
Function _streaming_sparse_false_positive_at_k
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _streaming_sparse_false_positive_at_k(labels,
Function _confusion_matrix_at_thresholds
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _confusion_matrix_at_thresholds(labels,
Function mean
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def mean(values,
Function compute_auc
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def compute_auc(tp, fn, tn, fp, name):
Function _sparse_true_positive_at_k
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _sparse_true_positive_at_k(labels,
Function mean_tensor
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def mean_tensor(values,
Function compute_specificity_at_sensitivity
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def compute_specificity_at_sensitivity(tp, tn, fp, fn, name):
Function compute_sensitivity_at_specificity
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def compute_sensitivity_at_specificity(tp, tn, fp, fn, name):
Function fn
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def fn(distribution, *a):
"""Call `metric_value_fn` in the correct control flow context."""
if hasattr(distribution.extended, '_outer_control_flow_context'):
# If there was an outer context captured before this method was called,
# then we enter that context to create the metric value op. If the
- Read upRead up
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"