WebDR: A Web workbence for Data Reduction
Scikit-learn is a free software machine learning library for Python.
import matplotlib.pyplot as plt
from math import sqrt
points = [
[1,1,"Red"],
[1,2,"Red"],
[2,1,"Black"],
[3,4,"Black"],
[4,6,"Black"]
]
plt.title("Points")
plt.xlabel("x")
plt.ylabel("y")
for point in points:
plt.plot(point[1],point[0], "o", color=point[2])
$d_{ij} = \sqrt{ \sum_{i=1}^{p} (X_{ik} - X_{jk})^2 }$
def euc_dis(point1, point2):
return sqrt( (point1[0]-point2[0])**2 + (point1[1]-point2[1])**2 )
def knn(point, points, k):
result = 0;
distance = []
for i in range(len(points)):
distance.append([euc_dis(point, points[i]), points[i][2]])
distance.sort()
for i in range(k):
if distance[i][1] == "Red":
result += 1
else:
result -= 1
if result >= 0:
return "Red"
else:
return "Black"
print("The point [2,1] is:", knn([2,1], points, 3), " with K=3")
print("The point [2,1] is:", knn([2,1], points, 5), " with K=5")
# ENN-rule
# All k-NN
# Multiedit
# CNN-rule
Note: New training data segments can update an existing condensing set in a simple manner and without considering the “old” (removed) data that had been used for the construction of CS
# IB2
CJA properties:
# CJA
# RSP3
The algorithm:
RSP3 properties: