当前位置: 首页>>代码示例>>Python>>正文


Python Misc.check_input_data方法代码示例

本文整理汇总了Python中Misc.check_input_data方法的典型用法代码示例。如果您正苦于以下问题:Python Misc.check_input_data方法的具体用法?Python Misc.check_input_data怎么用?Python Misc.check_input_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Misc的用法示例。


在下文中一共展示了Misc.check_input_data方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: predict_round

# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import check_input_data [as 别名]
    def predict_round(self, tourney_round, analysis):
        """
        :method: Predict winner of a single round of the tournament.

        :param int tourney_round: round of the tournament to predict.
        :param object analysis: Analysis object
        """
        Misc.check_input_data("Kaggle", "tourney_slots")

        last_round_id_2digit = "R%02d" % (tourney_round - 1)
        current_round_id_1digit = "R%d" % tourney_round
        current_round_id_2digit = "R%02d" % tourney_round

        df = Constants.INPUT_DATA['Kaggle']['tourney_slots']
        tourney_slots = df[df.season == self.season_id]  # slice of tourney_slots DataFrame for current season
        for _id, row in tourney_slots.iterrows():
            if row.slot[:2] == current_round_id_1digit:
                if tourney_round == 6:
                    strongseed = row.strongseed[-2:]
                    weakseed = row.weakseed[-2:]
                else:
                    strongseed = self.zero_pad_seed(row.strongseed)
                    weakseed = self.zero_pad_seed(row.weakseed)
                team_1 = self.bracket[last_round_id_2digit][strongseed]
                team_2 = self.bracket[last_round_id_2digit][weakseed]
                if not team_1 or not team_2:
                    raise Exception("Cannot predict round '%s', do not have results from prior round." % tourney_round)
                winner = analysis.predict_winner(team_1, team_2, self.season_id)

                if tourney_round == 5:
                    slot = row.slot[-2:]
                else:
                    slot = self.zero_pad_seed(row.slot[-2:])
                self.bracket[current_round_id_2digit][slot] = winner
开发者ID:davidcasterton,项目名称:PyMarchMadness,代码行数:36,代码来源:Basketball.py

示例2: populate_1st_round

# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import check_input_data [as 别名]
    def populate_1st_round(self, analysis):
        """
        :method: Populate 1st round of bracket with teams.

        :param object analysis: Analysis object
        """
        Misc.check_input_data("Kaggle", "tourney_slots")
        Misc.check_input_data("Kaggle", "tourney_seeds")

        #variable init
        round_1 = "R00"

        # predict winners for play-in games
        df = Constants.INPUT_DATA['Kaggle']['tourney_slots']
        tourney_slots = df[df.season == self.season_id]  # slice of tourney_slots DataFrame for current season
        for _id, row in tourney_slots.iterrows():
            if row.slot[0] != "R":
                # play-in game
                team_1 = self.get_team_by_seed(row.strongseed)
                team_2 = self.get_team_by_seed(row.weakseed)
                winner = analysis.predict_winner(team_1, team_2, self.season_id)

                slot = self.zero_pad_seed(row.slot)
                self.bracket[round_1][slot] = winner

        # populate non-play-in teams
        df = Constants.INPUT_DATA['Kaggle']['tourney_seeds']
        tourney_seeds = df[df.season == self.season_id]  # slice of tourney_seeds DataFrame for current season
        for _id, row in tourney_seeds.iterrows():
            if len(row.seed) == 3:
                self.bracket[round_1][row.seed] = self.get_team_by_seed(row.seed)
开发者ID:davidcasterton,项目名称:PyMarchMadness,代码行数:33,代码来源:Basketball.py

示例3: data_available

# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import check_input_data [as 别名]
    def data_available(self, season_id):
        Misc.check_input_data("Kaggle", "tourney_seeds", raise_exception=True)

        tournament_year = Constants.SEASON_ID_TO_YEAR.get(season_id)
        file_name = 'summary%s' % str(tournament_year)[-2:]
        result = Misc.check_input_data("KenPomWithIds", file_name, raise_exception=False)

        return result
开发者ID:davidcasterton,项目名称:PyMarchMadness,代码行数:10,代码来源:Perceptron.py

示例4: get_team_by_seed

# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import check_input_data [as 别名]
    def get_team_by_seed(self, seed):
        """
        :method: Get team object from tournament seed string.

        :param string seed: tournament seed string
        :returns: Team object
        :rtype: object
        """
        Misc.check_input_data("Kaggle", "tourney_seeds")

        df = Constants.INPUT_DATA['Kaggle']['tourney_seeds']
        team_df = df[(df.season == self.season_id) & (df.seed == seed)]
        if not team_df.empty:
            team_id = team_df.team.iloc[0]
            team = self.team_factory.get_team(team_id)
        else:
            team = None

        return team
开发者ID:davidcasterton,项目名称:PyMarchMadness,代码行数:21,代码来源:Basketball.py

示例5: add_all_teams

# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import check_input_data [as 别名]
    def add_all_teams(self):
        """:method: Build objects for all teams from Kaggle data & add them to factory."""
        Misc.check_input_data("Kaggle", "tourney_seeds")
        Misc.check_input_data("Kaggle", "teams")

        df_seeds = Constants.INPUT_DATA['Kaggle']['tourney_seeds']
        for _id, row in df_seeds.iterrows():
            # variable init
            season_id = row.season
            team_id = int(row.team)
            tourney_seed = row.seed
            df_teams = Constants.INPUT_DATA['Kaggle']['teams']
            team_name = df_teams[df_teams.id == team_id].name.iloc[0]

            # create Team object
            team = self.get_team(team_id)
            if not team:
                team = self.add_team(team_id, team_name)
            season = team.add_season(season_id)
            season.set_tourney_seed(tourney_seed)
开发者ID:davidcasterton,项目名称:PyMarchMadness,代码行数:22,代码来源:Basketball.py

示例6: data_available

# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import check_input_data [as 别名]
    def data_available(self, season_id):
        Misc.check_input_data("Kaggle", "tourney_seeds", raise_exception=True)

        return True
开发者ID:davidcasterton,项目名称:PyMarchMadness,代码行数:6,代码来源:HighSeed.py

示例7: range

# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import check_input_data [as 别名]
    for i in range(len(kaggle_output_options)):
        prompt += "%s) %s\n" % (i, kaggle_output_options[i])
    user_input = raw_input(prompt)
    # check user input
    if user_input.isdigit() and (int(user_input) in range(num_kaggle_output_options)):
        kaggle_output = kaggle_output_options[int(user_input)]
    else:
        raise Exception("Invalid entry '%s', please enter one of following values %s." % (user_input, range(num_kaggle_output_options)))


    # create TeamFactory
    team_factory = Basketball.TeamFactory()
    team_factory.add_all_teams()

    # analyze each available season
    Misc.check_input_data("Kaggle", "seasons")
    for _, row in Constants.INPUT_DATA['Kaggle']['seasons'].iterrows():
        year = Misc.get_tournament_year(row.years)
        print("Predicting %s NCAA Tournament" % year)

        season_id = Constants.SEASON_YEAR_TO_ID[year]
        if analysis.data_available(season_id):
            tournament = Basketball.Tournament(team_factory, season_id)

            tournament.generate_matchup_probabilities(analysis)
            tournament.generate_bracket(analysis)

            tournaments[row.season] = tournament


开发者ID:davidcasterton,项目名称:PyMarchMadness,代码行数:30,代码来源:__main__.py

示例8: print

# 需要导入模块: import Misc [as 别名]
# 或者: from Misc import check_input_data [as 别名]
    INPUT_DATA[_sub_dir] = {}
    for _file in os.listdir(_sub_path):
        _file_path = os.path.join(_sub_path, _file)
        _file_base_name, _extension = os.path.splitext(_file)
        if _extension == ".csv":
            INPUT_DATA[_sub_dir][_file_base_name] = pandas.read_csv(_file_path)
        elif _extension == ".xls":
            INPUT_DATA[_sub_dir][_file_base_name] = pandas.read_excel(_file_path, 0, index_col=None, na_values=['NA'])
print("Input Data loaded.")

# lookup dictionaries based on input data
SEASON_ID_TO_YEAR = {}
DIVISIONS = {}
SEASON_YEAR_TO_ID = {}
if Misc.check_input_data("Kaggle", "seasons", raise_exception=False):
    df = INPUT_DATA['Kaggle']['seasons']
    for _, row in df.iterrows():
        season_id = row['season']
        tournament_year = Misc.get_tournament_year(row['years'])

        SEASON_YEAR_TO_ID[tournament_year] = season_id
        SEASON_ID_TO_YEAR[season_id] = tournament_year
        DIVISIONS[season_id] = {
            "W": row['regionW'],
            "X": row['regionX'],
            "Y": row['regionY'],
            "Z": row['regionZ'],
        }

# blank tournament bracket
开发者ID:davidcasterton,项目名称:PyMarchMadness,代码行数:32,代码来源:Constants.py


注:本文中的Misc.check_input_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。