title: How to compute precision,recall and f1 score of an imbalanced dataset for K fold cross validation?
body: <p>I have an imbalanced dataset containing binary classification problem.I have built Random Forest Classifier and used k fold cross validation with 10 folds.</p>
  
  <pre><code>kfold = model_selection.KFold(n_splits=10, random_state=42)
  model=RandomForestClassifier(n_estimators=50) 
  </code></pre>
  
  <p>I got the results of the 10 folds</p>
  
  <pre><code>results = model_selection.cross_val_score(model,features,labels, cv=kfold)
  print results
  [ 0.60666667  0.60333333  0.52333333  0.73        0.75333333  0.72        0.7
    0.73        0.83666667  0.88666667]
  </code></pre>
  
  <p>I have calculated accuracy by taking mean and standard deviation of the results</p>
  
  <pre><code>print("Accuracy: %.3f%% (%.3f%%)") % (results.mean()*100.0, results.std()*100.0)
  Accuracy: 70.900% (10.345%)
  </code></pre>
  
  <p>I have computed my predictions as follows</p>
  
  <pre><code>predictions = cross_val_predict(model, features,labels ,cv=10)
  </code></pre>
  
  <p>Since this is an imbalanced dataset,I would like to calculate precision,recall and f1 score of each fold and average the results.
  How to calculate the values in python?</p>