简体   繁体   English

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

[英]"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.

相关问题 “AttributeError:‘str’object 没有属性‘predict’”。 我正在开发垃圾检测器 model,这是错误 - "AttributeError: 'str' object has no attribute 'predict'". I am developing garbage detector model and this is the error 即使使用顺序 model,我也会收到“AttributeError: 'Model' object has no attribute 'predict_classes'” - Even when using Sequential model, I am getting “AttributeError: 'Model' object has no attribute 'predict_classes' ” AttributeError: 'str' object 在拟合逻辑回归 Model 中没有属性 'decode' - AttributeError: 'str' object has no attribute 'decode' in fitting Logistic Regression Model AttributeError:“str”对象没有属性“predict” - AttributeError: 'str' object has no attribute 'predict' 我收到一个错误:AttributeError: 'str' object has no attribute 'isfloat' - I am getting an error : AttributeError: 'str' object has no attribute 'isfloat' 为什么我得到 AttributeError: 'str' object has no attribute 'strftime'? - why I am getting AttributeError: 'str' object has no attribute 'strftime'? 使用casefold()时,出现错误,如“ AttributeError:'str'对象没有属性'casefold'” - While using casefold(), I am getting an error as “ AttributeError: 'str' object has no attribute 'casefold' ” Django AttributeError:“ str”对象没有属性“ model” - Django AttributeError: 'str' object has no attribute 'model' Python AttributeError:“ str”对象没有属性“ get_price” - Python AttributeError: 'str' object has no attribute 'get_price' AttributeError: 'str' object 在二进制逻辑回归中没有属性 'decode' - AttributeError: 'str' object has no attribute 'decode' in Binary Logistic Regression
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM