Evaluate the prediction error for each user-item pair in the given data
        set.

        Parameters
        ----------
        dataset : SFrame
            An SFrame in the same format as the one used during training.

        target : str
            The name of the target rating column in `dataset`.

        Returns
        -------
        out : dict
            A dictionary with three items: 'rmse_by_user' and 'rmse_by_item',
            which are SFrames containing the average rmse for each user and
            item, respectively; and 'rmse_overall', which is a float.

        Examples
        --------
        >>> import turicreate as tc
        >>> sf = tc.SFrame('https://static.turi.com/datasets/audioscrobbler')
        >>> train, test = tc.recommender.util.random_split_by_user(sf)
        >>> m = tc.recommender.create(train, target='target')
        >>> m.evaluate_rmse(test, target='target')

        See Also
        --------
        turicreate.evaluation.rmse

def evaluate_rmse(self, dataset, target):
        """
        Evaluate the prediction error for each user-item pair in the given data
        set.

        Parameters
        ----------
        dataset : SFrame
            An SFrame in the same format as the one used during training.

        target : str
            The name of the target rating column in `dataset`.

        Returns
        -------
        out : dict
            A dictionary with three items: 'rmse_by_user' and 'rmse_by_item',
            which are SFrames containing the average rmse for each user and
            item, respectively; and 'rmse_overall', which is a float.

        Examples
        --------
        >>> import turicreate as tc
        >>> sf = tc.SFrame('https://static.turi.com/datasets/audioscrobbler')
        >>> train, test = tc.recommender.util.random_split_by_user(sf)
        >>> m = tc.recommender.create(train, target='target')
        >>> m.evaluate_rmse(test, target='target')

        See Also
        --------
        turicreate.evaluation.rmse
        """

        assert target in dataset.column_names(), \
               'Provided dataset must contain a target column with the same \
                name as the target used during training.'
        y = dataset[target]
        yhat = self.predict(dataset)
        user_column = self.user_id
        item_column = self.item_id
        assert user_column in dataset.column_names() and \
               item_column in dataset.column_names(), \
            'Provided data set must have a column pertaining to user ids and \
             item ids, similar to what we had during training.'

        result = dataset[[user_column, item_column]]
        result['sq_error'] = (y - yhat) * (y - yhat)
        rmse_by_user = result.groupby(user_column,
                {'rmse':_turicreate.aggregate.AVG('sq_error'),
                 'count':_turicreate.aggregate.COUNT})
        rmse_by_user['rmse'] = rmse_by_user['rmse'].apply(lambda x: x**.5)
        rmse_by_item = result.groupby(item_column,
                {'rmse':_turicreate.aggregate.AVG('sq_error'),
                 'count':_turicreate.aggregate.COUNT})
        rmse_by_item['rmse'] = rmse_by_item['rmse'].apply(lambda x: x**.5)
        overall_rmse = result['sq_error'].mean() ** .5

        return {'rmse_by_user': rmse_by_user,
                'rmse_by_item': rmse_by_item,
                'rmse_overall': overall_rmse}