title: Python:key error
body: <p>I'm using scikit-learn for GMM training and am trying to vary the number of mixture components. I ran into problems, which were fixed <a href="https://stackoverflow.com/questions/20398242/python-list-iteration-only-returns-last-value">here</a>.</p>
  
  <p>I ended up with this code:</p>
  
  <pre><code>from sklearn.mixture import GMM
  
  class_names = ['name1','name2','name3']
  covs =  ['spherical', 'diagonal', 'tied', 'full']
  num_comp = [1,2,3]
  models = dict()
  
  for c in class_names:
      for cov in covs:
          models[c,cov] = values = []
          for num in num_comp:
              values.append(GMM(n_components=num,covariance_type=cov, init_params='wmc',n_init=1, n_iter=10))
  print models
  </code></pre>
  
  <p>I'm using the model dict() later on again and am running into problems because I don't know how to work with the dict.</p>
  
  <pre><code>training_data={'name1':'path2data1', 'name2': path2data2, 'name3': path2data3}
  
  for cov in covs:
      for c in class_names:
          for num in num_comp:
              models[c][cov].fit(training_data[c])
  </code></pre>
  
  <p>I get the error "KeyError:'name1'"</p>
  
  <p>I tried models[c,cov].fit(training_data[c]) as well but then I get the error "AttributeError: 'list' object has no attribute 'fit'"</p>
  
  <p>Thanks in advance for any tips!</p>