python - 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
你能帮我解决这个问题吗?
解决方案
你可能已经得到了这个,但是你去 - 你可能拼错了 Python Boolean constant True
。
小写的 true 是可用于变量的有效自由名称。尝试True
代替,true
它应该可以工作!
推荐阅读
- php - 在模板刀片 laravel 上设置 CURL
- matplotlib - Ubuntu 中的 Matplotlib 内存泄漏,但在 Windows 10 中没有
- excel - 如何自动将列值填充到 Excel 中的另一个工作表中?
- cassandra - Where does Cassandra reside in the CAP theorem?
- python - 如何在 vs 代码中更改 python 代码的选项卡大小
- python - 尝试使用 Python PySFTP 模块连接到远程服务器时出现 WinError 10060 错误
- html - 如何将可滚动div的高度设置为父容器的百分比
- c++ - 删除继承中的代码重复?
- javascript - 如何使用 nodejs 在数组中追加对象?
- r - 计算 R 中每列的负值、0 值和正值的数量和百分比