Skip to content

Commit 4117b62

Browse files
Merge pull request #208 from dpr1005/deepsource-transform-49e39c06
Format code with yapf, black, autopep8 and isort
2 parents 55926f4 + 7163d81 commit 4117b62

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

semisupervised/DensityPeaks.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from sklearn.svm import SVC
1717

1818
from instance_selection import ENN
19+
1920
from .utils import split
2021

2122

@@ -31,19 +32,19 @@ class STDPNF:
3132
"""
3233

3334
def __init__(
34-
self,
35-
dc=None,
36-
distance_metric="euclidean",
37-
k=3,
38-
gauss_cutoff=True,
39-
percent=2.0,
40-
density_threshold=None,
41-
distance_threshold=None,
42-
anormal=True,
43-
filtering=False,
44-
classifier=None,
45-
classifier_params=None,
46-
filter_method=None,
35+
self,
36+
dc=None,
37+
distance_metric="euclidean",
38+
k=3,
39+
gauss_cutoff=True,
40+
percent=2.0,
41+
density_threshold=None,
42+
distance_threshold=None,
43+
anormal=True,
44+
filtering=False,
45+
classifier=None,
46+
classifier_params=None,
47+
filter_method=None,
4748
):
4849
"""Semi Supervised Algorithm based on Density Peaks."""
4950
self.dc = dc
@@ -121,8 +122,7 @@ def __auto_select_dc(self):
121122

122123
while True:
123124
nneighs = (
124-
sum([1 for v in self.distances.values() if
125-
v < dc]) / self.n_id ** 2
125+
sum([1 for v in self.distances.values() if v < dc]) / self.n_id**2
126126
)
127127
if 0.01 <= nneighs <= 0.02:
128128
break
@@ -476,7 +476,7 @@ def _fit_stdpnf(self):
476476
while count <= max(self.order.values()):
477477
unlabeled_rows = self.structure_stdnpf.loc[
478478
self.structure_stdnpf["label"] == -1
479-
].index.to_list()
479+
].index.to_list()
480480
unlabeled_indexes = []
481481
for row in unlabeled_rows:
482482
if self.order[row] == count:
@@ -492,7 +492,7 @@ def _fit_stdpnf(self):
492492
else:
493493
labeled_data = self.structure_stdnpf.loc[
494494
self.structure_stdnpf["label"] != -1
495-
]
495+
]
496496
complete = labeled_data["sample"]
497497
complete_y = labeled_data["label"]
498498

@@ -502,15 +502,14 @@ def _fit_stdpnf(self):
502502

503503
labeled_data = self.structure_stdnpf.loc[
504504
self.structure_stdnpf["label"] != -1
505-
]
505+
]
506506
self.classifier_stdpnf.fit(
507507
labeled_data["sample"].tolist(), labeled_data["label"].tolist()
508508
)
509509

510510
count += 1
511511

512-
labeled_data = self.structure_stdnpf.loc[
513-
self.structure_stdnpf["label"] != -1]
512+
labeled_data = self.structure_stdnpf.loc[self.structure_stdnpf["label"] != -1]
514513
self.classifier_stdpnf.fit(
515514
labeled_data["sample"].tolist(), labeled_data["label"].tolist()
516515
)
@@ -533,8 +532,7 @@ def _results_to_structure(self, complete, result):
533532
if not is_in:
534533
results_to_unlabeled.append(r)
535534
for r in results_to_unlabeled:
536-
self.structure_stdnpf.at[
537-
np.array(self.structure_stdnpf["sample"], r)][
535+
self.structure_stdnpf.at[np.array(self.structure_stdnpf["sample"], r)][
538536
"label"
539537
] = -1
540538

0 commit comments

Comments
 (0)