Example #1
0
def test_build_bracket_2017():
    build_bracket(
        teamsPath=pkg_resources.resource_filename('bracketeer', 'tests/input/teams.csv'),
        seedsPath=pkg_resources.resource_filename('bracketeer', 'tests/input/seeds.csv'),
        slotsPath=pkg_resources.resource_filename('bracketeer', 'tests/input/slots.csv'),
        submissionPath=pkg_resources.resource_filename('bracketeer', 'tests/input/sub.csv'),
        year=2017,
        outputPath='output.png'
    )
    assert(os.path.isfile('output.png'))
def build_bracket_output():
    b = build_bracket(outputPath=base_url + 'output.png',
                      teamsPath=base_url + 'data/raw/Teams.csv',
                      seedsPath=base_url + 'data/raw/NCAATourneySeeds.csv',
                      submissionPath=base_url +
                      'data/processed/2019Predictions.csv',
                      slotsPath=base_url + 'data/raw/NCAATourneySlots.csv',
                      year=2019)
from bracketeer import build_bracket

m = build_bracket(outputPath='bracket.png',
                  teamsPath='data/Teams.csv',
                  seedsPath='data/NCAATourneySeeds.csv',
                  submissionPath='SubmissionStage2.csv',
                  slotsPath='data/NCAATourneySlots.csv',
                  year=2019)

# output feedback
print()
print()
print("2019 Bracket creation complete.")
print()
print()
Example #4
0
from bracketeer import build_bracket
b = build_bracket(outputPath='../output/Moutput.png',
                  teamsPath='../Minput2/Teams.csv',
                  seedsPath='../Minput3/NCAATourneySeeds.csv',
                  submissionPath='../output/Mstats_2018_AB.csv',
                  slotsPath='../Minput3/NCAATourneySlots.csv',
                  year=2018)
Example #5
0
              "w") as f:
        f.write("ID,Pred\n")

with open(f"./Results/2021_Stage2_{MODEL_SELECTED}_first_round.csv", "a") as f:
    for i, id, _ in stage_1_comp.itertuples():
        year, t1, t2 = id.split("_")
        year, t1, t2 = int(year), int(t1), int(t2)

        if year not in feature_dfs.keys():
            print(year)
            feature_dfs[year] = pd.read_csv(
                "./Data/Training/features_{:d}.csv".format(year))

        matchup = get_matchup_data(t1, t2, feature_dfs[year])
        matchup = np.array(matchup).reshape(1, -1)
        matchup = scaler.transform(matchup)
        prediction = model.predict_proba(matchup).flatten()
        if write == True:
            f.write(f"{id},{prediction[0]}\n")
        else:
            print(id, prediction[0])

if write:
    b = build_bracket(
        outputPath=f'Results/2021_bracket_{MODEL_SELECTED}_first_round.png',
        teamsPath='Data/Stage2/MTeams.csv',
        seedsPath='Data/Stage2/MNCAATourneySeeds.csv',
        submissionPath=f'Results/2021_Stage2_{MODEL_SELECTED}_first_round.csv',
        slotsPath='Data/Stage2/MNCAATourneySlots.csv',
        resultsPath='Results/first_round_misses.csv',
        year=2021)
Example #6
0
clf = svm.SVC(C=10.0, gamma=.0001, probability=True)
svm_param_grid = {
    'clf__C': np.logspace(start=-3, stop=3, num=7),
    'clf__gamma': np.logspace(start=-4, stop=-1, num=4)
}
clf.fit(train_inputs, train_labels)
res = clf.predict(test_inputs)
print(accuracy_score(test_labels, res))

df_predict = pd.read_csv('./csv_data/SampleSubmissionStage2.csv')

# Create pipeline for scaling and classifying:
pipe = Pipeline([('clf', clf)])

lr_search = GridSearchCV(pipe, svm_param_grid, cv=10)
lr_search.fit(train_inputs, train_labels)
print(lr_search.best_params_)

perm = PermutationImportance(lr_search,
                             random_state=1).fit(test_inputs, test_labels)

predict_poss_matches(lr_search, df_predict,
                     df_features).to_csv('best_model_results2.csv',
                                         index=False)

b = build_bracket(outputPath='best_bracket.png',
                  submissionPath='best_model_results2.csv',
                  teamsPath='./csv_data/Teams.csv',
                  seedsPath='./csv_data/NCAATourneySeeds.csv',
                  slotsPath='./csv_data/NCAATourneySlots.csv',
                  year=2019)
model = pickle.load(open("models/modelv2.sav", "rb"))

print("Getting teams")
print("Predicting matchups")

seeds = pd.read_csv(folder + '/NCAATourneySeeds.csv')
tourney_teams = []
for year in prediction_range:
    for index, row in seeds.iterrows():
        if row['Season'] == year:
            team_seeds[year][row['TeamID']] = row['Seed']
            tourney_teams.append(row['TeamID'])
    tourney_teams.sort()

    get_teams(tourney_teams, year)
    tourney_teams.clear()

prediction_path = 'predictions/submission_1.csv'

print(f"Writing {len(final_data)} results")
with open(prediction_path, 'w', newline='') as f:
    writer = csv.writer(f)
    writer.writerow(['ID', 'Pred'])
    writer.writerows(final_data)

m = build_bracket(outputPath='output.png',
                  teamsPath='Data/Teams.csv',
                  seedsPath='Data/NCAATourneySeeds.csv',
                  submissionPath=prediction_path,
                  slotsPath='Data/NCAATourneySlots.csv',
                  year=prediction_year)
Example #8
0
teamsout = (
    teams[['new_id', 'new_teamname']]
    .rename(columns={'new_id': 'TeamID', 'new_teamname': 'TeamName'})
)
seedsout = (
    seeds[['Season', 'new_seed', 'new_teamid']]
    .rename(columns={'new_seed': 'Seed', 'new_teamid': 'TeamID'})
)
slotsout = (
    slots[['Season', 'new_slot', 'new_strongseed', 'new_weakseed']]
    .rename(columns={'new_slot': 'Slot', 'new_strongseed': 'StrongSeed', 'new_weakseed': 'WeakSeed'})
)
subout = (
    sub[['new_id', 'new_pred']]
    .rename(columns={'new_id': 'ID', 'new_pred': 'Pred'})
)

teamsout.to_csv('input\\teams.csv', index=False)
seedsout.to_csv('input\\seeds.csv', index=False)
slotsout.to_csv('input\\slots.csv', index=False)
subout.to_csv('input\\sub.csv', index=False)

b = build_bracket(
        outputPath='output.png',
        teamsPath='input\\teams.csv',
        seedsPath='input\\seeds.csv',
        submissionPath='submissions\\ensemble_pred.csv',
        slotsPath='input\\slots.csv',
        year=2018
)
Example #9
0
import pip

pip.main(['install', 'binarytree'])
pip.main(['install', 'bracketeer'])

from bracketeer import build_bracket

b = build_bracket(teamsPath='input/Teams.csv',
                  seedsPath='input/NCAATourneySeeds.csv',
                  submissionPath='nbs/predictions.csv',
                  slotsPath='input/NCAATourneySlots.csv',
                  year=2018)