我试图按照教程"机器学习"来自微软,这是一个实用的部分。我刚刚复制了代码并尝试直接从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()
谢谢!
答案 0 :(得分:0)
df.head()返回一个数据帧。尝试将其打印出来以查看它。
print(sim_data.head())