title: Memory allocation error in sklearn random forest classification python
body: <p>I am trying to run sklearn random forest classification on 2,79,900 instances having 5 attributes and 1 class. But i am getting memory allocation error while trying to run the classification at the fit line, it is not able to train the classifier itself. Any suggestions on how to resolve this issue?</p>
  
  <p>The data a is</p>
  
  <p>x,y, day, week, Accuracy</p>
  
  <p>x and y  are the coordinates
  day is which day of the month (1-30)
  the week is which day of the week (1-7)
  and accuracy is an integer </p>
  
  <p>code:</p>
  
  <pre><code>import csv
  import numpy as np
  from sklearn.ensemble import RandomForestClassifier
  
  
  with open("time_data.csv", "rb") as infile:
      re1 = csv.reader(infile)
      result=[]
      ##next(reader, None)
      ##for row in reader:
      for row in re1:
          result.append(row[8])
  
      trainclass = result[:251900]
      testclass = result[251901:279953]
  
  
  with open("time_data.csv", "rb") as infile:
      re = csv.reader(infile)
      coords = [(float(d[1]), float(d[2]), float(d[3]), float(d[4]), float(d[5])) for d in re if len(d) &gt; 0]
      train = coords[:251900]
      test = coords[251901:279953]
  
  print "Done splitting data into test and train data"
  
  clf = RandomForestClassifier(n_estimators=500,max_features="log2", min_samples_split=3, min_samples_leaf=2)
  clf.fit(train,trainclass)
  
  print "Done training"
  score = clf.score(test,testclass)
  print "Done Testing"
  print score
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>line 366, in fit
      builder.build(self.tree_, X, y, sample_weight, X_idx_sorted)
    File "sklearn/tree/_tree.pyx", line 145, in sklearn.tree._tree.DepthFirstTreeBuilder.build
    File "sklearn/tree/_tree.pyx", line 244, in sklearn.tree._tree.DepthFirstTreeBuilder.build
    File "sklearn/tree/_tree.pyx", line 735, in sklearn.tree._tree.Tree._add_node
    File "sklearn/tree/_tree.pyx", line 707, in sklearn.tree._tree.Tree._resize_c
    File "sklearn/tree/_utils.pyx", line 39, in sklearn.tree._utils.safe_realloc
  MemoryError: could not allocate 10206838784 bytes
  </code></pre>