2016-03-10から1日間の記事一覧

pythonのpandasで離散化、ビニング、ビンに区切り集計

離散化、ビンに切って、ビニングして、カテゴリごとに集計 xはデータフレーム x[0]で1列目をとりだしている. qcutはデータ数をあわせる分割, cutは均等割り. x[0]として、pd.Seres化することに注意 x0だと、DataFrame。 cats=pd.qcut(x[0],30) print cats…

Rでデータの離散化とビニング(ビンで区切る)

R

x軸で等間隔. discretize関数を使う. library(infotheo) > x<-rnorm(1000) > y<-2*x+0.01*rnorm(1000) > l1<-discretize(x,disc="equalwidth",nbins=15) > tapply(x,l1[[1]],"mean") 1 2 3 4 5 6 -2.87785661 -2.50220873 -2.05626538 -1.63706018 -1.2338…