title: ValueError: Found array with dim 3. Estimator expected <= 2
body: <p>I'am trying to generate my own training data for recognition problem. I have two folder <code>s0</code> and <code>s1</code> and the folder containing is <code>data</code>.
  <code>images</code>, <code>lables</code> are the two list in which the <code>labels</code> contains the names of the folder. </p>
  
  <pre><code>|—- data
  |    |—- s0
  |    |    |—- 1.pgm
  |    |    |—- 2.pgm
  |    |    |—- 3.pgm
  |    |    |—- 4.pgm
  |    |    |—- ...
  |    |—- s1
  |    |    |—- 1.pgm
  |    |    |—- 2.pgm
  |    |    |—- 3.pgm
  |    |    |—- 4.pgm
  |    |    |—- ...
  </code></pre>
  
  <p>Below is the code, it's showing me an error on line <code>classifier.fit(images, lables)</code></p>
  
  <pre><code> Traceback (most recent call last):
  File "mint.py", line 34, in &lt;module&gt;
   classifier.fit(images, lables)
   File "/usr/local/lib/python2.7/dist-packages/sklearn/svm/base.py",  line 150, in fit
    X = check_array(X, accept_sparse='csr', dtype=np.float64, order='C')
   File "/usr/local/lib/python2.7/dist-   packages/sklearn/utils/validation.py", line 396, in check_array
    % (array.ndim, estimator_name))
  </code></pre>
  
  <p>ValueError: Found array with dim 3. Estimator expected &lt;= 2.
   here</p>
  
  <pre><code>import os,sys
  import cv2
  import numpy as np
  from sklearn.svm import SVC
  fn_dir ='/home/aquib/Desktop/Natural/data'
  
  # Create a list of images and a list of corresponding names
  (images, lables, names, id) = ([], [], {}, 0)
  for (subdirs, dirs, files) in os.walk(fn_dir):
      for subdir in dirs:
        names[id] = subdir
        mypath = os.path.join(fn_dir, subdir)
        for item in os.listdir(mypath):
          if '.png' in item:  
          label=id
          image = cv2.imread(os.path.join(mypath, item),0)
          r_image = np.resize(image,(30,30))
          if image is not None:
              images.append(r_image)
              lables.append(int(label))
        id += 1  
  #Create a Numpy array from the two lists above
  (images, lables) = [np.array(lis) for lis in [images, lables]]
  classifier = SVC(verbose=0, kernel='poly', degree=3)
  classifier.fit(images, lables)
  </code></pre>
  
  <p>I really don't understand how to correct it in 2 dimension.
  I am trying the below codes but the error is same:
     <code>
      images = np.array(images)
      im_sq = np.squeeze(images).shape
      images = images.reshape(images.shape[:2])</code></p>