title: Python image recognition - accessing the dataset
body: <p>I'm writing a Python program to recognize characters on images. I've already chosen a method of recognition and it's not what I'm having the problem with. It's the dataset access that bothers me. We are given a training dataset (pickle file), which contains images stored in a form of a single matrix <code>(NxD)</code>. Each row is one, 60x60 image. We are supposed to implement a function that for matrix <code>X</code> will give us a vector <code>y</code> of predicted class of labels (label being {0...35} - a character/digit that's recognized on the image). </p>
  
  <p>Now, I've read on the topic and all, I'm using HOG for feature extraction, along with a <code>get_features</code> function. I can't understand though how am I supposed to assign <code>x_train</code> and <code>x_val</code>, as well as <code>y_train</code> and <code>y_val</code>, having only what I have in my .pkl file. I decided to try and split the dataset into <code>x_train</code> and <code>x_val</code> randomly, 50-50. I'm getting <code>y</code> vector filled along the way, so should I split it up to get <code>y_val</code> as well? So far, I have this code for my final function (+ first I load the data):</p>
  
  <pre><code>def load_data():
      PICKLE_FILE_PATH = 'train.pkl'
      with open(PICKLE_FILE_PATH, 'rb') as f:
          return pkl.load(f)
  
  def final():
      """ 
      :param x: matrix NxD
      :return: vector Nx1
      """
      train = load_data()
      x = get_features(train['x'])
      N, D = x.shape
      y = np.zeros((N, 1))
      np.random.shuffle(x)
      x_train = x[:50]
      x_val = x[50:]
      # calling functions i'm using for recognition....
      return y
  </code></pre>
  
  <p>Now, I'm getting an error that says: </p>
  
  <pre><code>    x = get_features(train['x'])
  TypeError: tuple indices must be integers or slices, not str
  </code></pre>
  
  <p>After analyzing it for forever, I assume that in .pkl, the <code>(NxD)</code> matrix has one element per row, since it's supposed to contain one image per row. Maybe I'm seeing it wrong? Maybe there is no <code>'x'</code> in .pkl yet, just a nameless matrix? I got lost and I just want to understand how to transform that bit of data I'm given in the .pkl file to my familiar variables, <code>x_train, x_val, y_train, y_val</code> which I all need for recognition. Any tips would be great! </p>