Skip to content

Commit

Permalink
Streamlit App updated
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosfab committed Oct 4, 2023
1 parent 1b7bad0 commit 7862b40
Show file tree
Hide file tree
Showing 2 changed files with 273 additions and 24 deletions.
251 changes: 251 additions & 0 deletions notebooks/14_inference_pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,257 @@
"features = load_batch_of_features_from_store(current_date)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>rides_previous_672_hour</th>\n",
" <th>rides_previous_671_hour</th>\n",
" <th>rides_previous_670_hour</th>\n",
" <th>rides_previous_669_hour</th>\n",
" <th>rides_previous_668_hour</th>\n",
" <th>rides_previous_667_hour</th>\n",
" <th>rides_previous_666_hour</th>\n",
" <th>rides_previous_665_hour</th>\n",
" <th>rides_previous_664_hour</th>\n",
" <th>rides_previous_663_hour</th>\n",
" <th>...</th>\n",
" <th>rides_previous_8_hour</th>\n",
" <th>rides_previous_7_hour</th>\n",
" <th>rides_previous_6_hour</th>\n",
" <th>rides_previous_5_hour</th>\n",
" <th>rides_previous_4_hour</th>\n",
" <th>rides_previous_3_hour</th>\n",
" <th>rides_previous_2_hour</th>\n",
" <th>rides_previous_1_hour</th>\n",
" <th>pickup_hour</th>\n",
" <th>pickup_location_id</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>134</th>\n",
" <td>2.0</td>\n",
" <td>4.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>2.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>3.0</td>\n",
" <td>1.0</td>\n",
" <td>2023-10-04 13:00:00</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>212</th>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>2023-10-04 13:00:00</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40</th>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>2023-10-04 13:00:00</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>220</th>\n",
" <td>6.0</td>\n",
" <td>4.0</td>\n",
" <td>3.0</td>\n",
" <td>3.0</td>\n",
" <td>4.0</td>\n",
" <td>10.0</td>\n",
" <td>5.0</td>\n",
" <td>4.0</td>\n",
" <td>6.0</td>\n",
" <td>7.0</td>\n",
" <td>...</td>\n",
" <td>1.0</td>\n",
" <td>3.0</td>\n",
" <td>3.0</td>\n",
" <td>11.0</td>\n",
" <td>7.0</td>\n",
" <td>8.0</td>\n",
" <td>4.0</td>\n",
" <td>2.0</td>\n",
" <td>2023-10-04 13:00:00</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>69</th>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>2023-10-04 13:00:00</td>\n",
" <td>5</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 674 columns</p>\n",
"</div>"
],
"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,
Expand Down
46 changes: 22 additions & 24 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
home_title = "Taxi Demand Prediction"
st.markdown(f"""# {home_title} <span style=color:#2E9BF5><font size=5>Web App</font></span>""", 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.
Expand All @@ -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
Expand Down Expand Up @@ -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? 🤔')

Expand Down Expand Up @@ -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()

0 comments on commit 7862b40

Please sign in to comment.