Spaces:
Build error
Build error
Commit ·
425853e
1
Parent(s): cae7e1b
[ADD] Archivos Principales
Browse files- app.py +115 -0
- model/categories_ohe.pickle +3 -0
- model/rf.pkl +3 -0
- requirements.txt +154 -0
app.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pickle
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
PARAMS_NAME = [
|
| 7 |
+
"Age",
|
| 8 |
+
"Class",
|
| 9 |
+
"Wifi",
|
| 10 |
+
"Booking",
|
| 11 |
+
"Seat",
|
| 12 |
+
"Checkin"
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
with open("model/rf.pkl", "rb") as f:
|
| 17 |
+
model = pickle.load(f)
|
| 18 |
+
|
| 19 |
+
COLUMNS_PATH = "model/categories_ohe.pickle"
|
| 20 |
+
with open(COLUMNS_PATH, 'rb') as handle:
|
| 21 |
+
ohe_tr = pickle.load(handle)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def predict(*args):
|
| 25 |
+
answer_dict = {}
|
| 26 |
+
|
| 27 |
+
for i in range(len(PARAMS_NAME)):
|
| 28 |
+
answer_dict[PARAMS_NAME[i]] = [args[i]]
|
| 29 |
+
|
| 30 |
+
single_instance = pd.DataFrame.from_dict(answer_dict)
|
| 31 |
+
|
| 32 |
+
# Reformat columns
|
| 33 |
+
single_instance_ohe = pd.get_dummies(single_instance).reindex(columns = ohe_tr).fillna(0)
|
| 34 |
+
|
| 35 |
+
prediction = model.predict(single_instance_ohe)
|
| 36 |
+
|
| 37 |
+
response = format(prediction[0], '.2f')
|
| 38 |
+
|
| 39 |
+
return response
|
| 40 |
+
|
| 41 |
+
with gr.Blocks() as demo:
|
| 42 |
+
gr.Markdown(
|
| 43 |
+
'''
|
| 44 |
+
# Flight satisfaction 🛩
|
| 45 |
+
'''
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
with gr.Row():
|
| 49 |
+
with gr.Column():
|
| 50 |
+
|
| 51 |
+
gr.Markdown(
|
| 52 |
+
'''
|
| 53 |
+
## Input 🛫
|
| 54 |
+
|
| 55 |
+
'''
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
Age = gr.Slider(label="Age", minimum=0, maximum=120, step=1, randomize=True)
|
| 59 |
+
|
| 60 |
+
Class = gr.Radio(
|
| 61 |
+
label="Class",
|
| 62 |
+
choices=["Business", "Eco", "Eco Plus"],
|
| 63 |
+
value="Eco Plus"
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
Wifi = gr.Slider(label="Wifi", minimum=0, maximum=5, step=1, randomize=True)
|
| 67 |
+
|
| 68 |
+
Booking = gr.Slider(label="Booking", minimum=0, maximum=5, step=1, randomize=True)
|
| 69 |
+
|
| 70 |
+
Seat = gr.Slider(label="Seat", minimum=0, maximum=5, step=1, randomize=True)
|
| 71 |
+
|
| 72 |
+
Checkin = gr.Slider(label="Checkin", minimum=0, maximum=5, step=1, randomize=True)
|
| 73 |
+
|
| 74 |
+
with gr.Column():
|
| 75 |
+
|
| 76 |
+
gr.Markdown(
|
| 77 |
+
'''
|
| 78 |
+
## Prediction 🛬
|
| 79 |
+
|
| 80 |
+
'''
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
label = gr.Label(label="Satisfaction")
|
| 84 |
+
predict_btn = gr.Button(value="Shoot")
|
| 85 |
+
predict_btn.click(
|
| 86 |
+
predict,
|
| 87 |
+
inputs=[
|
| 88 |
+
Age,
|
| 89 |
+
Class,
|
| 90 |
+
Wifi,
|
| 91 |
+
Booking,
|
| 92 |
+
Seat,
|
| 93 |
+
Checkin,
|
| 94 |
+
],
|
| 95 |
+
outputs=[label],
|
| 96 |
+
api_name="Flight satisfaction"
|
| 97 |
+
)
|
| 98 |
+
gr.Markdown(
|
| 99 |
+
'''
|
| 100 |
+
|
| 101 |
+
<p style='text-align:center'>
|
| 102 |
+
<a href='https://www.escueladedatosvivos.ai/cursos/bootcamp-de-data-science'
|
| 103 |
+
target='_blank'>Estudia con Carlitos y hace muchas de estas APIS 😎 !
|
| 104 |
+
</a>
|
| 105 |
+
</p>
|
| 106 |
+
'''
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
demo.launch()
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
|
model/categories_ohe.pickle
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:87509ad6135a53afdf6619009619635ecea70026c997f80282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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiofiles==23.2.1
|
| 2 |
+
altair==5.1.0
|
| 3 |
+
annotated-types==0.5.0
|
| 4 |
+
anyio==3.7.1
|
| 5 |
+
argon2-cffi==23.1.0
|
| 6 |
+
argon2-cffi-bindings==21.2.0
|
| 7 |
+
arrow==1.2.3
|
| 8 |
+
asttokens==2.2.1
|
| 9 |
+
async-lru==2.0.4
|
| 10 |
+
attrs==23.1.0
|
| 11 |
+
Babel==2.12.1
|
| 12 |
+
backcall==0.2.0
|
| 13 |
+
beautifulsoup4==4.12.2
|
| 14 |
+
bleach==6.0.0
|
| 15 |
+
certifi==2023.7.22
|
| 16 |
+
cffi==1.15.1
|
| 17 |
+
cfgv==3.4.0
|
| 18 |
+
charset-normalizer==3.2.0
|
| 19 |
+
click==8.1.7
|
| 20 |
+
comm==0.1.4
|
| 21 |
+
contourpy==1.1.0
|
| 22 |
+
cycler==0.11.0
|
| 23 |
+
debugpy==1.6.7.post1
|
| 24 |
+
decorator==5.1.1
|
| 25 |
+
defusedxml==0.7.1
|
| 26 |
+
distlib==0.3.7
|
| 27 |
+
exceptiongroup==1.1.3
|
| 28 |
+
executing==1.2.0
|
| 29 |
+
fastapi==0.103.0
|
| 30 |
+
fastjsonschema==2.18.0
|
| 31 |
+
ffmpy==0.3.1
|
| 32 |
+
filelock==3.12.3
|
| 33 |
+
flake8==6.1.0
|
| 34 |
+
fonttools==4.42.1
|
| 35 |
+
fqdn==1.5.1
|
| 36 |
+
fsspec==2023.6.0
|
| 37 |
+
funpymodeling==0.1.8
|
| 38 |
+
gradio==3.41.2
|
| 39 |
+
gradio_client==0.5.0
|
| 40 |
+
h11==0.14.0
|
| 41 |
+
httpcore==0.17.3
|
| 42 |
+
httpx==0.24.1
|
| 43 |
+
huggingface-hub==0.16.4
|
| 44 |
+
identify==2.5.27
|
| 45 |
+
idna==3.4
|
| 46 |
+
importlib-resources==6.0.1
|
| 47 |
+
iniconfig==2.0.0
|
| 48 |
+
ipykernel==6.25.1
|
| 49 |
+
ipython==8.14.0
|
| 50 |
+
ipython-genutils==0.2.0
|
| 51 |
+
ipywidgets==8.1.0
|
| 52 |
+
isoduration==20.11.0
|
| 53 |
+
jedi==0.19.0
|
| 54 |
+
Jinja2==3.1.2
|
| 55 |
+
joblib==1.3.2
|
| 56 |
+
json5==0.9.14
|
| 57 |
+
jsonpointer==2.4
|
| 58 |
+
jsonschema==4.19.0
|
| 59 |
+
jsonschema-specifications==2023.7.1
|
| 60 |
+
jupyter==1.0.0
|
| 61 |
+
jupyter-console==6.6.3
|
| 62 |
+
jupyter-events==0.7.0
|
| 63 |
+
jupyter-lsp==2.2.0
|
| 64 |
+
jupyter_client==8.3.0
|
| 65 |
+
jupyter_core==5.3.1
|
| 66 |
+
jupyter_server==2.7.2
|
| 67 |
+
jupyter_server_terminals==0.4.4
|
| 68 |
+
jupyterlab==4.0.5
|
| 69 |
+
jupyterlab-pygments==0.2.2
|
| 70 |
+
jupyterlab-widgets==3.0.8
|
| 71 |
+
jupyterlab_server==2.24.0
|
| 72 |
+
kiwisolver==1.4.5
|
| 73 |
+
MarkupSafe==2.1.3
|
| 74 |
+
matplotlib==3.7.2
|
| 75 |
+
matplotlib-inline==0.1.6
|
| 76 |
+
mccabe==0.7.0
|
| 77 |
+
mistune==3.0.1
|
| 78 |
+
nbclient==0.8.0
|
| 79 |
+
nbconvert==7.7.4
|
| 80 |
+
nbformat==5.9.2
|
| 81 |
+
nest-asyncio==1.5.7
|
| 82 |
+
nodeenv==1.8.0
|
| 83 |
+
notebook==7.0.2
|
| 84 |
+
notebook_shim==0.2.3
|
| 85 |
+
numpy==1.25.2
|
| 86 |
+
orjson==3.9.5
|
| 87 |
+
overrides==7.4.0
|
| 88 |
+
packaging==23.1
|
| 89 |
+
pandas==2.0.3
|
| 90 |
+
pandocfilters==1.5.0
|
| 91 |
+
parso==0.8.3
|
| 92 |
+
pexpect==4.8.0
|
| 93 |
+
pickleshare==0.7.5
|
| 94 |
+
Pillow==10.0.0
|
| 95 |
+
platformdirs==3.10.0
|
| 96 |
+
pluggy==1.3.0
|
| 97 |
+
pre-commit==3.3.3
|
| 98 |
+
prometheus-client==0.17.1
|
| 99 |
+
prompt-toolkit==3.0.39
|
| 100 |
+
psutil==5.9.5
|
| 101 |
+
ptyprocess==0.7.0
|
| 102 |
+
pure-eval==0.2.2
|
| 103 |
+
pycodestyle==2.11.0
|
| 104 |
+
pycparser==2.21
|
| 105 |
+
pydantic==2.3.0
|
| 106 |
+
pydantic_core==2.6.3
|
| 107 |
+
pydub==0.25.1
|
| 108 |
+
pyflakes==3.1.0
|
| 109 |
+
Pygments==2.16.1
|
| 110 |
+
pyparsing==3.0.9
|
| 111 |
+
pytest==7.4.0
|
| 112 |
+
python-dateutil==2.8.2
|
| 113 |
+
python-json-logger==2.0.7
|
| 114 |
+
python-multipart==0.0.6
|
| 115 |
+
pytz==2023.3
|
| 116 |
+
PyYAML==6.0.1
|
| 117 |
+
pyzmq==25.1.1
|
| 118 |
+
qtconsole==5.4.3
|
| 119 |
+
QtPy==2.3.1
|
| 120 |
+
referencing==0.30.2
|
| 121 |
+
requests==2.31.0
|
| 122 |
+
rfc3339-validator==0.1.4
|
| 123 |
+
rfc3986-validator==0.1.1
|
| 124 |
+
rpds-py==0.10.0
|
| 125 |
+
scikit-learn==1.3.0
|
| 126 |
+
scipy==1.11.2
|
| 127 |
+
seaborn==0.12.2
|
| 128 |
+
semantic-version==2.10.0
|
| 129 |
+
Send2Trash==1.8.2
|
| 130 |
+
six==1.16.0
|
| 131 |
+
sniffio==1.3.0
|
| 132 |
+
soupsieve==2.4.1
|
| 133 |
+
stack-data==0.6.2
|
| 134 |
+
starlette==0.27.0
|
| 135 |
+
terminado==0.17.1
|
| 136 |
+
threadpoolctl==3.2.0
|
| 137 |
+
tinycss2==1.2.1
|
| 138 |
+
tomli==2.0.1
|
| 139 |
+
toolz==0.12.0
|
| 140 |
+
tornado==6.3.3
|
| 141 |
+
tqdm==4.66.1
|
| 142 |
+
traitlets==5.9.0
|
| 143 |
+
typing_extensions==4.7.1
|
| 144 |
+
tzdata==2023.3
|
| 145 |
+
uri-template==1.3.0
|
| 146 |
+
urllib3==2.0.4
|
| 147 |
+
uvicorn==0.23.2
|
| 148 |
+
virtualenv==20.24.3
|
| 149 |
+
wcwidth==0.2.6
|
| 150 |
+
webcolors==1.13
|
| 151 |
+
webencodings==0.5.1
|
| 152 |
+
websocket-client==1.6.2
|
| 153 |
+
websockets==11.0.3
|
| 154 |
+
widgetsnbextension==4.0.8
|