bmi_life_model.fit(x,y)
bmi_life_model.predict(21.079)
ValueError: Expected 2D array, got scalar array instead:
array=21.079.Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
按照回归模型预测,出现错误,该错误是由于sklearn版本更新后,数据维度不一致导致,代码改成以下即可:
bmi_life_model.predict([[21.079]])
array([[60.31486644]])
模型运行成功!