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)
有没有人有解决这个问题的想法?谢谢!