Exemplo n.º 1
0
scores = []

csv_files = ['11-12.csv','12-13.csv','13-14.csv','14-15.csv','15-16.csv']
for test_sea in csv_files:
    test_data = []
    test_target = []
    data = []
    target = []
    loocv = set(csv_files) - set([test_sea])
    sea = Season(test_sea)
    for date,home,away,res,bet in sea.matches:
         home_standing, home_remain = sea.standing(home,date)
         away_standing, away_remain = sea.standing(away,date)
         #data.append( [ home_standing, home_remain, c2i[sea.lastGame(home,date)], away_standing, away_remain, c2i[sea.lastGame(away,date)], sea.points_on_date(home,date)-sea.points_on_date(away,date) ] )
         test_data.append( [ home_standing, c2i[sea.lastGame(home,date)], away_standing, c2i[sea.lastGame(away,date)], sea.points_on_date(home,date)-sea.points_on_date(away,date) ] )
         feature_names = ['Home standing','Home last game', 'Away standing','Away last game','Point difference']
         test_target.append(c2i[res])
    for csv in loocv:
        sea = Season(csv)
        for date,home,away,res, bet in sea.matches:
             home_standing, home_remain = sea.standing(home,date)
             away_standing, away_remain = sea.standing(away,date)
             #data.append( [ home_standing, home_remain, c2i[sea.lastGame(home,date)], away_standing, away_remain, c2i[sea.lastGame(away,date)], sea.points_on_date(home,date)-sea.points_on_date(away,date) ] )
             data.append( [ home_standing, c2i[sea.lastGame(home,date)], away_standing, c2i[sea.lastGame(away,date)], sea.points_on_date(home,date)-sea.points_on_date(away,date) ] )
             feature_names = ['Home standing','Home last game', 'Away standing','Away last game','Point difference']
             target.append(c2i[res])
    clf = tree.DecisionTreeClassifier(max_depth=3)
    clf = clf.fit(data,target)
    print 'Testing on ',test_sea
    scores.append(clf.score(test_data,test_target))
Exemplo n.º 2
0
scores = []

csv_files = ['11-12.csv', '12-13.csv', '13-14.csv', '14-15.csv', '15-16.csv']
for test_sea in csv_files:
    test_data = []
    test_target = []
    data = []
    target = []
    loocv = set(csv_files) - set([test_sea])
    sea = Season(test_sea)
    for date, home, away, res, bet in sea.matches:
        home_standing, home_remain = sea.standing(home, date)
        away_standing, away_remain = sea.standing(away, date)
        #data.append( [ home_standing, home_remain, c2i[sea.lastGame(home,date)], away_standing, away_remain, c2i[sea.lastGame(away,date)], sea.points_on_date(home,date)-sea.points_on_date(away,date) ] )
        test_data.append([
            home_standing, c2i[sea.lastGame(home, date)], away_standing,
            c2i[sea.lastGame(away, date)],
            sea.points_on_date(home, date) - sea.points_on_date(away, date)
        ])
        feature_names = [
            'Home standing', 'Home last game', 'Away standing',
            'Away last game', 'Point difference'
        ]
        test_target.append(c2i[res])
    for csv in loocv:
        sea = Season(csv)
        for date, home, away, res, bet in sea.matches:
            home_standing, home_remain = sea.standing(home, date)
            away_standing, away_remain = sea.standing(away, date)
            #data.append( [ home_standing, home_remain, c2i[sea.lastGame(home,date)], away_standing, away_remain, c2i[sea.lastGame(away,date)], sea.points_on_date(home,date)-sea.points_on_date(away,date) ] )
            data.append([