graphlab create中topk用法

参考文档:https://turi.com/products/create/docs/generated/graphlab.SFrame.topk.html

要求:需要在test_data中寻找最相似的前20种positive

只有sframe才可以用topk,因此需要继续用到原来的结构test_data。想到可以在test_data中加一行probility,然后按照probility,取topk=20即可。

test_data['probability'] = sentiment_model.predict(test_data, output_type='probability')
test_data_p = test_data[test_data['sentiment']==1]
test_data.topk('probability', k=20)

猜你喜欢

转载自blog.csdn.net/weixin_41770169/article/details/81085464