From 7862b4084b498b454684cc88880dfe5abacccd83 Mon Sep 17 00:00:00 2001 From: Carlos Melo Date: Wed, 4 Oct 2023 14:33:39 -0300 Subject: [PATCH] Streamlit App updated --- notebooks/14_inference_pipeline.ipynb | 251 ++++++++++++++++++++++++++ src/app.py | 46 +++-- 2 files changed, 273 insertions(+), 24 deletions(-) diff --git a/notebooks/14_inference_pipeline.ipynb b/notebooks/14_inference_pipeline.ipynb index 0954df0..feccddd 100644 --- a/notebooks/14_inference_pipeline.ipynb +++ b/notebooks/14_inference_pipeline.ipynb @@ -87,6 +87,257 @@ "features = load_batch_of_features_from_store(current_date)" ] }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
rides_previous_672_hourrides_previous_671_hourrides_previous_670_hourrides_previous_669_hourrides_previous_668_hourrides_previous_667_hourrides_previous_666_hourrides_previous_665_hourrides_previous_664_hourrides_previous_663_hour...rides_previous_8_hourrides_previous_7_hourrides_previous_6_hourrides_previous_5_hourrides_previous_4_hourrides_previous_3_hourrides_previous_2_hourrides_previous_1_hourpickup_hourpickup_location_id
1342.04.01.00.02.01.01.00.00.00.0...0.00.01.00.00.01.03.01.02023-10-04 13:00:001
2120.00.00.00.00.00.00.00.00.00.0...0.00.00.00.00.00.00.00.02023-10-04 13:00:002
400.00.00.00.00.00.00.00.00.00.0...0.00.00.00.00.01.00.00.02023-10-04 13:00:003
2206.04.03.03.04.010.05.04.06.07.0...1.03.03.011.07.08.04.02.02023-10-04 13:00:004
690.00.00.01.00.00.00.01.00.00.0...0.00.00.01.00.00.00.00.02023-10-04 13:00:005
\n", + "

5 rows × 674 columns

\n", + "
" + ], + "text/plain": [ + " rides_previous_672_hour rides_previous_671_hour \\\n", + "134 2.0 4.0 \n", + "212 0.0 0.0 \n", + "40 0.0 0.0 \n", + "220 6.0 4.0 \n", + "69 0.0 0.0 \n", + "\n", + " rides_previous_670_hour rides_previous_669_hour \\\n", + "134 1.0 0.0 \n", + "212 0.0 0.0 \n", + "40 0.0 0.0 \n", + "220 3.0 3.0 \n", + "69 0.0 1.0 \n", + "\n", + " rides_previous_668_hour rides_previous_667_hour \\\n", + "134 2.0 1.0 \n", + "212 0.0 0.0 \n", + "40 0.0 0.0 \n", + "220 4.0 10.0 \n", + "69 0.0 0.0 \n", + "\n", + " rides_previous_666_hour rides_previous_665_hour \\\n", + "134 1.0 0.0 \n", + "212 0.0 0.0 \n", + "40 0.0 0.0 \n", + "220 5.0 4.0 \n", + "69 0.0 1.0 \n", + "\n", + " rides_previous_664_hour rides_previous_663_hour ... \\\n", + "134 0.0 0.0 ... \n", + "212 0.0 0.0 ... \n", + "40 0.0 0.0 ... \n", + "220 6.0 7.0 ... \n", + "69 0.0 0.0 ... \n", + "\n", + " rides_previous_8_hour rides_previous_7_hour rides_previous_6_hour \\\n", + "134 0.0 0.0 1.0 \n", + "212 0.0 0.0 0.0 \n", + "40 0.0 0.0 0.0 \n", + "220 1.0 3.0 3.0 \n", + "69 0.0 0.0 0.0 \n", + "\n", + " rides_previous_5_hour rides_previous_4_hour rides_previous_3_hour \\\n", + "134 0.0 0.0 1.0 \n", + "212 0.0 0.0 0.0 \n", + "40 0.0 0.0 1.0 \n", + "220 11.0 7.0 8.0 \n", + "69 1.0 0.0 0.0 \n", + "\n", + " rides_previous_2_hour rides_previous_1_hour pickup_hour \\\n", + "134 3.0 1.0 2023-10-04 13:00:00 \n", + "212 0.0 0.0 2023-10-04 13:00:00 \n", + "40 0.0 0.0 2023-10-04 13:00:00 \n", + "220 4.0 2.0 2023-10-04 13:00:00 \n", + "69 0.0 0.0 2023-10-04 13:00:00 \n", + "\n", + " pickup_location_id \n", + "134 1 \n", + "212 2 \n", + "40 3 \n", + "220 4 \n", + "69 5 \n", + "\n", + "[5 rows x 674 columns]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "features.head()" + ] + }, { "cell_type": "code", "execution_count": 3, diff --git a/src/app.py b/src/app.py index a62bbb0..43749d1 100644 --- a/src/app.py +++ b/src/app.py @@ -25,11 +25,6 @@ home_title = "Taxi Demand Prediction" st.markdown(f"""# {home_title} Web App""", unsafe_allow_html=True) -st.markdown("""\n""") - -loading_info = st.empty() - -st.markdown("#### Greetings 🚖") st.write( """ Welcome to the Taxi Demand Predictor Hub, where cutting-edge Machine Learning meets urban mobility needs. For those interested in the technical aspects, the project repository offers comprehensive insights. @@ -39,9 +34,14 @@ # App Component ac.robo_avatar_component() +st.markdown("""\n""") + +loading_info = st.empty() + + # Sidebar progress_bar = st.sidebar.header(":gear: Project Progress") -progress_bar.progress(0) +progress_bar = st.sidebar.progress(0) # constant for number of steps in progress bar N_STEPS = 4 @@ -107,7 +107,7 @@ def get_predictions_for_date(df, target_date): elif prev_hour_predictions_ready: predictions_df = get_predictions_for_date(predictions_df, current_date - timedelta(hours=1)) current_date -= timedelta(hours=1) - st.subheader('⚠️ The most recent data is not yet available. Using last hour predictions') + # st.write('⚠️ The most recent data is not yet available. Using last hour predictions') else: raise Exception('Features are not available for the last 2 hours. Is your feature pipeline up and running? 🤔') @@ -182,29 +182,27 @@ def pseudocolor(val, minval, maxval, startcolor, stopcolor): ) st.pydeck_chart(r) + st.sidebar.write('⚠️ Ongoing Work') progress_bar.progress(4/N_STEPS) -ac.render_contact() - - # Real-world Machine Learning Section -st.markdown("\n") -st.markdown("#### Real-World Machine Learning 🛠") -st.write(""" - Welcome to a real-world ML service predicting NYC taxi rides, crafted with MLOps best practices. Transitioning from raw data to a robust data pipeline, and from a model prototype to a fully-functional batch-scoring system, powered by a Feature Store and GitHub Actions. +st.sidebar.warning(""" + The deployment of our Streamlit web app is in progress. I'll be deploying and updating the Streamlit app and the repository in the coming days.""" + ) +st.sidebar.markdown("\n") +st.sidebar.markdown("\n\n\n") + +st.sidebar.markdown("#### 🛠 About the Project") +st.sidebar.write(""" + Welcome to a real-world ML service predicting NYC taxi rides, crafted with MLOps best practices. Transitioning from raw data to a robust data pipeline, and from a model prototype to a fully-functional batch-scoring system. """) # Ongoing Work Section -st.markdown("#### Ongoing Work 🚧") -st.markdown(""" - I'll be deploying and updating the Streamlit app and the repository in the coming days.""" - ) -st.markdown("\n") -st.info(""" - The deployment of our Streamlit web app is in progress. \n\n**Stay updated:** While waiting for the full app to be live, you can also [check out the repository here.](https://github.com/carlosfab/taxi_demand_predictor) -.\n\n- Connect with me on [LinkedIn](http://linkedin.com/in/carlos-melo-data-science/).\n- Read my articles on my [personal blog](https://sigmoidal.ai/en). - """) +# st.sidebar.markdown("#### 🚧 Ongoing Work ") + # Repository Link Button -st.link_button(":star: Star the Repository!", "https://github.com/carlosfab/taxi_demand_predictor", type='secondary', use_container_width=True) +st.sidebar.link_button(":star: Star the Repository!", "https://github.com/carlosfab/taxi_demand_predictor", type='secondary', use_container_width=True) + +ac.render_contact()