Function generate_clusters
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def generate_clusters(self) -> Tuple[List[List], List[List]]:
"""
Perform DBSCAN to create the final micro-clusters
Works by grouping dense enough p_micro_clusters (weight >= mu)
with distance <= 2 * self._epsilon
- 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
File denstream.py
has 311 lines of code (exceeds 250 allowed). Consider refactoring. Open
import math
import numpy as np
from collections import deque
from scipy.spatial import distance
from typing import Tuple, List
Function train
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def train(self, case: Case):
"""
"Trains" Denstream by updating micro_clusters with a new point
Parameters
- 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 dbscan
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def dbscan(self, buffer: List) -> None:
"""
Performs DBSCAN to create initial p-micro-clusters
Works by grouping points with distance <= self._epsilon
and filtering groups that are dense enough (weight >= beta * mu)
- 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 add_point
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_point(self, case: Case) -> int:
"""
Tries to add a point to an existing p-micro-cluster at time "t"
Otherwise, tries to add that point to an existing o-micro-clusters
If all fails, creates a new o-micro-cluster with that new point
- 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
Avoid deeply nested control flow statements. Open
if to_add:
connected_clusters[testing_group].append(r_cluster)
change = True
else:
buffer_.append(r_cluster)
Avoid deeply nested control flow statements. Open
for cluster in connected_clusters[testing_group]:
dist = self.euclidean_distance(cluster.centroid,
r_cluster.centroid)
if dist <= 2 * self.epsilon:
to_add = True
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, lambda_: float, beta: float, epsilon: float, mu: int, stream_speed: int, n_features: int):