title: R Neural Networks - Iris Dataset Confusion Matrix
body: <p>I don't how to figure the following: 
  1.  Which 30 elements did it predicted ? 
  2. I can't get the ConfusionMatrix working.</p>
  
  <p>Any help appreciated.  Thank you.</p>
  
  <pre><code>library(nnet)
  attach(iris)
  
  library(caret)
  set.seed(3456)
  trainIndex &lt;- createDataPartition(iris$Species, p = .8,
                                 list = F,
                                 times = 1)
  
  irisTrain &lt;- iris[ trainIndex,]
  irisTest  &lt;- iris[-trainIndex,]
  
  irispred &lt;- nnet(Species ~ ., data=irisTrain, size=10)
  predicted &lt;- predict(irispred,irisTest,type="class")
  </code></pre>
  
  <p>output:</p>
  
  <p>predicted &lt;- predict(irispred,irisTest,type="class")</p>
  
  <blockquote>
    <p>predicted
       [1] "setosa"     "setosa"     "setosa"     "setosa"     "setosa"     "setosa"             "setosa"<br>
     [8] "setosa"     "setosa"     "setosa"     "versicolor" "versicolor" "versicolor" "versicolor"
    [15] "versicolor" "versicolor" "virginica"  "versicolor" "versicolor" "versicolor" "virginica" 
    [22] "virginica"  "virginica"  "virginica"  "virginica"  "virginica"  "virginica"  "virginica" 
    [29] "virginica"  "virginica"</p>
  </blockquote>
  
  <p>Confusion Matrix errors, not sure what the should the 2nd argument be:</p>
  
  <p>confusionMatrix(predicted, iris$Species)
  Error in table(data, reference, dnn = dnn, ...) : 
    all arguments must have the same length</p>
  
  <blockquote>
    <p>confusionMatrix(predicted, irisTest, positive=1)
    Error in sort.list(y) : 'x' must be atomic for 'sort.list'
    Have you called 'sort' on a list?
    confusionMatrix(predicted, iris, positive=1)
    Error in sort.list(y) : 'x' must be atomic for 'sort.list'
    Have you called 'sort' on a list?</p>
  </blockquote>