我正在将球树聚类算法应用于我的pandas df列sp500news3['phrase_vector']
(下面的示例)
我已经尝试过
from sklearn.neighbors import BallTree
import numpy as np
tree = BallTree(sp500news3['phrase_vector'])
print(tree.query_radius(sp500news3['phrase_vector'][:1], r=0.3, count_only=True))
ind = tree.query_radius(sp500news3['phrase_vector'][:1], r=0.3)
print(ind) # indices of neighbors within distance 0.
返回ValueError: setting an array element with a sequence.
指向此行tree = BallTree(sp500news3['phrase_vector'])
sp500news3['phrase_vector']
0 [-1.464906, 1.6889418, -1.750461, 0.54739094, ...
1 [-1.2658471, 1.250561, 0.59811795, -4.5680103,...
2 [-2.5886421, 3.0229673, -1.7595533, -3.804605,...
3 [-1.9567089, 3.6295261, 0.44644845, -2.5851138...
4 [-0.8531435, 1.686829, -2.1624348, -2.82526, 0...