Update app.py
Browse files
app.py
CHANGED
|
@@ -44,6 +44,76 @@ if "learning_rate" not in st.session_state:
|
|
| 44 |
# Full-width layout
|
| 45 |
st.set_page_config(layout="wide")
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
# Page Layout
|
| 48 |
st.title("π Gradient Descent Interactive Tool π")
|
| 49 |
|
|
@@ -53,8 +123,22 @@ col1, col2 = st.columns([1, 2])
|
|
| 53 |
with col1:
|
| 54 |
st.subheader("π§ Define Your Function")
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
func_input = st.text_input(
|
| 57 |
-
"
|
| 58 |
key="func_input",
|
| 59 |
on_change=reset_state
|
| 60 |
)
|
|
|
|
| 44 |
# Full-width layout
|
| 45 |
st.set_page_config(layout="wide")
|
| 46 |
|
| 47 |
+
# CSS Styles for Borders, Font, Reduced Padding, and Custom Border Color
|
| 48 |
+
st.markdown(
|
| 49 |
+
"""
|
| 50 |
+
<style>
|
| 51 |
+
* {
|
| 52 |
+
font-family: Cambria, Arial, sans-serif !important;
|
| 53 |
+
}
|
| 54 |
+
h1, h2, h3, h4, h5 {
|
| 55 |
+
text-align: center;
|
| 56 |
+
margin-top: 0;
|
| 57 |
+
}
|
| 58 |
+
input, .stButton button, .stDownloadButton button {
|
| 59 |
+
border: 2px solid #ea445a;
|
| 60 |
+
border-radius: 5px;
|
| 61 |
+
padding: 10px;
|
| 62 |
+
}
|
| 63 |
+
.stInfo, .stSuccess {
|
| 64 |
+
border: 2px solid #ea445a;
|
| 65 |
+
border-radius: 5px;
|
| 66 |
+
padding: 10px;
|
| 67 |
+
}
|
| 68 |
+
.stButton {
|
| 69 |
+
margin-top: 10px;
|
| 70 |
+
}
|
| 71 |
+
.css-1d391kg {
|
| 72 |
+
padding-top: 0.5rem;
|
| 73 |
+
}
|
| 74 |
+
.stPlotlyChart {
|
| 75 |
+
display: block;
|
| 76 |
+
margin: 0 auto;
|
| 77 |
+
}
|
| 78 |
+
.css-1lcbvhc {
|
| 79 |
+
padding-left: 0;
|
| 80 |
+
padding-right: 0;
|
| 81 |
+
}
|
| 82 |
+
.stTextInput input, .stNumberInput input {
|
| 83 |
+
border: 2px solid #001A6E;
|
| 84 |
+
border-radius: 5px;
|
| 85 |
+
padding: 10px;
|
| 86 |
+
}
|
| 87 |
+
.tooltip {
|
| 88 |
+
position: relative;
|
| 89 |
+
display: inline-block;
|
| 90 |
+
cursor: pointer;
|
| 91 |
+
}
|
| 92 |
+
.tooltip .tooltiptext {
|
| 93 |
+
visibility: hidden;
|
| 94 |
+
opacity: 0;
|
| 95 |
+
width: 300px;
|
| 96 |
+
background-color: #001A6E;
|
| 97 |
+
color: #fff;
|
| 98 |
+
text-align: center;
|
| 99 |
+
border-radius: 5px;
|
| 100 |
+
padding: 5px;
|
| 101 |
+
position: absolute;
|
| 102 |
+
z-index: 1;
|
| 103 |
+
bottom: 125%;
|
| 104 |
+
left: 50%;
|
| 105 |
+
margin-left: -150px;
|
| 106 |
+
transition: opacity 0.3s;
|
| 107 |
+
}
|
| 108 |
+
.tooltip:hover .tooltiptext {
|
| 109 |
+
visibility: visible;
|
| 110 |
+
opacity: 1;
|
| 111 |
+
}
|
| 112 |
+
</style>
|
| 113 |
+
""",
|
| 114 |
+
unsafe_allow_html=True,
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
# Page Layout
|
| 118 |
st.title("π Gradient Descent Interactive Tool π")
|
| 119 |
|
|
|
|
| 123 |
with col1:
|
| 124 |
st.subheader("π§ Define Your Function")
|
| 125 |
|
| 126 |
+
st.markdown(
|
| 127 |
+
"""
|
| 128 |
+
<div class="tooltip">
|
| 129 |
+
<label for="func_input">Enter a function of 'x':</label>
|
| 130 |
+
<span class="tooltiptext">
|
| 131 |
+
**How to input your function:**
|
| 132 |
+
- Use `x**n` for powers of x
|
| 133 |
+
- Use `np.sin(x)`, `np.log(x)`, or `np.exp(x)` for trigonometric, logarithmic, or exponential functions.
|
| 134 |
+
</span>
|
| 135 |
+
</div>
|
| 136 |
+
""",
|
| 137 |
+
unsafe_allow_html=True
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
func_input = st.text_input(
|
| 141 |
+
"π",
|
| 142 |
key="func_input",
|
| 143 |
on_change=reset_state
|
| 144 |
)
|