本文整理匯總了Python中sklearn.preprocessing.StandardScaler.to_csv方法的典型用法代碼示例。如果您正苦於以下問題:Python StandardScaler.to_csv方法的具體用法?Python StandardScaler.to_csv怎麽用?Python StandardScaler.to_csv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sklearn.preprocessing.StandardScaler
的用法示例。
在下文中一共展示了StandardScaler.to_csv方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: hour
# 需要導入模塊: from sklearn.preprocessing import StandardScaler [as 別名]
# 或者: from sklearn.preprocessing.StandardScaler import to_csv [as 別名]
i=0
for name,group in groupdata:
distance=0
vlist=[]
for index,row in group.iterrows():
Lng1,Lat1,time1=row['Lng'],row['Lat'],row['Time']
if(Lng0!=0 and Lat0!=0 and time0!=0 and time1!=time0):
distance+=Distance(Lng0,Lat0,Lng1,Lat1)
vlist.append(Distance(Lng0,Lat0,Lng1,Lat1)/(time1-time0))
Lng0,Lat0,time0=Lng1,Lat1,time1
varray=np.array(vlist)
Alldistance.loc[i,'STDSpeed']=varray.std()
Alldistance.loc[i,'Distance']=distance
i+=1
#new feature:average speed,rush hour(7:00-9:00,17:00-19:00), unexpected hour(0:00-5:00) 'ASpeed','Rush','Few'
newdata=pd.merge(timelen,Alldistance)
newdata=pd.merge(newdata,hours)
newdata['ASpeed']=newdata['Distance']/newdata['Timelen']
newdata['Rush']=newdata['Hour'].apply(lambda x:1 if (x>=7 and x <=9) or (x>=17 and x<=19)else 0)#是否上班上學高峰時間
newdata['Few']=newdata['Hour'].apply(lambda x:1 if (x==24 or (x>=0 and x<=5) )else 0)#是否人數稀少時間
newdata = StandardScaler().fit_transform(newdata)
#PCA
pca=PCA(n_components=3)
newdata=pca.fit_transform(newdata)
newdata=pd.DataFrame(data=newdata)
newdata.to_csv('prodata.csv',index=False)