(self, scores)
return scores_summary
Re-group scores respecting M4 rules.
        :param scores: Scores per group.
        :return: Grouped scores.
Re-group scores respecting M4 rules.
        :param scores: Scores per group.
        :return: Grouped scores.
Re - group scores respecting M4 rules . : param scores : Scores per group . : return : Grouped scores .
def summarize_groups(self, scores):
        """
        Re-group scores respecting M4 rules.
        :param scores: Scores per group.
        :return: Grouped scores.
        """
        scores_summary = OrderedDict()

        def group_count(group_name):
            return len(np.where(self.test_set.groups == group_name)[0])

        weighted_score = {}
        for g in ['Yearly', 'Quarterly', 'Monthly']:
            weighted_score[g] = scores[g] * group_count(g)
            scores_summary[g] = scores[g]

        others_score = 0
        others_count = 0
        for g in ['Weekly', 'Daily', 'Hourly']:
            others_score += scores[g] * group_count(g)
            others_count += group_count(g)
        weighted_score['Others'] = others_score
        scores_summary['Others'] = others_score / others_count

        average = np.sum(list(weighted_score.values())) / len(self.test_set.groups)
        scores_summary['Average'] = average

        return scores_summary
def summarize_groups ( self , scores ) : scores_summary = OrderedDict ( ) def group_count ( group_name ) : return len ( np . where ( self . test_set . groups == group_name ) [ 0 ] ) weighted_score = { } for g in [ 'Yearly' , 'Quarterly' , 'Monthly' ] : weighted_score [ g ] = scores [ g ] * group_count ( g ) scores_summary [ g ] = scores [ g ] others_score = 0 others_count = 0 for g in [ 'Weekly' , 'Daily' , 'Hourly' ] : others_score += scores [ g ] * group_count ( g ) others_count += group_count ( g ) weighted_score [ 'Others' ] = others_score scores_summary [ 'Others' ] = others_score / others_count average = np . sum ( list ( weighted_score . values ( ) ) ) / len ( self . test_set . groups ) scores_summary [ 'Average' ] = average return scores_summary