Streamlit is an open-source app framework for Machine Learning and Data Science teams. It allows programmers to create chic data apps in hours, that can be viewed and interacted with by non ‘coding-savvy’ users.

For my capstone project at Flatiron, I chose to build a climbing recommendation engine. I wanted to create a friendly user interface, so I chose to use Streamlit. I began this process by installing Streamlit.

pip install streamlit

After that I created a new recommender.py file that I used to run my streamlit application. I started by importing all the libraries and other flies I would be using.

import streamlit as st  #imports the streamlit library and framework
from PIL import Image #used to display images on streamlit
import models #models.py ran my rec system

I began by using Streamlit intuitive interface to create a Title for the page.

#title
st.title(“Climb Recommender”)

I wanted an image, so I added one using the below code.

img = Image.open(‘figures/8561A9D4–5B9B-4973-A54E-22BC5544AD6F_1_105_c.jpeg’)
st.image(img, caption=’El Cajon Mountain, San Diego’)

I then needed to get information from the user about the climb and geographic location to search. This was achieved using the st.text_input function which allows the user to input text. I also used the st.number_input to get numeric values from the user. For the zipcode and radius section I chose to select a default value.

#header
st.header(‘Input the reference climb using Mountain Project ID’)
st.subheader(‘You can include search area(using zip or city & state) and radius range in miles, \n https://www.mountainproject.com/area/classics <- link to climbs’)
#ask user for input
climb_id = st.text_input(‘Enter target climb ID (or mountain project url for target climb):’)
zip_code = st.text_input(‘Enter zip code to search for similar climbs in that area:’, ‘92008’)
st.info(‘Or search by city and state’)
city = st.text_input(‘Enter city to search in that area:’, ‘’)
state = st.text_input(‘Enter state to search in that area:’, ‘’)
st.text(‘Lastly, enter the search radius (defaults to 60 miles)’)
radius_range = st.number_input(‘Enter radius to search in specified area:’, default_range)
Input boxes for the user

Finally I used the a st.button function to take all the user inputed information and use it to run my recommendation system.

test = st.button(‘Search for recommended climbs’)

Lastly I used the st.dataframe function with returned my results in a next excel style format.

st.dataframe(models.get_wrecked(target_id=climb_id, target_state=state,target_city=city,
target_zipcode=zip_code,target_radius_range=radius_range,star_limit=3.5))
st.success(‘Finished’) #shows the green Finished banner

Video of Climbing recommender streamlit app

Reference

https://github.com/gseemann/climb_recommender

Data Scientist