我有一个包含此类数据的数据框...
user_name audit_status IP
0 deck_man Success 192.168.1.19
1 devid Failed 192.168.1.14
使用tf-idf
将其转换为向量后,我得到以下结果:
user_name audit_status IP
0 (0, 4)\t1.0\n (1, 0)\t1.0\n (2, 3)\t1.0\n ... (0, 1)\t1.0\n (1, 1)\t1.0\n (2, 0)\t1.0\n .. (0, 5)\t0.431952109640923\n (0, 3)\t0.43195...
现在,该值的type
是45x5 sparse matrix of type '<class 'numpy.float64'>' with 45 stored elements in Compressed Sparse Row format
我的目标是将这些数据转换为矢量形式,然后将其传递到PCA中以减小尺寸(因为它还包含更多列)。
如果我将PCA
这类数据传递给我,则会出现错误:ValueError: setting an array element with a sequence.
对此有什么解决方案?
PCA接收这种数据(这里是示例)
x y z
0 -2.264542 0.505704 0.604580
我该怎么做?
我们将不胜感激。