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

Update pages/3_Life cycle of ML.py

Browse files
Files changed (1) hide show
  1. 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
- # 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()
 
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()