我使用jupyter notebook和graphlab / turi作为tfidf-nearest_neighbors模型,到目前为止工作正常。
但是,当我查询模型时
tfidf_model.query(Test_AD)我总是得到头 - [5行x 4列]
我应该使用“print_rows(num_rows = m,num_columns = n)”来打印更多的行和列,如:
tfidf_model.query(Test_AD).print_rows(num_rows = 50,num_columns = 4)
但是,当我使用它时,我不再获得任何行,只有摘要字段:
开始成对查询。 + -------------- + --------- + ------------- + ---------- ---- + |查询点| #pairs | %完成。 |经过的时间| + -------------- + --------- + ------------- + ---------- ---- + | 0 | 1 | 0.00519481 | 13.033ms | |完成| | 100 | 106.281ms | + -------------- + --------- + ------------- + ---------- ---- +
而已。没有错误信息,没有。任何想法,如何获得所有/更多行?
我试图转换为pandas或.show()命令等,没有帮助。
好吧,似乎我必须用以下内容定义数字或邻居:
tfidf_model.query(Test_AD,k = 100).show()
所以我可以在游说中得到前100名的名单。
出现这种情况是由于Jupyter Notebook无法在同一帧中显示每一行。有几种方法可以打印并查看您的要求。
sf[100:] # Returns an SFrame containing rows 100 to the end
sf[:100] # Returns an SFrame containing rows 0 to row 99 inclusive
sf[0:100:2] # Returns an SFrame containing rows 0 to row 100 in steps of 2
sf[-100:] # Returns an SFrame containing last 100 rows
sf[-100:len(sf):2] # Returns an SFrame containing last 100 rows in steps of 2
df = pd.DataFrame({i: range(1000) for i in range(100)})
df.ix[:5, :10]
df.head(n)
df.tail(n)
SFrame.export_csv(filename, delimiter=', ', line_terminator='\n', header=True, quote_level=2, double_quote=True, escape_char='\\', quote_char='"', na_rep='', file_header='', file_footer='', line_prefix='', _no_prefix_on_first_value=False, **kwargs)
请参阅SFrame上的文档。我希望有所帮助。
print_rows是Sframe或模型的预期方法。以下是模型的示例:
model1.get("coefficients").print_rows(num_rows=16, num_columns=6)