title: Getting a memory error when using sklearn.cluster Kmeans
body: <p>As the title states I'm getting a memory error when I try use <code>kmeans.fit()</code>.</p>
  
  <p>The data set I'm using has size:</p>
  
  <pre><code>print(np.size(np_list)): 1248680000
  print(np_list.shape): (31217, 40000)
  </code></pre>
  
  <p>My code, I'm running that gives me a memory error is:</p>
  
  <pre><code>with open('np_array.pickle', 'rb') as handle:
      np_list = pickle.load(handle)
  
  
  kmeans = KMeans(n_clusters=5)
  kmeans.fit(np_list)
  
  centroids = kmeans.cluster_centers_
  labels = kmeans.labels_
  
  print(centroids)
  print(labels)
  </code></pre>
  
  <p>I'm working with a data set of 32k images each of which are black and white and were originally 200x200. I turned the 200x200 dimension into a single dimension of 40k in row major order.</p>
  
  <p>Description of traceback:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Project/ML_Clustering.py", line 54, in &lt;module&gt;
      kmeans.fit(np_list)
    File "C:\Users\me\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\cluster\k_means_.py", line 896, in fit
      return_n_iter=True)
    File "C:\Users\me\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\cluster\k_means_.py", line 283, in k_means
      X = as_float_array(X, copy=copy_x)
    File "C:\Users\me\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\utils\validation.py", line 88, in as_float_array
      return X.copy('F' if X.flags['F_CONTIGUOUS'] else 'C') if copy else X
  MemoryError
  </code></pre>