title: R caret with reproducible outcome/results
body: <p>I am using the <code>caret</code> package in <code>R</code> for some supervised multivariate analysis. I am trying to add some functionality to my script that will allow for reproducible outcomes whenever the script is run.</p>
  
  <p>I have this setup for using 2 classification models (each model is run separately, not as an enesmble):</p>
  
  <pre><code>library(caret)
  
  load.data = ....
  cleaned.data = cleaning(load.data)
  mycontrol = trainControl(...)
  train, test = createDatapartition(...)
  
  model1 = train(...,
                 data=train, ...,
                 trControl=mycontrol,
                 preprocess=c('center'))
  model2 = train(...,
                 data=train, ...,
                 trControl=mycontrol,
                 preprocess=c('pca'))
  
  feature.importances = ...
  summary(resamples(list(m1=model1,m2=model2)))
  learing_curve_dat(...) #see link 1. below.
  predict()
  Evaluate(....) #see link 2. below
  </code></pre>
  
  <p>Where in this pipeline should I use <a href="http://rfunction.com/archives/62" rel="nofollow noreferrer"><code>set.seed(#)</code></a> and what should <a href="https://stackoverflow.com/a/13605506/4057186"><code>#</code></a> be in order to get reproducible outcomes each time the script is run - or do I just pick any value for <code>#</code> randomly?</p>
  
  <p>Links:</p>
  
  <p><a href="https://www.rdocumentation.org/packages/caret/versions/6.0-76/topics/learing_curve_dat" rel="nofollow noreferrer">1.</a>
  <a href="http://blog.revolutionanalytics.com/2016/03/com_class_eval_metrics_r.html" rel="nofollow noreferrer">2.</a></p>