import streamlit as st import math # Define the conversion table from French to Ewbank grades french_to_ewbank = { '4a/4a+': 13, '4b/4b+': 14, '4c/4c+': 15, '5a': 15.5, '5a+/5b': 16, '5b+': 17, '5c': 17.5, '5c+/6a': 18, '6a+': 19, '6b': 20, '6b+': 21, '6c': 21.5, '6c+': 22.5, '7a': 23, '7a+': 24, '7b': 25, '7b+': 26, '7c': 27, '7c+': 28, '8a': 29, '8a+': 30, '8b': 31, '8b+': 32, '8c': 33, '9a': 35, '9b': 37, '9c': 39 } # Function to convert French grades to Ewbank grades def convert_french_to_ewbank(french_grade): return french_to_ewbank.get(french_grade, None) # Function to calculate the probability of success def calculate_probability_of_success(current_grade_ewbank, route_grade_ewbank, m_parameter): probability_success = 1 / (math.exp(m_parameter * (route_grade_ewbank - current_grade_ewbank)) + 1) expected_attempts = (1 - probability_success) / probability_success return probability_success, expected_attempts # Streamlit app def main(): st.title("Climbing Grade Success Estimator") # Sidebar for references st.sidebar.header("How it works?") st.sidebar.write("""Based on the work presented in the paper 'Bayesian inference of the climbing grade scale' available on [ArXiv](https://arxiv.org/abs/2111.08140)""") st.sidebar.write("""\n\n[Here you can find a table for grade conversion](https://www.thecrag.com/en/article/grades)""") st.sidebar.header("\n\nOriginal Paper Citation:") st.sidebar.text(""" @misc{drummond2021bayesian, title={Bayesian inference of the climbing grade scale}, author={Alexei Drummond and Alex Popinga}, year={2021}, eprint={2111.08140}, archivePrefix={arXiv}, primaryClass={stat.AP} } """) st.sidebar.write("""\n\nDeveloped by Edoardo Bianchi""") st.write("Select your current climbing grade and the grade of the route you plan to climb. Grades are expressed following the French system.") current_grade_french = st.selectbox("Climber's Current Grade (French)", options=list(french_to_ewbank.keys())) route_grade_french = st.selectbox("Route Grade (French)", options=list(french_to_ewbank.keys())) m_parameter = 0.85 # Slope parameter from the paper for Ewbank scale if st.button("Estimate Probability"): current_grade_ewbank = convert_french_to_ewbank(current_grade_french) route_grade_ewbank = convert_french_to_ewbank(route_grade_french) probability, attempts = calculate_probability_of_success(current_grade_ewbank, route_grade_ewbank, m_parameter) st.success(f"Probability of Success: {probability*100:.2f}%") st.success(f"Expected Number of Attempts: {attempts:.2f}") if __name__ == "__main__": main()