@@ -70,6 +70,22 @@ def __init__(
7070 else :
7171 self .filter = None
7272
73+ self .y = None
74+ self .low = None
75+ self .u = None
76+ self .classifier_stdpnf = None
77+ self .order = None
78+ self .structure = None
79+ self .structure_stdnpf = None
80+ self .n_id = None
81+ self .distances = None
82+ self .max_dis = None
83+ self .min_dis = None
84+ self .rho = None
85+ self .delta = None
86+ self .nneigh = None
87+ self .data = None
88+
7389 def __build_distance (self ):
7490 """
7591 Calculate distance dict.
@@ -182,9 +198,13 @@ def __min_neighbor_and_distance(self):
182198
183199 :return: distance vector, nearest neighbor vector
184200 """
201+ if self .rho is None :
202+ raise ValueError ("Encountered rho as None." )
203+
185204 sort_rho_idx = np .argsort (- self .rho )
186205 delta , nneigh = [float (self .max_dis )] * self .n_id , [0 ] * self .n_id
187206 delta [sort_rho_idx [0 ]] = - 1.0
207+
188208 for i in range (self .n_id ):
189209 for j in range (0 , i ):
190210 old_i , old_j = sort_rho_idx [i ], sort_rho_idx [j ]
@@ -240,6 +260,7 @@ def __step_a(self):
240260 return samples_labeled
241261
242262 def __discover_structure (self ):
263+ """Discovers the under laying structure."""
243264 self ._fit_without ()
244265
245266 def __nan_search (self ):
@@ -343,22 +364,22 @@ def __enane(self, fx, nan, r):
343364
344365 return es , es_pred
345366
346- def __init_values (self , l , u , y ):
367+ def __init_values (self , low , u , y ):
347368 """
348369 It takes in the lower and upper bounds of the data, and the data itself,
349370 and then calculates the distances between the data points,
350371 the maximum distance, the minimum distance, the dc value, the rho
351372 value, the delta value, the number of neighbors, and the structure
352373 of the data
353374
354- :param l : lower bound of the data
375+ :param low : lower bound of the data
355376 :param u: upper bound of the data
356377 :param y: the labels of the data
357378 """
358379 self .y = y
359- self .l = l
380+ self .low = low
360381 self .u = u
361- self .data = np .concatenate ((l , u ), axis = 0 )
382+ self .data = np .concatenate ((low , u ), axis = 0 )
362383 self .n_id = self .data .shape [0 ]
363384 self .distances , self .max_dis , self .min_dis = self .__build_distance ()
364385 self .dc = self .__select_dc ()
@@ -447,14 +468,13 @@ def _fit_stdpnf(self):
447468 Self Training based on Density Peaks and a parameter-free noise
448469 filter.
449470 """
450-
451471 self .__discover_structure ()
452472
453473 nan , lambda_param = self .__nan_search ()
454474 self .classifier_stdpnf = KNeighborsClassifier (
455475 n_neighbors = self .k , metric = self .distance_metric
456476 )
457- self .classifier_stdpnf .fit (self .l , self .y )
477+ self .classifier_stdpnf .fit (self .low , self .y )
458478 count = 1
459479
460480 while count <= max (self .order .values ()):
@@ -530,7 +550,7 @@ def _if_filter(self, complete, complete_y):
530550 :return: The result is a dataframe with the filtered data.
531551 """
532552 if isinstance (self .filter , ENN ):
533- original = pd .DataFrame (self .l )
553+ original = pd .DataFrame (self .low )
534554 original_y = pd .DataFrame (self .y )
535555 result , _ = self .filter .filter_original_complete (
536556 original , original_y , complete , complete_y
0 commit comments