title: how to plot KNN clusters boundaries in r
body: <p>I am using iris data for K- nearest neighbour. I have replaced species type with numerical values in data i.e </p>
  
  <pre><code>setosa = 1
  versicolor = 2
  virginica = 3 
  </code></pre>
  
  <p>now I am diving my data into training and testing set . And training this model on the basis of species colmum. </p>
  
  <pre><code># Clustering
  WNew &lt;- iris
  
  
  # Knn Clustering Technique
  
  library(class)
  library(gmodels)
  WNew[is.na(WNew)] &lt;- 0
  WSmallSet&lt;-WNew[1:100,]
  WTestSet&lt;-WNew[100:150,] # testing set
  WLabel&lt;-c(WNew[1:100,5]) # training set
  wTestLabel&lt;-c(WNew[100:150,5])
  kWset1 &lt;- knnSet &lt;- knn(WSmallSet,WTestSet,WLabel,k=3)
  CTab&lt;-CrossTable(x = wTestLabel, y = kWset1,prop.chisq=FALSE)
  </code></pre>
  
  <p>now I want to plot this 3 clusters boundaries on the basis of their boundaries. but i dont know how to do this . Can anyone help me with this.??</p>