面对streamlight的问题

2024-04-26 00:54:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个项目,以预测房价,并希望部署使用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)}')

但是,当我使用stream run app.py在终端中运行时,它会在我的web浏览器中打开,但我发现以下错误:

name错误:未定义名称“true” 回溯: 文件“c:\users\anju\anaconda3\lib\site packages\streamlit\ScriptRunner.py”,第322行,在脚本中 exec(代码,模块.dict) 文件“C:\Users\Anju\app.py”,第1468行,在 “滚动”:真

你能帮我做这个吗


Tags: thepynumberinputareayearusersint
2条回答

Hy,我也是一个类似的问题,经过广泛的研究,我发现streamlit并不意味着要从Jupyter笔记本中获得灵感,如果你使用Jupyter笔记本,然后将其写在python脚本上。我想这可能是你的问题。 我通过卸载并重新安装Streamlight解决了我的问题。希望这能有所帮助

您可能已经知道了这一点,但是您可能已经将Python布尔常量True拼写错误了

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

相关问题 更多 >