Skip to content

Commit 0b94ab5

Browse files
Improved code quality based on Codacy report #133
1 parent 364f0b0 commit 0b94ab5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

semisupervised/CoTraining.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def fit(self, samples, y):
9191
size=2 * self.p + 2 * self.n,
9292
replace=False, shuffle=False)
9393
except ValueError:
94-
print(f'The model was incorrectly parametrized, k is to big.')
94+
print('The model was incorrectly parametrized, k is to big.')
9595
try:
9696
u_prime = np.concatenate((u_prime, u[u_random_index]))
9797
except IndexError:

semisupervised/DemocraticCoLearning.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,17 @@ def predict(self, samples):
306306
breakpoint()
307307

308308
confidence = [0 for _ in range(self.n_labels)]
309-
for j in range(len(gj)):
310-
izq = (gj[j] + 0.5) / (gj[j] + 1)
311-
div = True if gj[j] != 0 else False
309+
for index, j in enumerate(gj):
310+
izq = (j + 0.5) / (j + 1)
311+
div = True if j != 0 else False
312312
if div:
313-
der = [(gj_h[0][j] * self.w1) / gj[j],
314-
(gj_h[1][j] * self.w2) / gj[j],
315-
(gj_h[2][j] * self.w3) / gj[j]]
313+
der = [(gj_h[0][index] * self.w1) / gj[index],
314+
(gj_h[1][index] * self.w2) / gj[index],
315+
(gj_h[2][index] * self.w3) / gj[index]]
316316
else:
317317
der = [1 for _ in range(self.n_classifiers)]
318318

319-
confidence[j] = sum([izq * d for d in der]) / len(der)
319+
confidence[index] = sum([izq * d for d in der]) / len(der)
320320

321321
labels = []
322322
pred1 = self.h1.predict(samples)

0 commit comments

Comments
 (0)