AttributeError:“元组”对象没有属性“ predict”

时间:2019-12-12 14:17:48

标签: python

app = Flask(__name__)
model = pickle.load(open('data.pickle', 'rb'))

@app.route('/')
def home():
    return render_template('index.html')
@app.route('/predict',methods=['POST'])
def predict():
    input=request.form['user_input']
    result=model.predict([bag_of_words(input,words)])[0]
    result_index=numpy.argmax(result)
    tag=labels[result_index]
    if result[result_index]>0.7:
        for tg in data['intents']:
            if tg['tag']==tag:
                responses=tg['responses']
        bot_response=random.choice(responses)
    else:
        bot_response="I didn't get that ,Please try again"
    bot_response=chat(input)
    return render_template('index.html',input=input,bot_response=bot_response)

result = model.predict([bag_of_words(input,words)])[0] 在此行中显示上述错误

0 个答案:

没有答案