我正在使用数据集训练模型。在计算相似索引时,我的数据出现索引超出范围错误。我的数据框有2个字段Storyid和Title。 storyid是一个长数值,标题是文本 有问题的代码:
for idx, row in ds.iterrows():
similar_indices = cosine_similarities[idx].argsort()[:-100:-1]
similar_items = [(cosine_similarities[idx][i], ds['id'][i])
for i in similar_indices]
错误日志:
similar_indices = cosine_similarities[idx].argsort()[:-100:-1]
IndexError: index 124411787 is out of bounds for axis 0 with size 21659