我试着学习微软的“机器学习”教程,其中有一个实用的部分。我只是复制了代码,并试图从Linux上的终端直接执行它。当我运行它时,什么都不会返回。根据我在视频中看到的内容,它应该返回一个带有值的表。
有人知道为什么不能用吗?
以下是代码:
def sim_log_data(x1,y1,n1,sd1,x2,y2,n2,sd2):
import numpy.random as nr
import pandas as pd
# normal method draws normal samples from a Gaussian distribuition
wx1 = nr.normal(loc = x1, scale=sd1, size=n1)
wy1 = nr.normal(loc = y1, scale=sd1, size=n1)
# z1 and z2 are our labels, they have two possibilities, 0 or 1
z1 = [1]*n1
wx2 = nr.normal(loc = x2, scale=sd2, size=n2)
wy2 = nr.normal(loc = y2, scale=sd2, size=n2)
z2 = [0]*n2
# storing everything in DataFrames
df1 = pd.DataFrame({'x':wx1,'y':wy1, 'z':z1})
df2 = pd.DataFrame({'x':wx2,'y':wy2, 'z':z2})
# concaternating the columns to be displayed
return pd.concat([df1,df2], axis=0, ignore_index = True)
sim_data = sim_log_data(1,1,50,1,-1,-1,50,1)
sim_data.head()谢谢!
发布于 2018-04-25 15:01:59
df.head()返回一个数据文件。试着把它打印下来看看。
print(sim_data.head())https://stackoverflow.com/questions/50025440
复制相似问题