思路:
1.获取NBA2017年的数据
2.格式化处理数据
3.设计统计分析模型
4.特征选取并进行机器学习
NBA的数据是自己在网上获取的csv数据,如下,可以直接保存成csv后缀的文本文件
Date,Start (ET),Visitor/Neutral,PTS,Home/Neutral,PTS,,,Notes
Tue Oct 25 2016,7:30 pm,New York Knicks,88,Cleveland Cavaliers,117,Box Score,,
Tue Oct 25 2016,10:30 pm,San Antonio Spurs,129,Golden State Warriors,100,Box Score,,
Tue Oct 25 2016,10:00 pm,Utah Jazz,104,Portland Trail Blazers,113,Box Score,,
Wed Oct 26 2016,7:30 pm,Brooklyn Nets,117,Boston Celtics,122,Box Score,,
Wed Oct 26 2016,7:00 pm,Dallas Mavericks,121,Indiana Pacers,130,Box Score,OT,
Wed Oct 26 2016,10:30 pm,Houston Rockets,114,Los Angeles Lakers,120,Box Score,,
Wed Oct 26 2016,8:00 pm,Minnesota Timberwolves,98,Memphis Grizzlies,102,Box Score,,
Wed Oct 26 2016,8:00 pm,Charlotte Hornets,107,Milwaukee Bucks,96,Box Score,,
Wed Oct 26 2016,8:00 pm,Denver Nuggets,107,New Orleans Pelicans,102,Box Score,,
Wed Oct 26 2016,7:00 pm,Miami Heat,108,Orlando Magic,96,Box Score,,
Wed Oct 26 2016,8:00 pm,Oklahoma City Thunder,103,Philadelphia 76ers,97,Box Score,,
Wed Oct 26 2016,10:00 pm,Sacramento Kings,113,Phoenix Suns,94,Box Score,,
Wed Oct 26 2016,7:30 pm,Detroit Pistons,91,Toronto Raptors,109,Box Score,,
Thu Oct 27 2016,7:30 pm,Washington Wizards,99,Atlanta Hawks,114,Box Score,,
Thu Oct 27 2016,8:00 pm,Boston Celtics,99,Chicago Bulls,105,Box Score,,
Thu Oct 27 2016,10:30 pm,Los Angeles Clippers,114,Portland Trail Blazers,106,Box Score,,
Thu Oct 27 2016,10:30 pm,San Antonio Spurs,102,Sacramento Kings,94,Box Score,,
Fri Oct 28 2016,7:30 pm,Indiana Pacers,94,Brooklyn Nets,103,Box Score,,
Fri Oct 28 2016,8:30 pm,Houston Rockets,106,Dallas Mavericks,98,Box Score,,
Fri Oct 28 2016,7:30 pm,Orlando Magic,82,Detroit Pistons,108,Box Score,,
Fri Oct 28 2016,8:00 pm,Charlotte Hornets,97,Miami Heat,91,Box Score,,
Fri Oct 28 2016,9:30 pm,Golden State Warriors,122,New Orleans Pelicans,114,Box Score,,
Fri Oct 28 2016,8:00 pm,Phoenix Suns,110,Oklahoma City Thunder,113,Box Score,OT,
Fri Oct 28 2016,7:00 pm,Cleveland Cavaliers,94,Toronto Raptors,91,Box Score,,
Fri Oct 28 2016,9:00 pm,Los Angeles Lakers,89,Utah Jazz,96,Box Score,,
Sat Oct 29 2016,8:00 pm,Indiana Pacers,101,Chicago Bulls,118,Box Score,,
Sat Oct 29 2016,7:00 pm,Boston Celtics,104,Charlotte Hornets,98,Box Score,,
Sat Oct 29 2016,7:30 pm,Orlando Magic,99,Cleveland Cavaliers,105,Box Score,,
Sat Oct 29 2016,9:00 pm,Portland Trail Blazers,115,Denver Nuggets,113,Box Score,OT,
Sat Oct 29 2016,8:00 pm,Brooklyn Nets,108,Milwaukee Bucks,110,Box Score,,
Sat Oct 29 2016,7:30 pm,Memphis Grizzlies,104,New York Knicks,111,Box Score,,
Sat Oct 29 2016,12:30 pm,Atlanta Hawks,104,Philadelphia 76ers,72,Box Score,,
Sat Oct 29 2016,10:30 pm,Minnesota Timberwolves,103,Sacramento Kings,106,Box Score,,
Sat Oct 29 2016,8:00 pm,New Orleans Pelicans,79,San Antonio Spurs,98,Box Score,,
Sun Oct 30 2016,6:00 pm,Milwaukee Bucks,83,Detroit Pistons,98,Box Score,,
Sun Oct 30 2016,8:00 pm,Dallas Mavericks,92,Houston Rockets,93,Box Score,,
Sun Oct 30 2016,4:30 pm,Utah Jazz,75,Los Angeles Clippers,88,Box Score,,
Sun Oct 30 2016,8:00 pm,Washington Wizards,103,Memphis Grizzlies,112,Box Score,OT,
Sun Oct 30 2016,6:00 pm,San Antonio Spurs,106,Miami Heat,99,Box Score,,
Sun Oct 30 2016,7:00 pm,Los Angeles Lakers,96,Oklahoma City Thunder,113,Box Score,,
Sun Oct 30 2016,6:00 pm,Golden State Warriors,106,Phoenix Suns,100,Box Score,,
Mon Oct 31 2016,7:30 pm,Sacramento Kings,95,Atlanta Hawks,106,Box Score,,
Mon Oct 31 2016,7:30 pm,Chicago Bulls,118,Brooklyn Nets,88,Box Score,,
Mon Oct 31 2016,10:30 pm,Phoenix Suns,98,Los Angeles Clippers,116,Box Score,,
Mon Oct 31 2016,7:30 pm,Denver Nuggets,102,Toronto Raptors,105,Box Score,,
Tue Nov 1 2016,6:00 pm,Houston Rockets,120,Cleveland Cavaliers,128,Box Score,,
Tue Nov 1 2016,7:30 pm,New York Knicks,89,Detroit Pistons,102,Box Score,,
Tue Nov 1 2016,7:00 pm,Los Angeles Lakers,108,Indiana Pacers,115,Box Score,,
Tue Nov 1 2016,7:30 pm,Sacramento Kings,96,Miami Heat,108,Box Score,OT,
Tue Nov 1 2016,8:00 pm,Memphis Grizzlies,80,Minnesota Timberwolves,116,Box Score,,
Tue Nov 1 2016,8:00 pm,Milwaukee Bucks,117,New Orleans Pelicans,113,Box Score,,
Tue Nov 1 2016,7:00 pm,Orlando Magic,103,Philadelphia 76ers,101,Box Score,,
Tue Nov 1 2016,10:00 pm,Golden State Warriors,127,Portland Trail Blazers,104,Box Score,,
Tue Nov 1 2016,8:30 pm,Utah Jazz,106,San Antonio Spurs,91,Box Score,,
Wed Nov 2 2016,7:30 pm,Los Angeles Lakers,123,Atlanta Hawks,116,Box Score,,
Wed Nov 2 2016,8:00 pm,Chicago Bulls,100,Boston Celtics,107,Box Score,,
Wed Nov 2 2016,7:30 pm,Detroit Pistons,101,Brooklyn Nets,109,Box Score,,
Wed Nov 2 2016,7:00 pm,Philadelphia 76ers,93,Charlotte Hornets,109,Box Score,,
Wed Nov 2 2016,10:30 pm,Oklahoma City Thunder,85,Los Angeles Clippers,83,Box Score,,
Wed Nov 2 2016,8:00 pm,New Orleans Pelicans,83,Memphis Grizzlies,89,Box Score,OT,
Wed Nov 2 2016,7:30 pm,Houston Rockets,118,New York Knicks,99,Box Score,,
Wed Nov 2 2016,10:00 pm,Portland Trail Blazers,115,Phoenix Suns,118,Box Score,OT,
Wed Nov 2 2016,9:00 pm,Dallas Mavericks,81,Utah Jazz,97,Box Score,,
Wed Nov 2 2016,7:00 pm,Toronto Raptors,113,Washington Wizards,103,Box Score,,
Thu Nov 3 2016,8:00 pm,Boston Celtics,122,Cleveland Cavaliers,128,Box Score,,
Thu Nov 3 2016,10:30 pm,Oklahoma City Thunder,96,Golden State Warriors,122,Box Score,,
Thu Nov 3 2016,8:00 pm,Indiana Pacers,107,Milwaukee Bucks,125,Box Score,,
Thu Nov 3 2016,8:00 pm,Denver Nuggets,102,Minnesota Timberwolves,99,Box Score,,
Thu Nov 3 2016,7:00 pm,Sacramento Kings,94,Orlando Magic,102,Box Score,,
Fri Nov 4 2016,7:30 pm,Charlotte Hornets,99,Brooklyn Nets,95,Box Score,,
Fri Nov 4 2016,8:00 pm,New York Knicks,117,Chicago Bulls,104,Box Score,,
Fri Nov 4 2016,8:30 pm,Portland Trail Blazers,105,Dallas Mavericks,95,Box Score,,
Fri Nov 4 2016,10:30 pm,Golden State Warriors,97,Los Angeles Lakers,117,Box Score,,
Fri Nov 4 2016,8:00 pm,Los Angeles Clippers,99,Memphis Grizzlies,88,Box Score,,
Fri Nov 4 2016,8:00 pm,Phoenix Suns,112,New Orleans Pelicans,111,Box Score,OT,
Fri Nov 4 2016,7:30 pm,Miami Heat,87,Toronto Raptors,96,Box Score,,
Fri Nov 4 2016,9:00 pm,San Antonio Spurs,100,Utah Jazz,86,Box Score,,
Fri Nov 4 2016,7:00 pm,Atlanta Hawks,92,Washington Wizards,95,Box Score,,
Sat Nov 5 2016,7:30 pm,Houston Rockets,97,Atlanta Hawks,112,Box Score,,
Sat Nov 5 2016,7:00 pm,Denver Nuggets,86,Detroit Pistons,103,Box Score,,
Sat Nov 5 2016,7:00 pm,Chicago Bulls,94,Indiana Pacers,111,Box Score,,
Sat Nov 5 2016,8:00 pm,Sacramento Kings,91,Milwaukee Bucks,117,Box Score,,
Sat Nov 5 2016,6:00 pm,Minnesota Timberwolves,92,Oklahoma City Thunder,112,Box Score,,
Sat Nov 5 2016,7:00 pm,Washington Wizards,86,Orlando Magic,88,Box Score,,
Sat Nov 5 2016,7:00 pm,Cleveland Cavaliers,102,Philadelphia 76ers,101,Box Score,,
Sat Nov 5 2016,8:30 pm,Los Angeles Clippers,116,San Antonio Spurs,92,Box Score,,
Sun Nov 6 2016,7:30 pm,Denver Nuggets,123,Boston Celtics,107,Box Score,,
Sun Nov 6 2016,7:00 pm,Milwaukee Bucks,75,Dallas Mavericks,86,Box Score,OT,
Sun Nov 6 2016,9:30 pm,Phoenix Suns,108,Los Angeles Lakers,119,Box Score,,
Sun Nov 6 2016,3:30 pm,Portland Trail Blazers,100,Memphis Grizzlies,94,Box Score,,
Sun Nov 6 2016,12:00 pm,Utah Jazz,114,New York Knicks,109,Box Score,,
Sun Nov 6 2016,6:00 pm,Sacramento Kings,96,Toronto Raptors,91,Box Score,,
Mon Nov 7 2016,8:00 pm,Orlando Magic,80,Chicago Bulls,112,Box Score,,
Mon Nov 7 2016,7:00 pm,Indiana Pacers,100,Charlotte Hornets,122,Box Score,,
Mon Nov 7 2016,10:30 pm,New Orleans Pelicans,106,Golden State Warriors,116,Box Score,,
Mon Nov 7 2016,10:30 pm,Detroit Pistons,82,Los Angeles Clippers,114,Box Score,,
Mon Nov 7 2016,8:00 pm,Miami Heat,85,Oklahoma City Thunder,97,Box Score,,
Mon Nov 7 2016,7:00 pm,Utah Jazz,109,Philadelphia 76ers,84,Box Score,,
Mon Nov 7 2016,7:00 pm,Houston Rockets,114,Washington Wizards,106,Box Score,,
Tue Nov 8 2016,7:30 pm,Minnesota Timberwolves,110,Brooklyn Nets,119,Box Score,,
Tue Nov 8 2016,7:00 pm,Atlanta Hawks,110,Cleveland Cavaliers,106,Box Score,,
Tue Nov 8 2016,10:30 pm,Dallas Mavericks,109,Los Angeles Lakers,97,Box Score,,
Tue Nov 8 2016,8:00 pm,Denver Nuggets,107,Memphis Grizzlies,108,Box Score,,
Tue Nov 8 2016,10:00 pm,Phoenix Suns,121,Portland Trail Blazers,124,Box Score,,
Tue Nov 8 2016,10:30 pm,New Orleans Pelicans,94,Sacramento Kings,102,Box Score,,
Wed Nov 9 2016,7:30 pm,Chicago Bulls,107,Atlanta Hawks,115,Box Score,,
Wed Nov 9 2016,7:00 pm,Utah Jazz,98,Charlotte Hornets,104,Box Score,,
Wed Nov 9 2016,10:30 pm,Dallas Mavericks,95,Golden State Warriors,116,Box Score,,
Wed Nov 9 2016,7:00 pm,Philadelphia 76ers,115,Indiana Pacers,122,Box Score,OT,
Wed Nov 9 2016,10:30 pm,Portland Trail Blazers,80,Los Angeles Clippers,111,Box Score,,
Wed Nov 9 2016,7:00 pm,Brooklyn Nets,96,New York Knicks,110,Box Score,,
Wed Nov 9 2016,8:00 pm,Toronto Raptors,112,Oklahoma City Thunder,102,Box Score,,
Wed Nov 9 2016,7:00 pm,Minnesota Timberwolves,123,Orlando Magic,107,Box Score,,
Wed Nov 9 2016,9:00 pm,Detroit Pistons,100,Phoenix Suns,107,Box Score,,
Wed Nov 9 2016,9:30 pm,Houston Rockets,101,San Antonio Spurs,99,Box Score,,
Wed Nov 9 2016,7:00 pm,Boston Celtics,93,Washington Wizards,118,Box Score,,
Thu Nov 10 2016,9:00 pm,Golden State Warriors,125,Denver Nuggets,101,Box Score,,
Thu Nov 10 2016,8:00 pm,Chicago Bulls,98,Miami Heat,95,Box Score,,
Thu Nov 10 2016,8:00 pm,New Orleans Pelicans,112,Milwaukee Bucks,106,Box Score,,
Thu Nov 10 2016,10:30 pm,Los Angeles Lakers,101,Sacramento Kings,91,Box Score,,
Fri Nov 11 2016,7:30 pm,New York Knicks,87,Boston Celtics,115,Box Score,,
Fri Nov 11 2016,7:00 pm,Toronto Raptors,113,Charlotte Hornets,111,Box Score,,
Fri Nov 11 2016,8:00 pm,Los Angeles Clippers,110,Oklahoma City Thunder,108,Box Score,,
Fri Nov 11 2016,7:00 pm,Utah Jazz,87,Orlando Magic,74,Box Score,,
Fri Nov 11 2016,7:00 pm,Indiana Pacers,105,Philadelphia 76ers,109,Box Score,OT,
Fri Nov 11 2016,10:00 pm,Sacramento Kings,120,Portland Trail Blazers,122,Box Score,OT,
Fri Nov 11 2016,8:30 pm,Detroit Pistons,86,San Antonio Spurs,96,Box Score,,
Fri Nov 11 2016,7:00 pm,Cleveland Cavaliers,105,Washington Wizards,94,Box Score,,
Sat Nov 12 2016,7:30 pm,Philadelphia 76ers,96,Atlanta Hawks,117,Box Score,,
Sat Nov 12 2016,8:00 pm,Washington Wizards,95,Chicago Bulls,106,Box Score,,
Sat Nov 12 2016,9:00 pm,Detroit Pistons,106,Denver Nuggets,95,Box Score,,
Sat Nov 12 2016,8:00 pm,San Antonio Spurs,106,Houston Rockets,100,Box Score,,
Sat Nov 12 2016,7:00 pm,Boston Celtics,105,Indiana Pacers,99,Box Score,,
Sat Nov 12 2016,8:00 pm,Utah Jazz,102,Miami Heat,91,Box Score,,
Sat Nov 12 2016,8:30 pm,Memphis Grizzlies,96,Milwaukee Bucks,106,Box Score,,
Sat Nov 12 2016,8:00 pm,Los Angeles Clippers,119,Minnesota Timberwolves,105,Box Score,,
Sat Nov 12 2016,7:00 pm,Los Angeles Lakers,126,New Orleans Pelicans,99,Box Score,,
Sat Nov 12 2016,9:00 pm,Brooklyn Nets,122,Phoenix Suns,104,Box Score,,
Sat Nov 12 2016,7:30 pm,New York Knicks,107,Toronto Raptors,118,Box Score,,
Sun Nov 13 2016,3:30 pm,Charlotte Hornets,93,Cleveland Cavaliers,100,Box Score,,
Sun Nov 13 2016,8:00 pm,Phoenix Suns,120,Golden State Warriors,133,Box Score,,
Sun Nov 13 2016,7:00 pm,Los Angeles Lakers,99,Minnesota Timberwolves,125,Box Score,,
Sun Nov 13 2016,7:00 pm,Orlando Magic,119,Oklahoma City Thunder,117,Box Score,,
Sun Nov 13 2016,9:00 pm,Denver Nuggets,105,Portland Trail Blazers,112,Box Score,,
Mon Nov 14 2016,7:30 pm,Oklahoma City Thunder,88,Detroit Pistons,104,Box Score,,
Mon Nov 14 2016,8:00 pm,Philadelphia 76ers,88,Houston Rockets,115,Box Score,,
Mon Nov 14 2016,7:00 pm,Orlando Magic,69,Indiana Pacers,88,Box Score,,
Mon Nov 14 2016,10:30 pm,Brooklyn Nets,95,Los Angeles Clippers,127,Box Score,,
Mon Nov 14 2016,8:00 pm,Boston Celtics,105,New Orleans Pelicans,106,Box Score,,
Mon Nov 14 2016,7:30 pm,Dallas Mavericks,77,New York Knicks,93,Box Score,,
Mon Nov 14 2016,8:30 pm,Miami Heat,90,San Antonio Spurs,94,Box Score,,
Mon Nov 14 2016,9:00 pm,Memphis Grizzlies,102,Utah Jazz,96,Box Score,,
Tue Nov 15 2016,7:00 pm,Toronto Raptors,117,Cleveland Cavaliers,121,Box Score,,
Tue Nov 15 2016,10:30 pm,Brooklyn Nets,118,Los Angeles Lakers,125,Box Score,,
Tue Nov 15 2016,7:30 pm,Atlanta Hawks,93,Miami Heat,90,Box Score,,
Tue Nov 15 2016,8:00 pm,Charlotte Hornets,115,Minnesota Timberwolves,108,Box Score,,
Tue Nov 15 2016,10:00 pm,Chicago Bulls,113,Portland Trail Blazers,88,Box Score,,
Wed Nov 16 2016,7:30 pm,Milwaukee Bucks,100,Atlanta Hawks,107,Box Score,,
Wed Nov 16 2016,7:30 pm,Dallas Mavericks,83,Boston Celtics,90,Box Score,,
Wed Nov 16 2016,9:00 pm,Phoenix Suns,104,Denver Nuggets,120,Box Score,,
Wed Nov 16 2016,7:00 pm,Cleveland Cavaliers,93,Indiana Pacers,103,Box Score,,
Wed Nov 16 2016,10:30 pm,Memphis Grizzlies,111,Los Angeles Clippers,107,Box Score,,
Wed Nov 16 2016,7:30 pm,Detroit Pistons,102,New York Knicks,105,Box Score,,
Wed Nov 16 2016,8:00 pm,Houston Rockets,103,Oklahoma City Thunder,105,Box Score,,
Wed Nov 16 2016,7:00 pm,New Orleans Pelicans,82,Orlando Magic,89,Box Score,,
Wed Nov 16 2016,7:00 pm,Washington Wizards,102,Philadelphia 76ers,109,Box Score,,
Wed Nov 16 2016,10:30 pm,San Antonio Spurs,110,Sacramento Kings,105,Box Score,,
Wed Nov 16 2016,8:00 pm,Golden State Warriors,127,Toronto Raptors,121,Box Score,,
Thu Nov 17 2016,8:00 pm,Portland Trail Blazers,109,Houston Rockets,126,Box Score,,
Thu Nov 17 2016,7:30 pm,Milwaukee Bucks,73,Miami Heat,96,Box Score,,
Thu Nov 17 2016,8:00 pm,Philadelphia 76ers,86,Minnesota Timberwolves,110,Box Score,,
Thu Nov 17 2016,10:30 pm,Chicago Bulls,85,Utah Jazz,77,Box Score,,
Thu Nov 17 2016,7:00 pm,New York Knicks,112,Washington Wizards,119,Box Score,,
Fri Nov 18 2016,8:00 pm,Golden State Warriors,104,Boston Celtics,88,Box Score,,
Fri Nov 18 2016,7:00 pm,Atlanta Hawks,96,Charlotte Hornets,100,Box Score,,
Fri Nov 18 2016,7:30 pm,Detroit Pistons,81,Cleveland Cavaliers,104,Box Score,,
Fri Nov 18 2016,8:30 pm,Memphis Grizzlies,80,Dallas Mavericks,64,Box Score,,
Fri Nov 18 2016,9:00 pm,Toronto Raptors,113,Denver Nuggets,111,Box Score,OT,
Fri Nov 18 2016,7:00 pm,Phoenix Suns,116,Indiana Pacers,96,Box Score,,
Fri Nov 18 2016,10:30 pm,San Antonio Spurs,116,Los Angeles Lakers,107,Box Score,,
Fri Nov 18 2016,8:00 pm,Portland Trail Blazers,101,New Orleans Pelicans,113,Box Score,,
Fri Nov 18 2016,8:00 pm,Brooklyn Nets,105,Oklahoma City Thunder,124,Box Score,,
Fri Nov 18 2016,10:30 pm,Los Angeles Clippers,121,Sacramento Kings,115,Box Score,,
Sat Nov 19 2016,7:00 pm,Boston Celtics,94,Detroit Pistons,92,Box Score,,
Sat Nov 19 2016,5:00 pm,Utah Jazz,102,Houston Rockets,111,Box Score,,
Sat Nov 19 2016,10:30 pm,Chicago Bulls,95,Los Angeles Clippers,102,Box Score,,
Sat Nov 19 2016,8:00 pm,Minnesota Timberwolves,71,Memphis Grizzlies,93,Box Score,,
Sat Nov 19 2016,8:30 pm,Golden State Warriors,124,Milwaukee Bucks,121,Box Score,,
Sat Nov 19 2016,7:00 pm,Charlotte Hornets,116,New Orleans Pelicans,121,Box Score,OT,
Sat Nov 19 2016,7:00 pm,Dallas Mavericks,87,Orlando Magic,95,Box Score,,
Sat Nov 19 2016,7:30 pm,Phoenix Suns,105,Philadelphia 76ers,120,Box Score,,
Sat Nov 19 2016,7:00 pm,Miami Heat,114,Washington Wizards,111,Box Score,,
Sun Nov 20 2016,3:30 pm,Portland Trail Blazers,129,Brooklyn Nets,109,Box Score,,
Sun Nov 20 2016,9:00 pm,Utah Jazz,91,Denver Nuggets,105,Box Score,,
Sun Nov 20 2016,9:30 pm,Chicago Bulls,118,Los Angeles Lakers,110,Box Score,,
Sun Nov 20 2016,12:00 pm,Atlanta Hawks,94,New York Knicks,104,Box Score,,
Sun Nov 20 2016,7:00 pm,Indiana Pacers,115,Oklahoma City Thunder,111,Box Score,OT,
Sun Nov 20 2016,9:00 pm,Toronto Raptors,99,Sacramento Kings,102,Box Score,,
Mon Nov 21 2016,7:00 pm,Memphis Grizzlies,105,Charlotte Hornets,90,Box Score,,
Mon Nov 21 2016,7:30 pm,Houston Rockets,99,Detroit Pistons,96,Box Score,,
Mon Nov 21 2016,7:00 pm,Golden State Warriors,120,Indiana Pacers,83,Box Score,,
Mon Nov 21 2016,10:30 pm,Toronto Raptors,115,Los Angeles Clippers,123,Box Score,,
Mon Nov 21 2016,8:00 pm,Orlando Magic,89,Milwaukee Bucks,93,Box Score,,
Mon Nov 21 2016,8:00 pm,Boston Celtics,99,Minnesota Timberwolves,93,Box Score,,
Mon Nov 21 2016,7:00 pm,Miami Heat,94,Philadelphia 76ers,101,Box Score,,
Mon Nov 21 2016,8:30 pm,Dallas Mavericks,91,San Antonio Spurs,96,Box Score,,
Mon Nov 21 2016,7:00 pm,Phoenix Suns,101,Washington Wizards,106,Box Score,,
Tue Nov 22 2016,7:30 pm,New Orleans Pelicans,112,Atlanta Hawks,94,Box Score,,
Tue Nov 22 2016,9:00 pm,Chicago Bulls,107,Denver Nuggets,110,Box Score,,
Tue Nov 22 2016,10:30 pm,Oklahoma City Thunder,109,Los Angeles Lakers,111,Box Score,,
Tue Nov 22 2016,7:30 pm,Portland Trail Blazers,103,New York Knicks,107,Box Score,,
Wed Nov 23 2016,7:30 pm,Boston Celtics,111,Brooklyn Nets,92,Box Score,,
Wed Nov 23 2016,7:00 pm,San Antonio Spurs,119,Charlotte Hornets,114,Box Score,,
Wed Nov 23 2016,7:00 pm,Portland Trail Blazers,125,Cleveland Cavaliers,137,Box Score,,
Wed Nov 23 2016,8:30 pm,Los Angeles Clippers,124,Dallas Mavericks,104,Box Score,,
Wed Nov 23 2016,7:30 pm,Miami Heat,84,Detroit Pistons,107,Box Score,,
Wed Nov 23 2016,10:30 pm,Los Angeles Lakers,106,Golden State Warriors,149,Box Score,,
Wed Nov 23 2016,8:00 pm,Toronto Raptors,115,Houston Rockets,102,Box Score,,
Wed Nov 23 2016,7:00 pm,Atlanta Hawks,96,Indiana Pacers,85,Box Score,,
Wed Nov 23 2016,9:30 pm,Minnesota Timberwolves,96,New Orleans Pelicans,117,Box Score,,
Wed Nov 23 2016,7:00 pm,Phoenix Suns,92,Orlando Magic,87,Box Score,,
Wed Nov 23 2016,7:00 pm,Memphis Grizzlies,104,Philadelphia 76ers,99,Box Score,2OT,
Wed Nov 23 2016,10:30 pm,Oklahoma City Thunder,101,Sacramento Kings,116,Box Score,,
Wed Nov 23 2016,9:00 pm,Denver Nuggets,83,Utah Jazz,108,Box Score,,
Fri Nov 25 2016,1:00 pm,San Antonio Spurs,109,Boston Celtics,103,Box Score,,
Fri Nov 25 2016,7:30 pm,Dallas Mavericks,90,Cleveland Cavaliers,128,Box Score,,
Fri Nov 25 2016,9:00 pm,Oklahoma City Thunder,132,Denver Nuggets,129,Box Score,OT,
Fri Nov 25 2016,7:30 pm,Los Angeles Clippers,97,Detroit Pistons,108,Box Score,,
Fri Nov 25 2016,8:00 pm,Brooklyn Nets,97,Indiana Pacers,118,Box Score,,
Fri Nov 25 2016,10:30 pm,Golden State Warriors,109,Los Angeles Lakers,85,Box Score,,
Fri Nov 25 2016,8:00 pm,Miami Heat,90,Memphis Grizzlies,81,Box Score,,
Fri Nov 25 2016,8:00 pm,Toronto Raptors,105,Milwaukee Bucks,99,Box Score,,
Fri Nov 25 2016,7:30 pm,Charlotte Hornets,111,New York Knicks,113,Box Score,OT,
Fri Nov 25 2016,7:00 pm,Washington Wizards,94,Orlando Magic,91,Box Score,,
Fri Nov 25 2016,7:30 pm,Chicago Bulls,105,Philadelphia 76ers,89,Box Score,,
Fri Nov 25 2016,9:00 pm,Minnesota Timberwolves,98,Phoenix Suns,85,Box Score,,
Fri Nov 25 2016,10:00 pm,New Orleans Pelicans,104,Portland Trail Blazers,119,Box Score,,
Fri Nov 25 2016,10:30 pm,Houston Rockets,117,Sacramento Kings,104,Box Score,,
Fri Nov 25 2016,8:00 pm,Atlanta Hawks,68,Utah Jazz,95,Box Score,,
Sat Nov 26 2016,7:00 pm,New York Knicks,102,Charlotte Hornets,107,Box Score,,
Sat Nov 26 2016,10:30 pm,Minnesota Timberwolves,102,Golden State Warriors,115,Box Score,,
Sat Nov 26 2016,8:00 pm,Memphis Grizzlies,110,Miami Heat,107,Box Score,,
Sat Nov 26 2016,8:00 pm,Detroit Pistons,88,Oklahoma City Thunder,106,Box Score,,
Sat Nov 26 2016,7:00 pm,San Antonio Spurs,112,Washington Wizards,100,Box Score,,
Sun Nov 27 2016,6:00 pm,Sacramento Kings,122,Brooklyn Nets,105,Box Score,,
Sun Nov 27 2016,7:00 pm,New Orleans Pelicans,81,Dallas Mavericks,91,Box Score,,
Sun Nov 27 2016,6:00 pm,Los Angeles Clippers,70,Indiana Pacers,91,Box Score,,
Sun Nov 27 2016,9:30 pm,Atlanta Hawks,94,Los Angeles Lakers,109,Box Score,,
Sun Nov 27 2016,6:00 pm,Milwaukee Bucks,104,Orlando Magic,96,Box Score,,
Sun Nov 27 2016,1:00 pm,Cleveland Cavaliers,112,Philadelphia 76ers,108,Box Score,,
Sun Nov 27 2016,3:30 pm,Denver Nuggets,120,Phoenix Suns,114,Box Score,,
Sun Nov 27 2016,9:00 pm,Houston Rockets,130,Portland Trail Blazers,114,Box Score,,
Mon Nov 28 2016,10:30 pm,Atlanta Hawks,100,Golden State Warriors,105,Box Score,,
Mon Nov 28 2016,8:00 pm,Charlotte Hornets,104,Memphis Grizzlies,85,Box Score,,
Mon Nov 28 2016,7:30 pm,Boston Celtics,112,Miami Heat,104,Box Score,,
Mon Nov 28 2016,8:00 pm,Utah Jazz,112,Minnesota Timberwolves,103,Box Score,,
Mon Nov 28 2016,7:30 pm,Oklahoma City Thunder,112,New York Knicks,103,Box Score,,
Mon Nov 28 2016,7:30 pm,Philadelphia 76ers,95,Toronto Raptors,122,Box Score,,
Mon Nov 28 2016,7:00 pm,Sacramento Kings,95,Washington Wizards,101,Box Score,OT,
Tue Nov 29 2016,7:30 pm,Los Angeles Clippers,122,Brooklyn Nets,127,Box Score,2OT,
Tue Nov 29 2016,7:00 pm,Detroit Pistons,112,Charlotte Hornets,89,Box Score,,
Tue Nov 29 2016,8:00 pm,Cleveland Cavaliers,101,Milwaukee Bucks,118,Box Score,,
Tue Nov 29 2016,8:00 pm,Los Angeles Lakers,88,New Orleans Pelicans,105,Box Score,,
Tue Nov 29 2016,8:30 pm,Orlando Magic,95,San Antonio Spurs,83,Box Score,,
Tue Nov 29 2016,9:00 pm,Houston Rockets,101,Utah Jazz,120,Box Score,,
Wed Nov 30 2016,7:30 pm,Detroit Pistons,121,Boston Celtics,114,Box Score,,
Wed Nov 30 2016,8:00 pm,Los Angeles Lakers,96,Chicago Bulls,90,Box Score,,
Wed Nov 30 2016,8:30 pm,San Antonio Spurs,94,Dallas Mavericks,87,Box Score,,
Wed Nov 30 2016,9:00 pm,Miami Heat,106,Denver Nuggets,98,Box Score,,
Wed Nov 30 2016,8:00 pm,New York Knicks,106,Minnesota Timberwolves,104,Box Score,,
Wed Nov 30 2016,8:00 pm,Washington Wizards,115,Oklahoma City Thunder,126,Box Score,OT,
Wed Nov 30 2016,9:00 pm,Atlanta Hawks,107,Phoenix Suns,109,Box Score,,
Wed Nov 30 2016,10:00 pm,Indiana Pacers,109,Portland Trail Blazers,131,Box Score,,
Wed Nov 30 2016,7:30 pm,Memphis Grizzlies,105,Toronto Raptors,120,Box Score,,
直接看代码:
import numpy as np
import csv
from sklearn.preprocessing import MinMaxScaler
from sklearn.cross_validation import cross_val_score
from collections import defaultdict
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
import pandas as pd
dataset = pd.read_csv('1.csv', parse_dates=["Date"],)
dataset.columns = ["Date","Start (ET)","Visitor/Neutral","PTS","Home/Neutral","PTS.1","Score Type","OT","Notes",]
dataset["HomeWin"] = dataset['PTS'] < dataset['PTS.1']
dataset["HomeLastWin"] = False
dataset["VisitorLastWin"] = False
y_true = dataset["HomeWin"].values
won_last = defaultdict(int)
for index, row in dataset.iterrows():
home_team = row['Home/Neutral']
visitor_team = row['Visitor/Neutral']
row['HomeLastWin'] = won_last[home_team]
row['VisitorLastWin'] = won_last[visitor_team]
dataset.ix[index] = row
won_last[home_team] = row['HomeWin']
won_last[visitor_team] = not row['HomeWin']
x_previouswin = dataset[['HomeLastWin','VisitorLastWin']].values
clf = DecisionTreeClassifier()
scores = cross_val_score(clf,x_previouswin,y_true,scoring="accuracy",cv = 5)
print 'accuracy is {0:.1f}%'.format(np.mean(scores)*100)
这里我的分析学习模型是根据主客队上一场的获胜与否来进行分类的,可以看到在for循环中每次都记录本次比赛的主场球队的上一场是不是获胜,还有客场球队的商场获胜与否的记录,然后把这个特征记录进样本。从所有的样本中提取出主客场的获胜与否的特征, 对最终的获胜球队进行分类学习。
结构不是很好,准确率只有:accuracy is 54.7%
说明我这个模型特征选的很失败啊,哈哈