Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import math
|
3 |
+
|
4 |
+
# Define the conversion table from French to Ewbank grades
|
5 |
+
french_to_ewbank = {
|
6 |
+
'4a/4a+': 13, '4b/4b+': 14, '4c/4c+': 15,
|
7 |
+
'5a': 15.5, '5a+/5b': 16, '5b+': 17, '5c': 17.5,
|
8 |
+
'5c+/6a': 18, '6a+': 19,
|
9 |
+
'6b': 20, '6b+': 21, '6c': 21.5, '6c+': 22.5,
|
10 |
+
'7a': 23, '7a+': 24, '7b': 25, '7b+': 26,
|
11 |
+
'7c': 27, '7c+': 28, '8a': 29, '8a+': 30,
|
12 |
+
'8b': 31, '8b+': 32, '8c': 33, '9a': 35,
|
13 |
+
'9b': 37, '9c': 39
|
14 |
+
}
|
15 |
+
|
16 |
+
# Function to convert French grades to Ewbank grades
|
17 |
+
def convert_french_to_ewbank(french_grade):
|
18 |
+
return french_to_ewbank.get(french_grade, None)
|
19 |
+
|
20 |
+
# Function to calculate the probability of success
|
21 |
+
def calculate_probability_of_success(current_grade_ewbank, route_grade_ewbank, m_parameter):
|
22 |
+
probability_success = 1 / (math.exp(m_parameter * (route_grade_ewbank - current_grade_ewbank)) + 1)
|
23 |
+
expected_attempts = (1 - probability_success) / probability_success
|
24 |
+
return probability_success, expected_attempts
|
25 |
+
|
26 |
+
# Streamlit app
|
27 |
+
def main():
|
28 |
+
st.title("Climbing Grade Success Estimator")
|
29 |
+
|
30 |
+
# Sidebar for references
|
31 |
+
st.sidebar.header("How it works?")
|
32 |
+
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)""")
|
33 |
+
|
34 |
+
st.sidebar.write("""\n\n [Here you can find a table for grade conversion](https://www.thecrag.com/en/article/grades)""")
|
35 |
+
|
36 |
+
st.sidebar.header("\n\nOriginal Paper Citation:")
|
37 |
+
st.sidebar.text("""
|
38 |
+
@misc{drummond2021bayesian,
|
39 |
+
title={Bayesian inference of the climbing grade scale},
|
40 |
+
author={Alexei Drummond and Alex Popinga},
|
41 |
+
year={2021},
|
42 |
+
eprint={2111.08140},
|
43 |
+
archivePrefix={arXiv},
|
44 |
+
primaryClass={stat.AP}
|
45 |
+
}
|
46 |
+
""")
|
47 |
+
|
48 |
+
st.write("Select your current climbing grade and the grade of the route you plan to climb. Grades are expressed following the French system.")
|
49 |
+
current_grade_french = st.selectbox("Climber's Current Grade (French)", options=list(french_to_ewbank.keys()))
|
50 |
+
route_grade_french = st.selectbox("Route Grade (French)", options=list(french_to_ewbank.keys()))
|
51 |
+
m_parameter = 0.85 # Slope parameter from the paper for Ewbank scale
|
52 |
+
|
53 |
+
if st.button("Estimate Probability"):
|
54 |
+
current_grade_ewbank = convert_french_to_ewbank(current_grade_french)
|
55 |
+
route_grade_ewbank = convert_french_to_ewbank(route_grade_french)
|
56 |
+
probability, attempts = calculate_probability_of_success(current_grade_ewbank, route_grade_ewbank, m_parameter)
|
57 |
+
st.success(f"Probability of Success: {probability*100:.2f}%")
|
58 |
+
st.success(f"Expected Number of Attempts: {attempts:.2f}")
|
59 |
+
|
60 |
+
if __name__ == "__main__":
|
61 |
+
main()
|