Harika22 commited on
Commit
ae61fe8
·
verified ·
1 Parent(s): 1db1ee8

Update pages/3_Life cycle of ML.py

Browse files
Files changed (1) hide show
  1. pages/3_Life cycle of ML.py +120 -181
pages/3_Life cycle of ML.py CHANGED
@@ -1,211 +1,150 @@
1
  import streamlit as st
2
- import pandas as pd
3
- from graphviz import Digraph
4
 
5
  custom_css = """
6
  <style>
7
  html, body, [data-testid="stAppViewContainer"] {
8
- background: linear-gradient(to right, #f8fbff, #eef2f3);
9
- font-family: 'Arial', sans-serif;
10
  color: #333;
11
  }
12
  h1 {
13
- color: #34495e;
14
  text-align: center;
15
- font-size: 2.8rem;
16
- margin-top: 20px;
17
- text-shadow: 1px 1px 3px rgba(200, 200, 255, 0.8);
18
  }
19
- .stButton button {
20
- background-color: #4CAF50;
21
- border: none;
 
 
 
 
 
 
 
 
 
 
 
 
22
  color: white;
23
- padding: 12px 24px;
 
 
 
 
 
24
  text-align: center;
25
- font-size: 16px;
26
- border-radius: 8px;
27
  cursor: pointer;
28
- transition: background-color 0.3s ease, transform 0.3s ease;
 
29
  }
30
- .stButton button:hover {
31
- background-color: #45a049;
32
- transform: scale(1.05);
33
  }
34
- .stMarkdown {
 
 
 
 
 
 
35
  text-align: center;
36
- margin-top: 10px;
37
  }
38
  </style>
39
  """
40
 
41
  st.markdown(custom_css, unsafe_allow_html=True)
42
 
43
- st.markdown("<h1>🚀 Lifecycle of an ML Project</h1>", unsafe_allow_html=True)
44
-
45
- st.markdown("<p style='text-align:center;'>Explore each phase of the ML lifecycle by clicking on the buttons below</p>", unsafe_allow_html=True)
46
-
47
- steps = [
48
- "Problem Statement",
49
- "Data Collection",
50
- "Simple EDA",
51
- "Data Pre-Processing",
52
- "EDA",
53
- "Feature Engineering",
54
- "Model Training",
55
- "Testing",
56
- "Deployment and Maintenance"
57
- ]
58
-
59
- descriptions = {
60
- "Problem Statement": "Objective of the project.",
61
- "Data Collection": "Collecting data from various sources.",
62
- "Simple EDA": "Describing the quality of the data.",
63
- "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",
64
- "EDA": "Transforming insights into a clean dataset and providing proper visualizations.",
65
- "Feature Engineering": "Creating and analyzing features and labels.",
66
- "Model Training": "Training the machine about relationships between features and labels.",
67
- "Testing": "Testing how efficiently the machine learned.",
68
- "Deployment and Maintenance": "Deploying the machine to the client and ensuring maintenance for accurate results."
69
- }
70
-
71
-
72
- graph = Digraph(engine="neato", format="svg")
73
- graph.attr(splines="true", nodesep="0.8", ranksep="1.2", rankdir="LR")
74
- graph.attr("node", shape="ellipse", style="filled", color="#b3cde0", fontname="Arial", fontsize="12")
75
-
76
-
77
- for i, step in enumerate(steps):
78
- graph.node(str(i), step)
79
- if i < len(steps) - 1:
80
- graph.edge(str(i), str(i+1), color="#34495e", penwidth="2", arrowhead="vee", arrowsize="1.2")
81
-
82
- st.graphviz_chart(graph)
83
-
84
- st.markdown("<hr>", unsafe_allow_html=True)
85
-
86
- selected_step = None
87
- for step in steps:
88
- if st.button(step):
89
- selected_step = step
90
- break
91
-
92
- if selected_step:
93
- st.markdown(f"<h2>{selected_step}</h2>", unsafe_allow_html=True)
94
- st.markdown(f"<p style='font-size:1.1rem; text-align:center;'>{descriptions[selected_step]}</p>", unsafe_allow_html=True)
95
-
96
- st.markdown("<hr>", unsafe_allow_html=True)
97
-
98
- elif st.session_state["current_page"] == "Data Collection":
99
- st.title(":bar_chart: Data Collection")
100
- st.write("### Overview")
101
- st.write(
102
- "Data gathering is the process of collecting relevant data to solve a specific problem or achieve an objective."
103
- )
104
- st.markdown("""
105
- #### Types of Data:
106
- - **🟢 Structured Data**: Organized data with a predefined schema, such as databases, Excel sheets.
107
- - **🟠 Semi-Structured Data**: Data that doesn't conform strictly to a schema but has organizational tags, like JSON or XML.
108
- - **🔴 Unstructured Data**: Unorganized data such as images, audio, and videos without a specific format.
109
- """)
110
 
111
- col1, col2, col3 = st.columns(3)
112
- with col1:
113
- if st.button("Structured Data"):
114
- navigate_to("Structured Data")
115
- with col2:
116
- if st.button("Semi-Structured Data"):
117
- navigate_to("Semi-Structured Data")
118
- with col3:
119
- if st.button("Unstructured Data"):
120
- navigate_to("Unstructured Data")
121
 
122
- # Back to Main button
123
- if st.button("Back to Main"):
124
- navigate_to("Main")
125
 
126
- elif st.session_state["current_page"] == "Structured Data":
127
- st.title("🟢 Structured Data")
128
- st.markdown("**Structured data** is highly organized and stored in a fixed format, making it easily searchable.")
129
- st.markdown("### Examples of Structured Data")
130
- st.markdown("""
131
- - **Relational Databases**: Tables with rows and columns.
132
- - **Spreadsheets**: Data stored in Excel format.
133
- - **SQL Databases**: Structured query language (SQL) is used to manage and manipulate relational databases.
134
- """)
135
-
136
- st.markdown("### What is SQL?")
137
  st.write("""
138
- **SQL (Structured Query Language)** is a standardized programming language used to manage and manipulate relational databases.
139
- It is the most widely used language for managing structured data, particularly in systems where data is stored in rows and columns.
140
- """)
141
-
142
- st.markdown("### Key Features of SQL:")
143
- st.markdown("""
144
- - **Data Querying**: Retrieve data from relational databases using the SELECT statement.
145
- - **Data Manipulation**: Insert, update, and delete data in tables with the INSERT, UPDATE, and DELETE commands.
146
- - **Data Definition**: Define and modify the structure of database tables (e.g., CREATE, ALTER).
147
- - **Data Control**: Manage permissions and access to the database (e.g., GRANT, REVOKE).
148
  """)
149
 
150
- # Adding button for Excel and SQL data formats under Structured Data
151
- col1, col2 = st.columns(2)
152
- with col1:
153
- if st.button("Excel"):
154
- navigate_to("Excel Data Format")
155
- with col2:
156
- if st.button("SQL"):
157
- navigate_to("SQL Data Format")
158
-
159
- # Back to Types of Data button
160
- if st.button("Back to Types of Data"):
161
- navigate_to("Data Gathering")
162
-
163
- elif st.session_state["current_page"] == "Semi-Structured Data":
164
- st.title("🟠 Semi-Structured Data")
165
- st.write(
166
- "Semi-structured data is partially organized and contains tags or markers to separate elements, but it does not adhere to a strict schema."
167
- )
168
- st.markdown("### Common Formats")
169
- st.markdown("""
170
- - **JSON**: Widely used for web APIs.
171
- - **XML**: Common for document-based data.
172
- - **CSV**: Commonly used for data storage with commas separating values (often used with JSON/XML for data interchange).
173
- """)
174
-
175
- # Adding buttons for JSON, XML, and CSV data formats under Semi-Structured Data
176
- col1, col2, col3 = st.columns(3)
177
- with col1:
178
- if st.button("JSON"):
179
- navigate_to("JSON Data Format")
180
- with col2:
181
- if st.button("XML"):
182
- navigate_to("XML Data Format")
183
- with col3:
184
- if st.button("CSV"):
185
- navigate_to("CSV Data Format")
186
-
187
- # Back to Types of Data button
188
- if st.button("Back to Types of Data"):
189
- navigate_to("Data Gathering")
190
-
191
- elif st.session_state["current_page"] == "SQL Data Format":
192
- st.title(":file_folder: SQL Data Format")
193
- st.write("**SQL (Structured Query Language)** is used to query, update, and manage relational databases.")
194
- st.markdown("### Common SQL Databases")
195
- st.markdown("""
196
- - **MySQL**: Open-source relational database management system.
197
- - **PostgreSQL**: Advanced open-source relational database system.
198
- - **SQLite**: Lightweight, file-based SQL database.
199
- """)
 
 
200
 
201
- st.markdown("### Example SQL Query")
202
- st.code(
203
- """sql
204
- SELECT * FROM customers WHERE age > 30;
205
- """,
206
- language="sql",
207
- )
208
 
209
- # Back to Structured Data button
210
- if st.button("Back to Structured Data"):
211
- navigate_to("Structured Data")
 
1
  import streamlit as st
 
 
2
 
3
  custom_css = """
4
  <style>
5
  html, body, [data-testid="stAppViewContainer"] {
6
+ font-family: Arial, sans-serif;
7
+ background: linear-gradient(to right, #ffefba, #ffffff); /* Warm gradient */
8
  color: #333;
9
  }
10
  h1 {
11
+ color: #4CAF50; /* Green */
12
  text-align: center;
13
+ font-size: 3rem;
14
+ text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
 
15
  }
16
+ .circle-container {
17
+ display: flex;
18
+ justify-content: center;
19
+ align-items: center;
20
+ position: relative;
21
+ width: 500px;
22
+ height: 500px;
23
+ margin: 50px auto;
24
+ background: transparent;
25
+ }
26
+ .circle-container .button {
27
+ position: absolute;
28
+ width: 120px;
29
+ height: 120px;
30
+ background: #8A2BE2; /* Blue-violet */
31
  color: white;
32
+ border: none;
33
+ border-radius: 50%;
34
+ display: flex;
35
+ justify-content: center;
36
+ align-items: center;
37
+ font-size: 1rem;
38
  text-align: center;
39
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
 
40
  cursor: pointer;
41
+ transition: transform 0.3s, box-shadow 0.3s;
42
+ text-decoration: none;
43
  }
44
+ .circle-container .button:hover {
45
+ transform: scale(1.1);
46
+ box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
47
  }
48
+ .center {
49
+ position: absolute;
50
+ top: 50%;
51
+ left: 50%;
52
+ transform: translate(-50%, -50%);
53
+ font-size: 1.5rem;
54
+ color: #4CAF50; /* Green */
55
  text-align: center;
 
56
  }
57
  </style>
58
  """
59
 
60
  st.markdown(custom_css, unsafe_allow_html=True)
61
 
62
+ # Define HTML content for ML lifecycle
63
+ ml_lifecycle_html = """
64
+ <div class="circle-container">
65
+ <a href="?page=problem_statement" class="button">Problem Statement</a>
66
+ <a href="?page=data_collection" class="button">Data Collection</a>
67
+ <a href="#" class="button">Simple EDA</a>
68
+ <a href="#" class="button">Pre-Processing</a>
69
+ <a href="#" class="button">EDA</a>
70
+ <a href="#" class="button">Feature Engineering</a>
71
+ <a href="#" class="button">Model Training</a>
72
+ <a href="#" class="button">Testing</a>
73
+ <a href="#" class="button">Deployment</a>
74
+ <a href="#" class="button">Monitoring</a>
75
+ <div class="center"><strong>ML Lifecycle</strong></div>
76
+ </div>
77
+ """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
+ # Define pages
80
+ params = st.experimental_get_query_params()
81
+ current_page = params.get("page", ["main"])[0]
 
 
 
 
 
 
 
82
 
83
+ def main_page():
84
+ st.markdown("<h1>Machine Learning Lifecycle</h1>", unsafe_allow_html=True)
85
+ st.markdown(ml_lifecycle_html, unsafe_allow_html=True)
86
 
87
+ def data_collection_page():
88
+ st.title("Data Collection")
 
 
 
 
 
 
 
 
 
89
  st.write("""
90
+ ### What is Data?
91
+ Data refers to raw facts and figures that can be processed for generating insights. It can be categorized as:
92
+ - **Structured Data**
93
+ - **Semi-Structured Data**
94
+ - **Unstructured Data**
 
 
 
 
 
95
  """)
96
 
97
+ # Buttons for different types of data
98
+ if st.button("Structured Data"):
99
+ st.session_state.data_type = "structured"
100
+ elif st.button("Semi-Structured Data"):
101
+ st.session_state.data_type = "semi_structured"
102
+ elif st.button("Unstructured Data"):
103
+ st.session_state.data_type = "unstructured"
104
+
105
+ if "data_type" in st.session_state:
106
+ if st.session_state.data_type == "structured":
107
+ st.subheader("Structured Data")
108
+ if st.button("Excel"):
109
+ st.write("""
110
+ ### Excel
111
+ - **What is it?** Spreadsheet software for storing tabular data.
112
+ - **How to read?** Use Python libraries like `pandas`:
113
+ ```python
114
+ import pandas as pd
115
+ df = pd.read_excel("file.xlsx")
116
+ ```
117
+ - **Common Issues:**
118
+ - Large file sizes causing memory errors.
119
+ - Formatting errors.
120
+ - **Solutions:**
121
+ - Use lightweight libraries like `openpyxl`.
122
+ - Pre-clean the data before analysis.
123
+ """)
124
+ elif st.button("CSV"):
125
+ st.write("""
126
+ ### CSV
127
+ - **What is it?** Comma-separated values for tabular data.
128
+ - **How to read?**
129
+ ```python
130
+ import pandas as pd
131
+ df = pd.read_csv("file.csv")
132
+ ```
133
+ - **Common Issues:**
134
+ - Delimiter inconsistencies.
135
+ - Missing values.
136
+ - **Solutions:**
137
+ - Specify the `delimiter` parameter.
138
+ - Use methods like `fillna` to handle missing values.
139
+ """)
140
+
141
+ if st.button("Back to Main Page"):
142
+ st.experimental_set_query_params(page="main")
143
+
144
+ # Page routing
145
+ if current_page == "data_collection":
146
+ data_collection_page()
147
+ else:
148
+ main_page()
149
 
 
 
 
 
 
 
 
150