我已经训练了具有120个功能的分类器模型,以预测我正在使用此代码。
file = open('/Users/arjun/DataSets/Cleaned_for_testing.txt').readlines()
trained_file = open(
'/Users/arjun/Projects/Classification/trained_models/final_classifier.pkl',
'rb')
model = pickle.load(trained_file)
for i in file:
features = features_for_sentence(i)
result = model.predict(features)
print(result)
它是一个二进制分类器。运行此命令时,新文本的功能会即时生成,然后输入到模型中。我得到的输出是
[1 1 1 1]
[1 1 1 1 1 1 1]
[1 1 1 1 1 1 1 1 1]
[1 1 1 1 1 1 1 1 1 1 1]
结果将被附加。如何避免这种情况或一个接一个地获得结果。