title: How to tune random forest code for quality prediction
body: <p>I am new to machine learning.I have got this dataset - <a href="http://archive.ics.uci.edu/ml/datasets/Wine+Quality" rel="nofollow noreferrer">http://archive.ics.uci.edu/ml/datasets/Wine+Quality</a>. I have to predict Quality of wine which is the last column on the dataset.I thought about applying Neural network or random forest for this, where as NN gave around 55% accuracy, with random forest I managed to get 73% so far. I want to improve the accuracy further.Below is code I have written.</p>
  
  <pre><code>wineq &lt;- read.csv("wine-quality.csv",header = TRUE)
  str(wineq)
  
  wineq$taste &lt;- ifelse(wineq$quality &lt; 6, 'bad', 'good')
  wineq$taste[wineq$quality == 6] &lt;- 'normal'
  wineq$taste &lt;- as.factor(wineq$taste)
  set.seed(54321)
  train &lt;- sample(1:nrow(wineq), .75 * nrow(wineq))
  wineq_train &lt;- wineq[train, ]
  wineq_test  &lt;- wineq[-train, ]
  
  library(randomForest)
  
  rf=randomForest(taste~.- 
  quality,data=wineq_train,importance=TRUE,ntree=100)
  
  rf_preds = predict(rf,wineq_test)
  rf_preds
  table(rf_preds, wineq_test$taste)
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>table(rf_preds, wineq_test$taste)</p>
  </blockquote>
  
  <pre><code>rf_preds bad good normal
  bad    302   11     81
  good     7  163     36
  normal  93  101    431
  </code></pre>
  
  <p>If I want to use <code>tuneRF</code> it gives me below error:</p>
  
  <pre><code>   fgl.res &lt;- tuneRF(x = wineq[train, ], y= wineq[-train, ], 
     stepFactor=1.5)
  </code></pre>
  
  <blockquote>
    <p>Error in randomForest.default(x, y, mtry = mtryStart, ntree =
    ntreeTry,<br>
           : 
           length of response must be the same as predictors</p>
  </blockquote>