資源簡介
python預測nba比賽結果
代碼片段和文件信息
#?-*-?coding:?utf-8?-*-
“““
Created?on?Sun?Jun??4?16:19:16?2017
@author:?dc
“““
import?pandas?as?pd?
import?math
import?numpy?as?np
from?sklearn?import?linear_model
import?csv
init_elo?=?1600
team_elos?=?{}
#trainteamstat?=?{}
folder?=?‘data‘
def?PruneData(M_stat?O_stat?T_stat):
????#這個函數要完成的任務在于將原始讀入的諸多隊伍的數據經過修剪,使其變為一個以team為索引
????#排列的特征數據
????
????#丟棄與球隊實力無關的統計量
????pruneM?=?M_stat.drop([‘Rk‘?‘Arena‘]axis?=?1)
????pruneO?=?O_stat.drop([‘Rk‘‘G‘‘MP‘]axis?=?1)
????pruneT?=?T_stat.drop([‘Rk‘‘G‘‘MP‘]axis?=?1)
????
????#將多個數據通過相同的index:team合并為一個數據
????mergeMO?=?pd.merge(pruneM?pruneO?how?=?‘left‘?on?=?‘Team‘)
????newstat?=?pd.merge(mergeMO?pruneT??how?=?‘left‘?on?=?‘Team‘)
????
????#將team作為index的數據返回
????return?newstat.set_index(‘Team‘?drop?=?True?append?=?False)
def?GetElo(team):
????#
????try:
????????return?team_elos[team]
????except:
????????team_elos[team]?=?init_elo
????return?team_elos[team]
def?CalcElo(winteam?l
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-06-10?12:20??python-項目一NBA\
?????目錄???????????0??2017-06-10?12:27??python-項目一NBA\data\
?????文件????????4795??2017-03-09?17:50??python-項目一NBA\data\15-16Miscellaneous_Stat.csv
?????文件????????4078??2017-03-09?17:49??python-項目一NBA\data\15-16Opponent_Per_Game_Stat.csv
?????文件????????4057??2017-03-09?17:48??python-項目一NBA\data\15-16Team_Per_Game_Stat.csv
?????文件???????43180??2017-03-10?01:04??python-項目一NBA\data\16-17Schedule.csv
?????文件???????49089??2017-03-09?00:41??python-項目一NBA\data\2015-2016_result.csv
?????文件???????12348??2017-06-05?09:23??python-項目一NBA\data\Train_data.csv
?????文件????????5581??2017-06-10?12:26??python-項目一NBA\p1_NBA_prediction.py
- 上一篇:51單片機音樂播放器
- 下一篇:SVPWM的原理及法則推導和控制算法詳解第四修改版
評論
共有 條評論