Harika22 commited on
Commit
0100f3d
·
verified ·
1 Parent(s): a8eb239

Update pages/3_Life cycle of ML.py

Browse files
Files changed (1) hide show
  1. pages/3_Life cycle of ML.py +190 -168
pages/3_Life cycle of ML.py CHANGED
@@ -1,185 +1,207 @@
1
  import streamlit as st
2
-
3
- # Function for displaying lifecycle steps with details
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
  import webbrowser
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  def data_collection_page():
66
- st.write("### What is Data?")
 
67
  st.write("""
68
- Data is a collection of facts, numbers, words, or observations that can be used to learn about something.
69
- It can be raw and unprocessed
70
- It can be structured or unstructured and comes from various sources.
71
- """)
72
 
73
- st.write("### Types of Data")
74
- st.write("""
75
- 1. **Structured Data**: Organized data that follows a schema (e.g., rows and columns, sql).
76
- 2. **Unstructured Data**: Data that doesn't follow a predefined model (e.g., images, text, audio and video).
77
- 3. **Semi-Structured Data**: Data that has some organizational properties but isn't fully structured (e.g., JSON, XML, CSV,HTML).
78
  """)
79
-
80
- selected_data_type = st.radio("Choose Data Type", ["Structured Data", "Unstructured Data", "Semi-Structured Data"])
81
-
82
- if selected_data_type == "Structured Data":
83
- display_structured_data_info()
84
-
85
- def display_structured_data_info():
86
- st.write("### Structured Data")
87
- st.write("Structured data is data that is highly organized and stored in a fixed format, like tables, rows, and columns.")
88
 
89
- # Button for each structured data format (Excel, CSV, XML)
90
- data_formats = st.radio("Choose a Data Format", ["Excel", "CSV", "XML"])
 
 
91
 
92
- if data_formats == "Excel":
93
- display_excel_info()
94
- elif data_formats == "CSV":
95
- display_csv_info()
96
- elif data_formats == "XML":
97
- display_xml_info()
98
-
99
- # Function to display Excel-related information
100
- def display_excel_info():
101
- st.write("### Excel Format")
 
 
 
 
102
  st.write("""
103
- **What it is**: Excel is a popular spreadsheet format commonly used for storing and analyzing structured data.
104
-
105
- **How to read these files**:
106
- - Use `pandas.read_excel()` to read Excel files in Python.
107
-
108
- **Issues encountered when handling Excel files**:
109
- - Large files can cause memory issues.
110
- - Compatibility problems with different Excel versions.
111
-
112
- **How to overcome these errors**:
113
- - Break large files into smaller chunks.
114
- - Use libraries like `openpyxl` for handling newer Excel files and `xlrd` for older ones.
115
  """)
116
-
117
- # Button to open the Jupyter Notebook or PDF with coding examples
118
- if st.button("Open Excel Code Example"):
119
- open_code_example("excel")
120
-
121
- # Function to display CSV-related information
122
- def display_csv_info():
123
- st.write("### CSV Format")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  st.write("""
125
- **What it is**: CSV (Comma Separated Values) is a text format for representing tabular data, where values are separated by commas.
126
-
127
- **How to read these files**:
128
- - Use `pandas.read_csv()` to read CSV files in Python.
129
-
130
- **Issues encountered when handling CSV files**:
131
- - Improper handling of special characters or delimiters.
132
- - Missing or inconsistent data.
133
-
134
- **How to overcome these errors**:
135
- - Specify delimiters using the `delimiter` parameter.
136
- - Handle missing data by using `fillna()` or `dropna()` methods in pandas.
137
  """)
138
-
139
- # Button to open the Jupyter Notebook or PDF with coding examples
140
- if st.button("Open CSV Code Example"):
141
- open_code_example("csv")
142
-
143
- # Function to display XML-related information
144
- def display_xml_info():
145
- st.write("### XML Format")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  st.write("""
147
- **What it is**: XML (Extensible Markup Language) is a flexible and structured format used to store data in a hierarchical manner.
148
-
149
- **How to read these files**:
150
- - Use `pandas.read_xml()` to read XML files or `xml.etree.ElementTree` for more complex parsing.
151
-
152
- **Issues encountered when handling XML files**:
153
- - Complex nested structures can be hard to parse.
154
- - Compatibility issues between different XML schemas.
155
-
156
- **How to overcome these errors**:
157
- - Use XPath or `lxml` for more advanced parsing.
158
- - Handle encoding issues using the `encoding` parameter while reading the file.
159
  """)
 
160
 
161
- # Button to open the Jupyter Notebook or PDF with coding examples
162
- if st.button("Open XML Code Example"):
163
- open_code_example("xml")
164
-
165
- # Function to open a Jupyter Notebook or PDF for coding examples
166
- def open_code_example(data_format):
167
- # Placeholder: Open a PDF/Jupyter notebook link for the data format
168
- example_links = {
169
- "excel": "https://yourlinktoexcelcode.com",
170
- "csv": "https://yourlinktocsvcode.com",
171
- "xml": "https://yourlinktoxmlcode.com",
172
- }
173
-
174
- link = example_links.get(data_format)
175
- if link:
176
- webbrowser.open_new_tab(link)
177
-
178
- def main():
179
- st.sidebar.title("ML Life Cycle Navigation")
180
-
181
- if st.sidebar.button("Data Collection"):
182
- data_collection_page()
183
 
184
- if __name__ == "__main__":
185
- main()
 
 
 
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import webbrowser
3
 
4
+ # Custom CSS for styling
5
+ custom_css = """
6
+ <style>
7
+ html, body, [data-testid="stAppViewContainer"] {
8
+ background: linear-gradient(
9
+ rgba(255, 182, 193, 0.8), /* Soft Pink */
10
+ rgba(230, 230, 255, 0.8) /* Lavender */
11
+ ),
12
+ url('https://i.imgur.com/vIszbgs.jpeg') no-repeat center center fixed;
13
+ background-size: cover; /* Cover the entire screen */
14
+ font-family: 'Arial', sans-serif;
15
+ color: #333333; /* Set text color to dark grey for better readability */
16
+ }
17
+ h1 {
18
+ color:#2c3e50;
19
+ text-align: center;
20
+ font-size: 3rem; /* Increase font size for the main title */
21
+ margin-top: 20px;
22
+ text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.8); /* Add shadow for better visibility */
23
+ }
24
+ .circle-container {
25
+ display: flex;
26
+ justify-content: center;
27
+ align-items: center;
28
+ position: relative;
29
+ width: 500px;
30
+ height: 500px;
31
+ margin: 50px;
32
+ background: transparent;
33
+ transform: translate(-50px, -50px); /* Move the container 50px to the left */
34
+ }
35
+ .circle-container .button {
36
+ position: absolute;
37
+ width: 120px;
38
+ height: 120px;
39
+ background: #1e1e2f;
40
+ color: white;
41
+ border: 2px solid #555;
42
+ border-radius: 50%;
43
+ display: flex;
44
+ justify-content: center;
45
+ align-items: center;
46
+ font-size: 1rem;
47
+ text-align: center;
48
+ text-decoration: none;
49
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
50
+ cursor: pointer;
51
+ transition: background 0.3s, box-shadow 0.3s;
52
+ }
53
+ .circle-container .button:hover {
54
+ background: #333; /* Change background color */
55
+ box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3); /* Add shadow on hover */
56
+ }
57
+ /* Positioning buttons in a circular layout */
58
+ .button:nth-child(1) { transform: rotate(0deg) translate(200px) rotate(0deg); }
59
+ .button:nth-child(2) { transform: rotate(36deg) translate(200px) rotate(-36deg); }
60
+ .button:nth-child(3) { transform: rotate(72deg) translate(200px) rotate(-72deg); }
61
+ .button:nth-child(4) { transform: rotate(108deg) translate(200px) rotate(-108deg); }
62
+ .button:nth-child(5) { transform: rotate(144deg) translate(200px) rotate(-144deg); }
63
+ .button:nth-child(6) { transform: rotate(180deg) translate(200px) rotate(-180deg); }
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.markdown(custom_css, unsafe_allow_html=True)
109
+ st.title("Data Collection")
110
  st.write("""
111
+ ### What is Data?
112
+ Data is a collection of facts, numbers, words, or observations used to gain insights. It can be raw or processed, depending on the context.
 
 
113
 
114
+ **Types of Data:**
115
+ - **Structured Data**: Highly organized in a tabular format (e.g., SQL databases).
116
+ - **Semi-Structured Data**: Contains some structure (e.g., JSON, XML).
117
+ - **Unstructured Data**: No predefined structure (e.g., text, images).
 
118
  """)
 
 
 
 
 
 
 
 
 
119
 
120
+ # Button choices for data types
121
+ structured_data = st.button('Structured Data')
122
+ semi_structured_data = st.button('Semi-Structured Data')
123
+ unstructured_data = st.button('Unstructured Data')
124
 
125
+ # Handling button clicks and displaying relevant info
126
+ if structured_data:
127
+ st.session_state.data_type = 'structured'
128
+ show_structured_data()
129
+ elif semi_structured_data:
130
+ st.session_state.data_type = 'semi_structured'
131
+ show_semi_structured_data()
132
+ elif unstructured_data:
133
+ st.session_state.data_type = 'unstructured'
134
+ show_unstructured_data()
135
+
136
+ # Structured Data details
137
+ def show_structured_data():
138
+ st.subheader("Structured Data")
139
  st.write("""
140
+ Structured data follows a well-defined format, often stored in relational databases or CSV files.
141
+ It can be efficiently processed and analyzed using software tools.
 
 
 
 
 
 
 
 
 
 
142
  """)
143
+ excel_button = st.button("Learn About Excel Files")
144
+ if excel_button:
145
+ st.write("""
146
+ ### Excel Files
147
+ **What is Excel?** Excel is a spreadsheet software for organizing, analyzing, and storing data.
148
+
149
+ **How to Read Excel Files:**
150
+ ```python
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
+ Semi-structured data is not fully organized but contains some structure, like XML or JSON files. These formats are often used for web data or APIs.
 
 
 
 
 
 
 
 
 
 
 
170
  """)
171
+ csv_button = st.button("Learn About CSV Files")
172
+ if csv_button:
173
+ st.write("""
174
+ ### CSV Files
175
+ **What is CSV?** CSV (Comma Separated Values) is a simple text format for storing tabular data.
176
+
177
+ **How to Read CSV Files:**
178
+ ```python
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
+ Unstructured data doesn't fit neatly into tables or files. It includes images, videos, and text, which require special techniques to process.
 
 
 
 
 
 
 
 
 
 
 
197
  """)
198
+ st.write("This requires advanced models like CNN for images or NLP for text data.")
199
 
200
+ # Render the page based on query parameters
201
+ params = st.query_params
202
+ page = params.get("page", ["main", "data_collection"])[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
 
204
+ if page == "data_collection":
205
+ data_collection_page()
206
+ else:
207
+ main_page()