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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Custom CSS styling
|
| 4 |
+
def add_custom_css():
|
| 5 |
+
st.markdown(
|
| 6 |
+
"""
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: 'Arial', sans-serif;
|
| 10 |
+
background-color: #f7f9fc;
|
| 11 |
+
}
|
| 12 |
+
.title {
|
| 13 |
+
text-align: center;
|
| 14 |
+
font-size: 2.5rem;
|
| 15 |
+
color: #1f77b4;
|
| 16 |
+
font-weight: bold;
|
| 17 |
+
margin-bottom: 20px;
|
| 18 |
+
}
|
| 19 |
+
.subtitle {
|
| 20 |
+
text-align: center;
|
| 21 |
+
font-size: 1.5rem;
|
| 22 |
+
color: #555555;
|
| 23 |
+
margin-top: -15px;
|
| 24 |
+
margin-bottom: 30px;
|
| 25 |
+
}
|
| 26 |
+
.button-container {
|
| 27 |
+
display: flex;
|
| 28 |
+
justify-content: space-evenly;
|
| 29 |
+
margin: 20px 0;
|
| 30 |
+
}
|
| 31 |
+
.stage-button {
|
| 32 |
+
background-color: #1f77b4;
|
| 33 |
+
color: white;
|
| 34 |
+
border: none;
|
| 35 |
+
border-radius: 8px;
|
| 36 |
+
padding: 10px 20px;
|
| 37 |
+
font-size: 1.2rem;
|
| 38 |
+
cursor: pointer;
|
| 39 |
+
text-transform: uppercase;
|
| 40 |
+
transition: background-color 0.3s ease;
|
| 41 |
+
}
|
| 42 |
+
.stage-button:hover {
|
| 43 |
+
background-color: #145a86;
|
| 44 |
+
}
|
| 45 |
+
.back-button {
|
| 46 |
+
background-color: #ff6347;
|
| 47 |
+
color: white;
|
| 48 |
+
border: none;
|
| 49 |
+
border-radius: 8px;
|
| 50 |
+
padding: 10px 20px;
|
| 51 |
+
font-size: 1rem;
|
| 52 |
+
cursor: pointer;
|
| 53 |
+
margin-top: 20px;
|
| 54 |
+
transition: background-color 0.3s ease;
|
| 55 |
+
}
|
| 56 |
+
.back-button:hover {
|
| 57 |
+
background-color: #d9534f;
|
| 58 |
+
}
|
| 59 |
+
</style>
|
| 60 |
+
""",
|
| 61 |
+
unsafe_allow_html=True,
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
# Functions for each page
|
| 65 |
+
def home_page():
|
| 66 |
+
st.markdown("<div class='title'>Machine Learning Lifecycle</div>", unsafe_allow_html=True)
|
| 67 |
+
st.markdown("<div class='subtitle'>Explore the stages of an ML project!</div>", unsafe_allow_html=True)
|
| 68 |
+
|
| 69 |
+
st.image("https://via.placeholder.com/800x400?text=ML+Lifecycle", caption="Visual Representation of ML Lifecycle")
|
| 70 |
+
|
| 71 |
+
st.markdown(
|
| 72 |
+
"""
|
| 73 |
+
<div class="button-container">
|
| 74 |
+
<button class="stage-button" onclick="location.href='?page=problem_definition'">1. Problem Definition</button>
|
| 75 |
+
<button class="stage-button" onclick="location.href='?page=data_collection'">2. Data Collection</button>
|
| 76 |
+
<button class="stage-button" onclick="location.href='?page=data_preparation'">3. Data Preparation</button>
|
| 77 |
+
</div>
|
| 78 |
+
<div class="button-container">
|
| 79 |
+
<button class="stage-button" onclick="location.href='?page=modeling'">4. Modeling</button>
|
| 80 |
+
<button class="stage-button" onclick="location.href='?page=evaluation'">5. Evaluation</button>
|
| 81 |
+
<button class="stage-button" onclick="location.href='?page=deployment'">6. Deployment</button>
|
| 82 |
+
</div>
|
| 83 |
+
""",
|
| 84 |
+
unsafe_allow_html=True,
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
def problem_definition_page():
|
| 88 |
+
st.markdown("<div class='title'>π― Problem Definition</div>", unsafe_allow_html=True)
|
| 89 |
+
st.write("Define the problem your machine learning model aims to solve.")
|
| 90 |
+
st.image("https://via.placeholder.com/600x300?text=Define+Problem", caption="Example: Problem Definition")
|
| 91 |
+
st.markdown(
|
| 92 |
+
"<button class='back-button' onclick=\"location.href='?page=home'\">Back to Home</button>",
|
| 93 |
+
unsafe_allow_html=True,
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
def data_collection_page():
|
| 97 |
+
st.markdown("<div class='title'>π Data Collection</div>", unsafe_allow_html=True)
|
| 98 |
+
st.write("Gather data relevant to the problem and verify data sources.")
|
| 99 |
+
st.image("https://via.placeholder.com/600x300?text=Data+Collection", caption="Data Sources Overview")
|
| 100 |
+
st.markdown(
|
| 101 |
+
"<button class='back-button' onclick=\"location.href='?page=home'\">Back to Home</button>",
|
| 102 |
+
unsafe_allow_html=True,
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
def data_preparation_page():
|
| 106 |
+
st.markdown("<div class='title'>π Data Preparation</div>", unsafe_allow_html=True)
|
| 107 |
+
st.write("Preprocess, clean, and split the data into train, validation, and test sets.")
|
| 108 |
+
st.image("https://via.placeholder.com/600x300?text=Data+Preparation", caption="Data Preparation Overview")
|
| 109 |
+
st.markdown(
|
| 110 |
+
"<button class='back-button' onclick=\"location.href='?page=home'\">Back to Home</button>",
|
| 111 |
+
unsafe_allow_html=True,
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
def modeling_page():
|
| 115 |
+
st.markdown("<div class='title'>π€ Modeling</div>", unsafe_allow_html=True)
|
| 116 |
+
st.write("Train machine learning models and tune hyperparameters.")
|
| 117 |
+
st.image("https://via.placeholder.com/600x300?text=Modeling", caption="Model Training Visualization")
|
| 118 |
+
st.markdown(
|
| 119 |
+
"<button class='back-button' onclick=\"location.href='?page=home'\">Back to Home</button>",
|
| 120 |
+
unsafe_allow_html=True,
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
def evaluation_page():
|
| 124 |
+
st.markdown("<div class='title'>β
Evaluation</div>", unsafe_allow_html=True)
|
| 125 |
+
st.write("Evaluate model performance using standard metrics.")
|
| 126 |
+
st.image("https://via.placeholder.com/600x300?text=Evaluation", caption="Evaluation Metrics Overview")
|
| 127 |
+
st.markdown(
|
| 128 |
+
"<button class='back-button' onclick=\"location.href='?page=home'\">Back to Home</button>",
|
| 129 |
+
unsafe_allow_html=True,
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
def deployment_page():
|
| 133 |
+
st.markdown("<div class='title'>π Deployment</div>", unsafe_allow_html=True)
|
| 134 |
+
st.write("Deploy your model for real-world use.")
|
| 135 |
+
st.image("https://via.placeholder.com/600x300?text=Deployment+Pipeline", caption="Deployment Pipeline")
|
| 136 |
+
st.markdown(
|
| 137 |
+
"<button class='back-button' onclick=\"location.href='?page=home'\">Back to Home</button>",
|
| 138 |
+
unsafe_allow_html=True,
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
# Main routing logic
|
| 142 |
+
def main():
|
| 143 |
+
add_custom_css()
|
| 144 |
+
query_params = st.experimental_get_query_params()
|
| 145 |
+
page = query_params.get("page", ["home"])[0]
|
| 146 |
+
|
| 147 |
+
if page == "home":
|
| 148 |
+
home_page()
|
| 149 |
+
elif page == "problem_definition":
|
| 150 |
+
problem_definition_page()
|
| 151 |
+
elif page == "data_collection":
|
| 152 |
+
data_collection_page()
|
| 153 |
+
elif page == "data_preparation":
|
| 154 |
+
data_preparation_page()
|
| 155 |
+
elif page == "modeling":
|
| 156 |
+
modeling_page()
|
| 157 |
+
elif page == "evaluation":
|
| 158 |
+
evaluation_page()
|
| 159 |
+
elif page == "deployment":
|
| 160 |
+
deployment_page()
|
| 161 |
+
else:
|
| 162 |
+
st.error("Page not found!")
|
| 163 |
+
|
| 164 |
+
if __name__ == "__main__":
|
| 165 |
+
main()
|