Hi. I’m trying to create a browser with ML algorithms using VSCode with python and installing streamlit. VSCode from Anaconda Navigator. The browser itself appears, but with a square informing KeyError: 166 and 5 files in Traceback. I have no clue how to solve it. I looked out “Streamlit KeyError 166” and I didn’t find anything.
I created a file called “app.py” on VSCode. I wrote the code below:
def predicao(timeA, timeB):
idA = nome_time[timeA]
idB = nome_time[timeB]
campeaoA = campeoes.get(timeA) if campeoes.get(timeA) != None else 0
campeaoB = campeoes.get(timeB) if campeoes.get(timeB) != None else 0
x = np.array([idA, idB, campeaoA, campeaoB]).astype(‘float64’)
x = np.reshape(x, (1,-1))
_y = svm_model.predict_proba(x)[0]
text = (‘Chance de’ +timeA+’ vencer ’ +timeB+‘é {}\nChance de ’ +timeB+’ vencer ’ +timeA+‘é {}\nChance de’ +timeA+ ’ e’ +timeB+’ empatar é {}').format(_y[1]*100, _y[2]*100, _y[0]*100)
return _y[0], text
prob1, text1 = predicao(selecionar_primeira_selecao, selecionar_segunda_selecao)
if st.button(“Realizar predição do Jogo”):
st.text(text1)
Also I include some files in order to make this code works. The "logo.png" is just a image file to use in the browser.
**Expected behavior:**
A browser where I can choose two countries and a button where I can predict the probability of these two countries can win the next World Cup.
**Actual behavior:**
The browser appear and I can select the two countries. Instead of a button to make predictions, it's appearing a square informing a KeyError: 166 with the following paths:
KeyError: 166
Traceback:
File “c:\Users\rocki\anaconda3\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py”, line 562, in _run_script
exec(code, module.dict)File “C:\Users\rocki\OneDrive\Documentos\TitandosDados\ProjetoCopadoMundo2022\Deploy\app.py”, line 21, in
model = joblib.load(“model.pkl”)File “c:\Users\rocki\anaconda3\lib\site-packages\joblib\numpy_pickle.py”, line 587, in load
obj = _unpickle(fobj, filename, mmap_mode)File “c:\Users\rocki\anaconda3\lib\site-packages\joblib\numpy_pickle.py”, line 506, in _unpickle
obj = unpickler.load()File “c:\Users\rocki\anaconda3\lib\pickle.py”, line 1212, in load
dispatchkey[0]
### Debug info
- Streamlit version: 0.84.1
- Python version: 3.9
- Using Conda? No PipEnv? No PyEnv? No Pex? No
- OS version: Windows 10
- Browser version: Microsoft Edge Version 106.0.1370.52
### Requirements file
Using Conda? No Conda, but the VSCode is from Conda.
PipEnv? No
PyEnv? No
Pex? No
Share the contents of your requirements file here:
altair==4.2.0
appnope==0.1.3
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
astor==0.8.1
asttokens==2.0.5
attrs==22.1.0
backcall==0.2.0
base58==2.1.1
beautifulsoup4==4.11.1
biopython==1.79
bleach==5.0.1
blinker==1.5
blis==0.7.7
cachetools==5.2.0
catalogue==2.0.7
certifi==2022.5.18.1
cffi==1.15.1
charset-normalizer==2.0.12
click==7.1.2
commonmark==0.9.1
cycler==0.11.0
cymem==2.0.6
debugpy==1.6.2
decorator==5.1.1
defusedxml==0.7.1
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.3.0/en_core_web_sm-3.3.0-py3-none-any.whl
entrypoints==0.4
executing==0.9.1
fastjsonschema==2.16.1
filelock==3.7.1
fonttools==4.34.4
gitdb==4.0.9
GitPython==3.1.27
idna==3.3
importlib-metadata==4.12.0
ipykernel==6.15.1
ipython==8.4.0
ipython-genutils==0.2.0
ipywidgets==7.7.1
jedi==0.18.1
Jinja2==3.1.2
joblib==1.2.0
jsonschema==4.8.0
jupyter-client==7.3.4
jupyter-core==4.11.1
jupyterlab-pygments==0.2.2
jupyterlab-widgets==1.1.1
kiwisolver==1.4.4
langcodes==3.3.0
lxml==4.9.1
MarkupSafe==2.1.1
matplotlib==3.4.2
matplotlib-inline==0.1.3
mistune==0.8.4
murmurhash==1.0.7
nbclient==0.6.6
nbconvert==6.5.0
nbformat==5.4.0
neatbio==0.0.2
nest-asyncio==1.5.5
notebook==6.4.12
numpy==1.22.4
packaging==21.3
pandas==1.3.0
pandocfilters==1.5.0
parso==0.8.3
pathy==0.6.1
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.2.0
plotly==5.1.0
preshed==3.0.6
prometheus-client==0.14.1
prompt-toolkit==3.0.30
protobuf==3.20.1
psutil==5.9.1
pt-core-news-sm @ https://github.com/explosion/spacy-models/releases/download/pt_core_news_sm-3.3.0/pt_core_news_sm-3.3.0-py3-none-any.whl
ptyprocess==0.7.0
pure-eval==0.2.2
pyarrow==8.0.0
pycparser==2.21
pydantic==1.8.2
pydeck==0.7.1
Pygments==2.12.0
pymongo==4.2.0
Pympler==1.0.1
pyparsing==3.0.9
pyrsistent==0.18.1
PySocks==1.7.1
python-dateutil==2.8.2
pytz==2022.1
pytz-deprecation-shim==0.1.0.post0
pyzmq==23.2.0
requests==2.28.0
rich==12.5.1
scikit-learn==1.1.2
scipy==1.9.0
seaborn==0.11.1
semver==2.13.0
Send2Trash==1.8.0
six==1.16.0
sklearn==0.0
smart-open==5.2.1
smmap==5.0.0
snscrape==0.4.3.20220106
soupsieve==2.3.2.post1
spacy==3.3.1
spacy-legacy==3.0.9
spacy-loggers==1.0.2
srsly==2.4.3
stack-data==0.3.0
streamlit==0.84.1
tenacity==8.0.1
terminado==0.15.0
thinc==8.0.17
threadpoolctl==3.1.0
tinycss2==1.1.1
toml==0.10.2
toolz==0.12.0
tornado==6.2
tqdm==4.64.0
traitlets==5.3.0
typer==0.4.1
typing_extensions==4.2.0
tzdata==2022.1
tzlocal==4.2
urllib3==1.26.9
validators==0.20.0
wasabi==0.9.1
wcwidth==0.2.5
webencodings==0.5.1
widgetsnbextension==3.6.1
zipp==3.8.1