博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
kaggle科比投篮数据集的画图案例
阅读量:7251 次
发布时间:2019-06-29

本文共 1666 字,大约阅读时间需要 5 分钟。

引用地址:https://www.kaggle.com/selfishgene/psychology-of-a-professional-athlete

# plot the shot attempts as a function of time (from start of game) with several different binningsplt.rcParams['figure.figsize'] = (16, 16)plt.rcParams['font.size'] = 16binsSizes = [24,12,6]plt.figure();for k, binSizeInSeconds in enumerate(binsSizes):    timeBins = np.arange(0,60*(4*12+3*5),binSizeInSeconds)+0.01    attemptsAsFunctionOfTime, b = np.histogram(data['secondsFromGameStart'], bins=timeBins)             maxHeight = max(attemptsAsFunctionOfTime) + 30    barWidth = 0.999*(timeBins[1]-timeBins[0])    plt.subplot(len(binsSizes),1,k+1);     plt.bar(timeBins[:-1],attemptsAsFunctionOfTime, align='edge', width=barWidth); plt.title(str(binSizeInSeconds) + ' second time bins')    plt.vlines(x=[0,12*60,2*12*60,3*12*60,4*12*60,4*12*60+5*60,4*12*60+2*5*60,4*12*60+3*5*60], ymin=0,ymax=maxHeight, colors='r')    plt.xlim((-20,3200)); plt.ylim((0,maxHeight)); plt.ylabel('attempts')plt.xlabel('time [seconds from start of game]')

 

 

2、特征值的转换

def FactorizeCategoricalVariable(inputDB, categoricalVarName):    opponentCategories = inputDB[categoricalVarName].value_counts().index.tolist()    outputDB = pd.DataFrame()    for category in opponentCategories:        featureName = categoricalVarName + ': ' + str(category)        outputDB[featureName] = (inputDB[categoricalVarName] == category).astype(int)    return outputDBfeaturesDB = pd.DataFrame()featuresDB['homeGame'] = data['matchup'].apply(lambda x: 1 if (x.find('@') < 0) else 0)featuresDB = pd.concat([featuresDB, FactorizeCategoricalVariable(data, 'opponent')], axis=1)

 

转载于:https://www.cnblogs.com/figo-studypath/p/9282214.html

你可能感兴趣的文章
[ 一起学React系列 -- 1 ] 信笔说JSX
查看>>
homebrew报错问题解决
查看>>
肉眼看到的相同两个字串的不同
查看>>
ng-zorror@~0.6升级@^1在开发中有哪些差异
查看>>
微信小程序 request请求封装
查看>>
Git 学习
查看>>
ES6深入浅出 模块系统
查看>>
一道js闭包面试题的学习
查看>>
微信小程序(新)必备知识
查看>>
网站接入微信扫码登录并获取用户基本信息(微信开放平台)
查看>>
HTC VIVE Wave 概览
查看>>
Vue动态控制input的disabled属性
查看>>
TCP的局限性有哪些?
查看>>
【前端数据结构基础】栈
查看>>
沙漠种水稻,88岁的袁隆平又创造奇迹!他参与的“袁米”还有个大计划
查看>>
JS基础入门篇(二十四)—DOM(上)
查看>>
阿里架构师眼里JVM可以说的那些事
查看>>
如何将应用完美迁移至Android P版本
查看>>
对数据科学家来说最重要的算法和统计模型
查看>>
Angular4 反向代理Details
查看>>