我正在做一个项目,以预测房价,并希望部署使用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行,在 “滚动”:真
你能帮我做这个吗
Hy,我也是一个类似的问题,经过广泛的研究,我发现streamlit并不意味着要从Jupyter笔记本中获得灵感,如果你使用Jupyter笔记本,然后将其写在python脚本上。我想这可能是你的问题。 我通过卸载并重新安装Streamlight解决了我的问题。希望这能有所帮助
您可能已经知道了这一点,但是您可能已经将Python布尔常量
True
拼写错误了小写true是变量可用的有效自由名称。尝试
True
而不是true
,它应该可以工作相关问题 更多 >
编程相关推荐