小编che*_*hen的帖子

类型错误:'numpy.float64' 对象不支持项目分配

def classify(self, texts):
        vectors = self.dictionary.feature_vectors(texts)
        predictions = self.svm.decision_function(vectors)
        predictions = np.transpose(predictions)[0]
        predictions = predictions / 2 + 0.5
        predictions[predictions > 1] = 1
        predictions[predictions < 0] = 0
        return predictions
Run Code Online (Sandbox Code Playgroud)

错误:

TypeError: 'numpy.float64' object does not support item assignment
Run Code Online (Sandbox Code Playgroud)

发生在以下行:

        predictions[predictions > 1] = 1
Run Code Online (Sandbox Code Playgroud)

有没有人有解决这个问题的想法?谢谢!

python numpy

10
推荐指数
1
解决办法
7万
查看次数

标签 统计

numpy ×1

python ×1