首页 > 解决方案 > Streamlit 面临的问题

问题描述

我正在做一个预测房价的项目,并希望使用 streamlit 进行部署。

# Take the users input
Lot_Area = st.number_input('LotArea')
Year_Built = st.number_input('YearBuilt')
Total_rooms = st.number_input('TotRmsAbvGrd')
# store the inputs
features = [Lot_Area, Year_Built, Total_rooms]
# convert user inputs into an array fr the model
int_features = [int(x) for x in features]
final_features = [np.array(int_features)]


if st.button('Predict'):           # when the submit button is pressed
    prediction = model.predict(final_features)
    st.balloons()
    st.success(f'The house price is: $ {round(prediction[0], 2)}')

但是,当我使用流运行 app.py 在终端中运行时,它会在我的网络浏览器中打开,但出现以下错误:

NameError: name 'true' is not defined Traceback: File "c:\users\anju\anaconda3\lib\site-packages\streamlit\ScriptRunner.py", line 322, in _run_script exec(code, module.dict ) File " C:\Users\Anju\app.py”,第 1468 行,在“滚动”中:true

你能帮我解决这个问题吗?

标签: pythonmachine-learningdata-sciencestreamlit

解决方案


你可能已经得到了这个,但是你去 - 你可能拼错了 Python Boolean constant True

小写的 true 是可用于变量的有效自由名称。尝试True代替,true它应该可以工作!


推荐阅读