Spaces:
Sleeping
Sleeping
Update pages/3_Life cycle of ML.py
Browse files- pages/3_Life cycle of ML.py +56 -175
pages/3_Life cycle of ML.py
CHANGED
|
@@ -1,183 +1,64 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import webbrowser
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
steps = {
|
| 6 |
-
"Problem Statement": "
|
| 7 |
-
"Data Collection": "
|
| 8 |
-
"Simple EDA": "
|
| 9 |
-
"Data Pre-Processing": "
|
| 10 |
-
"EDA": "
|
| 11 |
-
"Feature Engineering": "
|
| 12 |
-
"
|
| 13 |
-
"Testing": "
|
| 14 |
-
"Deployment
|
|
|
|
| 15 |
}
|
| 16 |
-
st.write(f"### {step_name}")
|
| 17 |
-
st.write(steps[step_name])
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
st.
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
st.title("Machine Learning Lifecycle")
|
| 36 |
-
|
| 37 |
-
display_lifecycle_step(selected_step)
|
| 38 |
-
|
| 39 |
-
st.markdown("""
|
| 40 |
-
<style>
|
| 41 |
-
.stApp {
|
| 42 |
-
background-color: #f0f0f5;
|
| 43 |
-
font-family: 'Arial', sans-serif;
|
| 44 |
-
}
|
| 45 |
-
.stSidebar .sidebar-content {
|
| 46 |
-
background-color: #e3e4e8;
|
| 47 |
-
border-radius: 10px;
|
| 48 |
-
padding: 10px;
|
| 49 |
-
}
|
| 50 |
-
.stButton > button {
|
| 51 |
-
background-color: #008CBA;
|
| 52 |
color: white;
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
padding:
|
|
|
|
|
|
|
|
|
|
| 56 |
}
|
| 57 |
-
.stButton
|
| 58 |
-
background-color: #
|
| 59 |
}
|
| 60 |
-
|
| 61 |
-
""",
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
st.write("### What is Data?")
|
| 65 |
-
st.write("""
|
| 66 |
-
Data is a collection of facts, numbers, words, or observations that can be used to learn about something.
|
| 67 |
-
It can be raw and unprocessed
|
| 68 |
-
It can be structured or unstructured and comes from various sources.
|
| 69 |
-
""")
|
| 70 |
-
|
| 71 |
-
st.write("### Types of Data")
|
| 72 |
-
st.write("""
|
| 73 |
-
1. *Structured Data*: Organized data that follows a schema (e.g., rows and columns, sql).
|
| 74 |
-
2. *Unstructured Data*: Data that doesn't follow a predefined model (e.g., images, text, audio and video).
|
| 75 |
-
3. *Semi-Structured Data*: Data that has some organizational properties but isn't fully structured (e.g., JSON, XML, CSV,HTML).
|
| 76 |
-
""")
|
| 77 |
-
|
| 78 |
-
selected_data_type = st.radio("Choose Data Type", ["Structured Data", "Unstructured Data", "Semi-Structured Data"])
|
| 79 |
-
|
| 80 |
-
if selected_data_type == "Structured Data":
|
| 81 |
-
display_structured_data_info()
|
| 82 |
-
|
| 83 |
-
def display_structured_data_info():
|
| 84 |
-
st.write("### Structured Data")
|
| 85 |
-
st.write("Structured data is data that is highly organized and stored in a fixed format, like tables, rows, and columns.")
|
| 86 |
-
|
| 87 |
-
# Button for each structured data format (Excel, CSV, XML)
|
| 88 |
-
data_formats = st.radio("Choose a Data Format", ["Excel", "CSV", "XML"])
|
| 89 |
-
|
| 90 |
-
if data_formats == "Excel":
|
| 91 |
-
display_excel_info()
|
| 92 |
-
elif data_formats == "CSV":
|
| 93 |
-
display_csv_info()
|
| 94 |
-
elif data_formats == "XML":
|
| 95 |
-
display_xml_info()
|
| 96 |
-
|
| 97 |
-
# Function to display Excel-related information
|
| 98 |
-
def display_excel_info():
|
| 99 |
-
st.write("### Excel Format")
|
| 100 |
-
st.write("""
|
| 101 |
-
*What it is*: Excel is a popular spreadsheet format commonly used for storing and analyzing structured data.
|
| 102 |
-
|
| 103 |
-
*How to read these files*:
|
| 104 |
-
- Use pandas.read_excel() to read Excel files in Python.
|
| 105 |
-
|
| 106 |
-
*Issues encountered when handling Excel files*:
|
| 107 |
-
- Large files can cause memory issues.
|
| 108 |
-
- Compatibility problems with different Excel versions.
|
| 109 |
-
|
| 110 |
-
*How to overcome these errors*:
|
| 111 |
-
- Break large files into smaller chunks.
|
| 112 |
-
- Use libraries like openpyxl for handling newer Excel files and xlrd for older ones.
|
| 113 |
-
""")
|
| 114 |
-
|
| 115 |
-
# Button to open the Jupyter Notebook or PDF with coding examples
|
| 116 |
-
if st.button("Open Excel Code Example"):
|
| 117 |
-
open_code_example("excel")
|
| 118 |
-
|
| 119 |
-
# Function to display CSV-related information
|
| 120 |
-
def display_csv_info():
|
| 121 |
-
st.write("### CSV Format")
|
| 122 |
-
st.write("""
|
| 123 |
-
*What it is*: CSV (Comma Separated Values) is a text format for representing tabular data, where values are separated by commas.
|
| 124 |
-
|
| 125 |
-
*How to read these files*:
|
| 126 |
-
- Use pandas.read_csv() to read CSV files in Python.
|
| 127 |
-
|
| 128 |
-
*Issues encountered when handling CSV files*:
|
| 129 |
-
- Improper handling of special characters or delimiters.
|
| 130 |
-
- Missing or inconsistent data.
|
| 131 |
-
|
| 132 |
-
*How to overcome these errors*:
|
| 133 |
-
- Specify delimiters using the delimiter parameter.
|
| 134 |
-
- Handle missing data by using fillna() or dropna() methods in pandas.
|
| 135 |
-
""")
|
| 136 |
-
|
| 137 |
-
# Button to open the Jupyter Notebook or PDF with coding examples
|
| 138 |
-
if st.button("Open CSV Code Example"):
|
| 139 |
-
open_code_example("csv")
|
| 140 |
-
|
| 141 |
-
# Function to display XML-related information
|
| 142 |
-
def display_xml_info():
|
| 143 |
-
st.write("### XML Format")
|
| 144 |
-
st.write("""
|
| 145 |
-
*What it is*: XML (Extensible Markup Language) is a flexible and structured format used to store data in a hierarchical manner.
|
| 146 |
-
|
| 147 |
-
*How to read these files*:
|
| 148 |
-
- Use pandas.read_xml() to read XML files or xml.etree.ElementTree for more complex parsing.
|
| 149 |
-
|
| 150 |
-
*Issues encountered when handling XML files*:
|
| 151 |
-
- Complex nested structures can be hard to parse.
|
| 152 |
-
- Compatibility issues between different XML schemas.
|
| 153 |
-
|
| 154 |
-
*How to overcome these errors*:
|
| 155 |
-
- Use XPath or lxml for more advanced parsing.
|
| 156 |
-
- Handle encoding issues using the encoding parameter while reading the file.
|
| 157 |
-
""")
|
| 158 |
-
|
| 159 |
-
# Button to open the Jupyter Notebook or PDF with coding examples
|
| 160 |
-
if st.button("Open XML Code Example"):
|
| 161 |
-
open_code_example("xml")
|
| 162 |
-
|
| 163 |
-
# Function to open a Jupyter Notebook or PDF for coding examples
|
| 164 |
-
def open_code_example(data_format):
|
| 165 |
-
# Placeholder: Open a PDF/Jupyter notebook link for the data format
|
| 166 |
-
example_links = {
|
| 167 |
-
"excel": "https://yourlinktoexcelcode.com",
|
| 168 |
-
"csv": "https://yourlinktocsvcode.com",
|
| 169 |
-
"xml": "https://yourlinktoxmlcode.com",
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
link = example_links.get(data_format)
|
| 173 |
-
if link:
|
| 174 |
-
webbrowser.open_new_tab(link)
|
| 175 |
-
|
| 176 |
-
def main():
|
| 177 |
-
st.sidebar.title("ML Life Cycle Navigation")
|
| 178 |
-
|
| 179 |
-
if st.sidebar.button("Data Collection"):
|
| 180 |
-
data_collection_page()
|
| 181 |
-
|
| 182 |
-
if __name__ == "__main__":
|
| 183 |
-
main()
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
+
# Initialize session state for navigation
|
| 4 |
+
if "page" not in st.session_state:
|
| 5 |
+
st.session_state.page = "main"
|
| 6 |
+
|
| 7 |
+
def navigate_to(page_name):
|
| 8 |
+
st.session_state.page = page_name
|
| 9 |
+
|
| 10 |
+
if st.session_state.page == "main":
|
| 11 |
+
# Main Page Header
|
| 12 |
+
st.markdown(
|
| 13 |
+
"""
|
| 14 |
+
<div style="background-color: #f0f0f5; padding: 10px; border-radius: 5px; text-align: center;">
|
| 15 |
+
<h2 style="color: #4a90e2; font-family: Arial, sans-serif;">ML Project Life Cycle</h2>
|
| 16 |
+
</div>
|
| 17 |
+
""",
|
| 18 |
+
unsafe_allow_html=True,
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# Steps and Descriptions
|
| 22 |
steps = {
|
| 23 |
+
"1. Problem Statement": "Define the aim/goal of the ML model.",
|
| 24 |
+
"2. Data Collection": "Gather data from various sources like APIs and web scraping.",
|
| 25 |
+
"3. Simple EDA": "Explore data for missing values and outliers.",
|
| 26 |
+
"4. Data Pre-Processing": "Clean and transform the data.",
|
| 27 |
+
"5. EDA": "Gain further insights and visualize the data.",
|
| 28 |
+
"6. Feature Engineering": "Create new features for better model performance.",
|
| 29 |
+
"7. Training the Model": "Train the model using the prepared dataset.",
|
| 30 |
+
"8. Testing the Data": "Test and evaluate model performance.",
|
| 31 |
+
"9. Deployment": "Deploy the model for real-world usage.",
|
| 32 |
+
"10. Monitoring": "Monitor model performance and update as needed.",
|
| 33 |
}
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
# Step Selector
|
| 36 |
+
step = st.selectbox("Select a step in the ML life cycle:", list(steps.keys()))
|
| 37 |
+
st.write(f"**{step}**: {steps[step]}")
|
| 38 |
+
|
| 39 |
+
# Navigation Button
|
| 40 |
+
if step == "2. Data Collection":
|
| 41 |
+
if st.button("Learn More About Data Collection"):
|
| 42 |
+
navigate_to("data_collection")
|
| 43 |
+
|
| 44 |
+
# Custom Style
|
| 45 |
+
st.markdown(
|
| 46 |
+
"""
|
| 47 |
+
<style>
|
| 48 |
+
.stButton button {
|
| 49 |
+
font-size: 16px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
color: white;
|
| 51 |
+
background-color: #007bff;
|
| 52 |
+
border: none;
|
| 53 |
+
padding: 10px 20px;
|
| 54 |
+
border-radius: 5px;
|
| 55 |
+
cursor: pointer;
|
| 56 |
+
transition: background-color 0.3s ease;
|
| 57 |
}
|
| 58 |
+
.stButton button:hover {
|
| 59 |
+
background-color: #0056b3;
|
| 60 |
}
|
| 61 |
+
</style>
|
| 62 |
+
""",
|
| 63 |
+
unsafe_allow_html=True,
|
| 64 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|