[英]"AttributeError: 'str' object has no attribute 'predict'". I am developing a car price predictor using Linear Regression model
Error : AttributeError: 'str' object has no attribute 'predict'".错误: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)
I hope you already found your answer, anyway, if you are using keras(tensorflow) then model.predict()
expects the first parameter to be a numpy array.我希望您已经找到了答案,无论如何,如果您使用的是 keras(tensorflow),那么model.predict()
期望第一个参数是一个 numpy 数组。
model.predict(x, batch_size=None, verbose=0, steps=None, callbacks=None)
where x: is input samples.其中 x: 是输入样本。 Can be a NumPy array or a TensorFlow tensor.可以是 NumPy 数组或 TensorFlow 张量。
After taking inputs you need to do some data processing and prepare them to feed your model and after compiling/training of your model use the processed data to make some predictions.接受输入后,您需要进行一些数据处理并准备它们以提供模型,并在编译/训练模型后使用处理过的数据进行一些预测。
There is a chance you get this error if you are loading the saved model from path.如果您从路径加载保存的模型,则可能会出现此错误。 Try using "model=load_model(modelFile)" in modelfile place give the path to your file.尝试在模型文件位置使用“model=load_model(modelFile)”给出文件的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.