zapatacc commited on
Commit
53ef2b2
1 Parent(s): 10d0d57

Initial commit

Browse files
Files changed (5) hide show
  1. .idea/.gitignore +8 -0
  2. .idea/vcs.xml +4 -0
  3. Dockerfile +15 -0
  4. main.py +34 -0
  5. requirements.txt +2 -0
.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
.idea/vcs.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings" defaultProject="true" />
4
+ </project>
Dockerfile ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /code
4
+
5
+ RUN apt-get update && apt-get install -y procps && pip install -U pip && rm /etc/localtime && ln -s /usr/share/zoneinfo/America/Mexico_City /etc/localtime
6
+
7
+ COPY ./requirements.txt /code/requirements.txt
8
+
9
+ RUN pip install -r ./requirements.txt
10
+
11
+ COPY ./main.py /code/
12
+
13
+ EXPOSE 8501
14
+
15
+ CMD ["streamlit","run", "main.py"]
main.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import json
4
+
5
+ st.write("""
6
+ # Application to predict the time for the NYC taxi trips
7
+ """)
8
+
9
+ st.sidebar.header('User Input Parameters')
10
+
11
+ def user_input_features():
12
+ PU = st.sidebar.text_input("PU Location ID", "80")
13
+ DO = st.sidebar.text_input("DO Location ID", "60")
14
+ trip_distance = st.sidebar.number_input("Trip Distance", value=10.0, min_value=0.1, max_value=100.0)
15
+
16
+ input_dict = {
17
+ 'PULocationID': PU,
18
+ 'DOLocationID': DO,
19
+ 'trip_distance': trip_distance,
20
+ }
21
+
22
+ return input_dict
23
+
24
+
25
+ input_dict = user_input_features()
26
+
27
+ if st.button('Predict'):
28
+ response = requests.post(
29
+ #url="http://localhost:8000/predict",
30
+ url="http://nyc-taxi-model-container:8000/predict",
31
+ data=json.dumps(input_dict)
32
+ )
33
+
34
+ st.write(f"El tiempo estimado del viaje es: {response.json()['prediction']} minutos")
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ requests==2.32.3
2
+ streamlit==1.39.0