Skip to content

Commit a723ead

Browse files
committed
Fixes in ENN
1 parent 95d67da commit a723ead

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

.Rhistory

Whitespace-only changes.

NoiseFiltersPy/ENN.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
from NoiseFiltersPy.Filter import *
66

77
class ENN:
8-
def __init__(self, max_neighbours = ):
9-
self.max_neighbours = max_neighbours
10-
self.filter = Filter(parameters = {"max_neighbours": self.max_neighbours})
8+
def __init__(self, neighbours = 3):
9+
self.neighbours = neighbours
10+
self.filter = Filter(parameters = {"neighbours": self.neighbours})
1111

1212
def __call__(self, data, classes):
1313
self.isNoise = np.array([False] * len(classes))
14-
self.clf = KNeighborsClassifier(n_neighbors = n_neigh, algorithm = 'kd_tree', n_jobs = -1)
14+
self.clf = KNeighborsClassifier(n_neighbors = self.neighbours, algorithm = 'kd_tree', n_jobs = -1)
1515
for indx in range(len(data)):
1616
self.clf.fit(np.delete(data, indx, axis = 0), np.delete(classes, indx, axis = 0))
17-
pred = self.clf.predict(data[indx])
17+
pred = self.clf.predict(data[indx].reshape(1, -1))
1818
self.isNoise[indx] = pred != classes[indx]
1919
self.filter.remIndx = np.argwhere(self.isNoise)
2020
notNoise = np.invert(self.isNoise)

examples/enn_example.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from sklearn import datasets
2+
from NoiseFiltersPy.ENN import ENN
3+
4+
dataset = datasets.load_iris()
5+
data = dataset.data
6+
classes = dataset.target
7+
enn = ENN()
8+
filter = enn(data, classes)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="NoiseFiltersPy",
8-
version="0.0.4",
8+
version="0.0.5",
99
author="Juliana Hosoume and Luis Faina",
1010
author_email="[email protected]",
1111
description="Python implementation of NoiseFiltersR",

0 commit comments

Comments
 (0)