![](/img/trans.png)
[英]"AttributeError: 'str' object has no attribute 'predict'". I am developing garbage detector model and this is the error
[英]"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.