import numpy as np
import matplotlib.pyplot as plt
from scikits.learn.machine.manifold_learning.regression.neighbors import \
     Neighbors, Kneighbors, Parzen


n = 100 # number of points
data1 = np.random.randn(n,2) + 3.0
data2 = np.random.randn(n, 2) + 5.0
data = np.concatenate((data1, data2))
labels = [0]*n + [1]*n

# we create the mesh
h = 0.1 # step size
x = np.arange(-2, 12, h)
y = np.arange(-2, 12, h)
X, Y = np.meshgrid(x, y)
Z = np.zeros(X.shape)


neigh = Neighbors(data, labels=labels, k=6)

for i in range(len(x)):
    for j in range(len(y)):
        Z[i,j] = neigh.predict((x[i], y[j]))

ax = plt.subplot(111)
plt.pcolormesh(X, Y, Z)
plt.scatter(data1[:,0], data1[:,1])
plt.scatter(data2[:,0], data2[:,1], c='red')

plt.show()

@@ -155,17 +155,16 @@
 Parzen%0A%0A
-%0A
 n = 100 
@@ -340,17 +340,16 @@
 esh%0Ah = 
-0
 .1 # ste
@@ -434,31 +434,8 @@
  y)%0A
-Z = np.zeros(X.shape)%0A%0A
 %0Anei
@@ -476,80 +476,63 @@
 , k=
-6
+3
 )%0A%0A
+points= %5B(x_i, y_j) 
 for 
+x_
 i in 
-range(len(x)):%0A   
+x
  for 
+y_
 j in 
-range(len(y)):%0A        Z%5Bi,j%5D
+y%5D%0AZ
  =
+ 
  nei
@@ -546,19 +546,41 @@
 ict(
-(x%5Bi%5D, y%5Bj%5D
+points)%0AZ =  Z.reshape(np.shape(X
 ))%0A%0A

Update KNN examples.