繁体   English   中英

“AttributeError: 'str' 对象没有属性 'predict'”。 我正在使用线性回归模型开发汽车价格预测器

[英]"AttributeError: 'str' object has no attribute 'predict'". I am developing a car price predictor using Linear Regression model

错误:AttributeError:'str' 对象没有属性 'predict'”。

maker=input('Maker:')
model=input('Model:') 
mileage=int(input('Mileage:')) 
manufacture_year= int(input('Manufacture Year:')) 
engine_hp= int(input('Engine_Hp:')) 
transmission= input('Transmission:') 
door_count= int(input('Door count:')) 
seat_count= int(input('Seat count:')) 
fuel_type= input('Fuel type:')  
outcome=model.predict(maker,model,mileage,manufacture_year,engine_hp,transmission,door_count,seat_count,fuel_type)
print('Price Of Car Should be approx: ',outcome)

我希望您已经找到了答案,无论如何,如果您使用的是 keras(tensorflow),那么model.predict()期望第一个参数是一个 numpy 数组。

model.predict(x, batch_size=None, verbose=0, steps=None, callbacks=None)

其中 x: 是输入样本。 可以是 NumPy 数组或 TensorFlow 张量。

接受输入后,您需要进行一些数据处理并准备它们以提供模型,并在编译/训练模型后使用处理过的数据进行一些预测。

如果您从路径加载保存的模型,则可能会出现此错误。 尝试在模型文件位置使用“model=load_model(modelFile)”给出文件的路径。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM