def get_orig_plot_data(self, col, tail=False): # 1 vs 2 plots in the figure pd = {} if tail: num = 10 tail = self.data[col].value_counts().tail(10) pd = tail.to_dict() else: num = 1000 head = self.data[col].value_counts().head(10) pd = head.to_dict() l = [] l.append(list(pd.keys())) l.append(list(pd.values())) return l
def add_to_player_dict(pd, players, date): team_stats = {'fg': 0, 'fga': 0, 'fta': 0, 'mp': 0, 'tov': 0, 'orb': 0, 'drb': 0, 'fg3a': 0} for name in players: stats = players[name] for key in pd.keys(): if key=='name': pd[key].append(name) elif key=='date': pd[key].append(date) else: if stats==None: pd[key].append(None) else: if key in team_stats: team_stats[key] += stats[key] pd[key].append(stats[key]) return team_stats
def evaluate_models_compare_to_stacking_r_square(predictions_dict, true_treatment_effect, stacking_predictions): """ :param predictions_dict: :param true_treatment_effect: :param stacking_predictions: an array of predicitons given by the stacking model :return: a table/array of evaluation metrics for each model """ pd = copy.deepcopy(predictions_dict) if "Actuals" in predictions_dict: pd.pop('Actuals') if "generated_data" in predictions_dict: pd.pop('generated_data') r2_dict = {} for key in pd.keys(): r2_dict[key] = r2_score(true_treatment_effect, pd[key]) r2_dict['stacking'] = r2_score(true_treatment_effect, stacking_predictions) return r2_dict
def get_colums(pd): return " (" + ", ".join(str(key) for key in pd.keys()) + ") "