title: How to handle the score method in sklearn?
body: <p>This is an extension from my previous question <a href="https://stackoverflow.com/questions/38411854/how-to-convert-a-groupby-mean-into-a-callable-object">How to convert a groupby().mean() into a callable object?</a></p>
  
  <p>I am grateful for the help that I received from this forum and Alberto Garcia-Raboso in particular who answered my question about this model. </p>
  
  <p>As I proceed, more errors occur. This one seems hard for me to correct. It is about the performance evaluation of the model. I attempted to use .score(pred_values, real_values) but the error suggests the input values are not in the [index]:</p>
  
  <pre><code>KeyError: 'None of [[87.333333333333329, 76.0, 81.5, 87.333333333333329, 87.333333333333329, 76.0, 81.5]] are in the [index]'
  </code></pre>
  
  <p>I am not sure how to explain this. Where is the index and how to access to it and fix the problem? </p>
  
  <p>I have been pondering about this actually for a long while. As I try again, I still cannot solve the problem. I would be grateful to any assistance. Thank you.</p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>from sklearn.base import BaseEstimator, ClassifierMixin
  import pandas as pd
  import numpy as np
  
  class MeanClassifier(BaseEstimator, ClassifierMixin):
      def __init__(self):
          pass
  
      def fit(self, X, y):
          self.name = X
          self.scores = y
          self.data = pd.DataFrame({"name": self.name, "score": self.scores})
          #print(self.data)
          self.means = self.data.groupby(["name"]).mean()
          #print(self.means)
          return self
  
      def predict(self, X):
          return list(self.means.loc[X, 'score'])
  </code></pre>
  
  <p><strong>Data inputs and model testing</strong></p>
  
  <pre><code>names = ["John", "Mary", "Suzie", "John", "John", "Mary", "Suzie"]
  scores = [80, 70, 75, 90, 92, 82, 88]
  dd = pd.DataFrame({"name": names, "score": scores})
  
  ddnames = list(dd['name'])
  ddscores = list(dd['score'])
  
  B = MeanClassifier()
  Bfit = B.fit(ddnames, ddscores)
  
  Bpred = B.predict(dd['name'])
  #print(Bpred)
  
  print(B.score(Bpred, ddscores))  #The error appears here
  </code></pre>