Spaces:
Sleeping
Sleeping
Update pages/3_Life cycle of ML.py
Browse files- pages/3_Life cycle of ML.py +165 -189
pages/3_Life cycle of ML.py
CHANGED
|
@@ -1,207 +1,183 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import webbrowser
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
color: #333333; /* Set text color to dark grey for better readability */
|
| 16 |
}
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
.button:nth-child(7) { transform: rotate(216deg) translate(200px) rotate(-216deg); }
|
| 65 |
-
.button:nth-child(8) { transform: rotate(252deg) translate(200px) rotate(-252deg); }
|
| 66 |
-
.button:nth-child(9) { transform: rotate(288deg) translate(200px) rotate(-288deg); }
|
| 67 |
-
.button:nth-child(10) { transform: rotate(324deg) translate(200px) rotate(-324deg); }
|
| 68 |
-
.center {
|
| 69 |
-
position: absolute;
|
| 70 |
-
top: 60%;
|
| 71 |
-
left: 50%;
|
| 72 |
-
font-size: 1.5rem;
|
| 73 |
-
color: white;
|
| 74 |
-
text-align: center;
|
| 75 |
-
transform: translate(-50%, -50%);
|
| 76 |
-
font-weight: bold;
|
| 77 |
-
}
|
| 78 |
-
</style>
|
| 79 |
-
"""
|
| 80 |
-
|
| 81 |
-
# HTML content for lifecycle buttons in a circular layout
|
| 82 |
-
ml_lifecycle_html = """
|
| 83 |
-
<div class="circle-container">
|
| 84 |
-
<a href="?page=Problem Statement" class="button">Problem Statement</a>
|
| 85 |
-
<a href="?page=data_collection" class="button">Data Collection</a>
|
| 86 |
-
<a href="?page=simple_eda" class="button">Simple EDA</a>
|
| 87 |
-
<a href="?page=data_preprocessing" class="button">Pre Processing</a>
|
| 88 |
-
<a href="?page=EDA" class="button">EDA</a>
|
| 89 |
-
<a href="?page=feature_engineering" class="button">Feature Engineering</a>
|
| 90 |
-
<a href="?page=model_training" class="button">Model Training</a>
|
| 91 |
-
<a href="?page=testing" class="button">Testing</a>
|
| 92 |
-
<a href="?page=deployment" class="button">Deployment</a>
|
| 93 |
-
<a href="?page=monitoring" class="button">Monitoring</a>
|
| 94 |
-
<div class="center"><strong>ML Lifecycle</strong></div>
|
| 95 |
-
</div>
|
| 96 |
-
"""
|
| 97 |
-
|
| 98 |
-
# Functions for page content
|
| 99 |
-
|
| 100 |
-
# Main page with ML lifecycle circle
|
| 101 |
-
def main_page():
|
| 102 |
-
st.markdown(custom_css, unsafe_allow_html=True)
|
| 103 |
-
st.markdown("<h1>Machine Learning Project Lifecycle</h1>", unsafe_allow_html=True)
|
| 104 |
-
st.markdown(ml_lifecycle_html, unsafe_allow_html=True)
|
| 105 |
-
|
| 106 |
-
# Data collection page
|
| 107 |
def data_collection_page():
|
| 108 |
-
st.
|
| 109 |
-
st.title("Data Collection")
|
| 110 |
st.write("""
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
|
|
|
| 118 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
-
# Button
|
| 121 |
-
|
| 122 |
-
semi_structured_data = st.button('Semi-Structured Data')
|
| 123 |
-
unstructured_data = st.button('Unstructured Data')
|
| 124 |
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
elif
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
# Structured Data details
|
| 137 |
-
def show_structured_data():
|
| 138 |
-
st.subheader("Structured Data")
|
| 139 |
st.write("""
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
""")
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
import pandas as pd
|
| 152 |
-
df = pd.read_excel('file.xlsx')
|
| 153 |
-
```
|
| 154 |
-
|
| 155 |
-
**Common Issues:**
|
| 156 |
-
- Large files may cause memory errors.
|
| 157 |
-
- Formatting issues may hinder data processing.
|
| 158 |
-
|
| 159 |
-
**Solutions:**
|
| 160 |
-
- Use `openpyxl` for large files.
|
| 161 |
-
- Preprocess Excel data to remove formatting issues.
|
| 162 |
-
""")
|
| 163 |
-
st.markdown("[Click here for Jupyter Notebook Example](http://localhost:8888/notebooks/yourfile.ipynb)", unsafe_allow_html=True)
|
| 164 |
-
|
| 165 |
-
# Semi-structured Data details
|
| 166 |
-
def show_semi_structured_data():
|
| 167 |
-
st.subheader("Semi-Structured Data")
|
| 168 |
st.write("""
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
""")
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
import pandas as pd
|
| 180 |
-
df = pd.read_csv('file.csv')
|
| 181 |
-
```
|
| 182 |
-
|
| 183 |
-
**Common Issues:**
|
| 184 |
-
- Missing values or inconsistent delimiters.
|
| 185 |
-
|
| 186 |
-
**Solutions:**
|
| 187 |
-
- Use `dropna()` or `fillna()` to handle missing data.
|
| 188 |
-
- Specify delimiters using the `delimiter` parameter.
|
| 189 |
-
""")
|
| 190 |
-
st.markdown("[Click here for Jupyter Notebook Example](http://localhost:8888/notebooks/yourfile.ipynb)", unsafe_allow_html=True)
|
| 191 |
-
|
| 192 |
-
# Unstructured Data details
|
| 193 |
-
def show_unstructured_data():
|
| 194 |
-
st.subheader("Unstructured Data")
|
| 195 |
st.write("""
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
""")
|
| 198 |
-
st.write("This requires advanced models like CNN for images or NLP for text data.")
|
| 199 |
|
| 200 |
-
#
|
| 201 |
-
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
-
if
|
| 205 |
-
|
| 206 |
-
else:
|
| 207 |
-
main_page()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import webbrowser
|
| 3 |
|
| 4 |
+
def display_lifecycle_step(step_name):
|
| 5 |
+
steps = {
|
| 6 |
+
"Problem Statement": "Objective of the project.",
|
| 7 |
+
"Data Collection": "Data is collected from various sources like APIs, databases, or web scraping atlast we've to go with manual collection.",
|
| 8 |
+
"Simple EDA": "Describing the quality of the data.",
|
| 9 |
+
"Data Pre-Processing": "It is a technique by which we can convert raw data into pre-procesed data --->1.Clean the data 2.Transform the data.",
|
| 10 |
+
"EDA": "Transforming insights into a clean dataset and providing proper visualizations.",
|
| 11 |
+
"Feature Engineering": "Creating and analyzing features and labels.",
|
| 12 |
+
"Model Training": "Training the machine about relationships between features and labels.",
|
| 13 |
+
"Testing": "Testing how efficiently the machine learned.",
|
| 14 |
+
"Deployment and Maintenance": "Deploying the machine to the client and ensuring maintenance for accurate results."
|
|
|
|
| 15 |
}
|
| 16 |
+
st.write(f"### {step_name}")
|
| 17 |
+
st.write(steps[step_name])
|
| 18 |
+
|
| 19 |
+
# Sidebar with buttons for lifecycle steps
|
| 20 |
+
st.sidebar.title("ML Lifecycle Steps")
|
| 21 |
+
|
| 22 |
+
# Create buttons for each lifecycle step
|
| 23 |
+
steps_list = [
|
| 24 |
+
"Problem Statement", "Data Collection", "Simple EDA",
|
| 25 |
+
"Data Pre-Processing", "EDA", "Feature Engineering",
|
| 26 |
+
"Model Training", "Testing", "Deployment and Maintenance"
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
selected_step = st.sidebar.radio(
|
| 30 |
+
"Choose a step in the ML lifecycle:",
|
| 31 |
+
steps_list,
|
| 32 |
+
index=0
|
| 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 |
+
border-radius: 50px;
|
| 54 |
+
font-size: 18px;
|
| 55 |
+
padding: 12px 24px;
|
| 56 |
+
}
|
| 57 |
+
.stButton > button:hover {
|
| 58 |
+
background-color: #007B8C;
|
| 59 |
+
}
|
| 60 |
+
</style>
|
| 61 |
+
""", unsafe_allow_html=True)
|
| 62 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
def data_collection_page():
|
| 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()
|
|
|
|
|
|