title: How do I use knn model for new data in R?
body: <p>I've just written a knn model in R. However, I don't know how to use the output to predict new data.</p>
  
  <pre><code># split into train (treino) and test (teste)
  treino_index &lt;- sample(seq_len(nrow(iris)), size = round(0.75*nrow(iris)))
  treino &lt;- iris[treino_index, ]
  teste &lt;- iris[-treino_index, ]
  
  # take a look at the sample
  head(treino)
  head(teste)
  
  # save specie from later
  treino_especie = treino$Species
  teste_especie = teste$Species
  
  # exclude species from train and test dataset
  treino = treino[-5]
  teste = teste[-5]
  
  # runs knn
  library(class)
  iris_teste_knn &lt;- knn(train = treino, test = teste, cl= treino_especie,k = 3,prob=TRUE) 
  
  
  # model performance using cross table
  install.packages('gmodels')
  library('gmodels')
  CrossTable(x=teste_especie, y=iris_teste_knn, prop.chisq=FALSE)
  </code></pre>
  
  <p>How do I apply this to new data. Suppose I have a specie with the following parameters: Sepal.Length = 5.0, Sepal.Width = 3.3, Petal.Length = 1.3, Petal.Width = 0.1. How do I know from which specie this come from?</p>