title: Build a Random Forest regressor with Cross Validation from scratch
body: <p>I know this is a very classical question which might be answered many times in this forum, however I could not find any clear answer which explains this clearly from scratch.</p>
  <p>Firstly, imgine that my dataset called my_data has 4 variables such as
  my_data = variable1, variable2, variable3, target_variable</p>
  <p>So, let's come to my problem. I'll explain all my steps and ask your help for where I've been stuck:</p>
  <pre><code># STEP1 : split my_data into [predictors] and [targets]
  
  predictors = my_data[[
  'variable1',
  'variable2',
  'variable3'
  ]]
  
  
  targets = my_data.target_variable
  
  # STEP2 : import the required libraries
  
  from sklearn import cross_validation
  from sklearn.ensemble import RandomForestRegressor
  
  #STEP3 : define a simple Random Forest model attirbutes
  
  model = RandomForestClassifier(n_estimators=100)
  
  
  #STEP4 : Simple K-Fold cross validation. 3 folds.
  
  cv = cross_validation.KFold(len(my_data), n_folds=3,  random_state=30)
  
  # STEP 5
  </code></pre>
  <p>At this step, I want to fit my model based on the training dataset, and then
  use that model on test dataset and predict test targets. I also want to calculate the required statistics such as MSE, r2 etc. for understanding the performance of my model.</p>
  <p>I'd appreciate if someone helps me woth some basic codelines for Step5.</p>