本文整理汇总了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)