`dtype='numeric' 与字节/字符串数组不兼容。请将数据显式转换为数值。`

问题描述 投票:0回答:1

ValueError: dtype='numeric' is not compatible with arrays of bytes/strings.Convert your data to numeric values explicitly instead.

`@app.route('/predict',methods=['GET', 'POST']) def Predict_placement(): ans = request.form.get("msg")

result = model.predict(np.array([ans]).reshape(-1, 1))`

I'm taking a string input in Html form and getting this error, how to resolve this?

html string numpy flask numpy-ndarray
1个回答
0
投票

您为预测提供的数据位于格式字符串中,但是您的模型只能处理数字数据。在将特征传递给预测之前,您应该尝试对特征进行一些编码。

© www.soinside.com 2019 - 2024. All rights reserved.