ronakreddy18 commited on
Commit
66b2688
Β·
verified Β·
1 Parent(s): 8682f40

Update pages/LIFE_CYCLE_OF_MACHINE_LEARNING.py

Browse files
pages/LIFE_CYCLE_OF_MACHINE_LEARNING.py CHANGED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Page navigation state
4
+ if 'page' not in st.session_state:
5
+ st.session_state.page = "home" # Default page is "home"
6
+
7
+ # ----------------- Home Page -----------------
8
+ def home_page():
9
+ st.title(":green[Lifecycle of a Machine Learning Project]")
10
+ st.markdown("Click on a stage to learn more about it.")
11
+
12
+ # Button for Data Collection (Redirects to 'data_collection' page)
13
+ if st.button(":orange[πŸ“Š Data Collection]"):
14
+ st.session_state.page = "data_collection"
15
+
16
+ # Buttons for other stages with brief explanations
17
+ if st.button(":blue[🌟 Problem Statement]"):
18
+ st.markdown("### Problem Statement\nIdentify the problem you want to solve and set clear objectives and success criteria.")
19
+
20
+ if st.button(":blue[πŸ› οΈ Simple EDA]"):
21
+ st.markdown("### Simple EDA\nPerform exploratory data analysis to understand data distributions and relationships.")
22
+
23
+ if st.button(":blue[Data Pre-Processing]"):
24
+ st.markdown("### Data Pre-Processing\nConvert raw data into cleaned data.")
25
+
26
+ if st.button(":blue[πŸ“ˆ Exploratory Data Analysis (EDA)]"):
27
+ st.markdown("### Exploratory Data Analysis (EDA)\nVisualize and analyze the data to understand its distributions and relationships.")
28
+
29
+ if st.button(":blue[πŸ‹οΈ Feature Engineering]"):
30
+ st.markdown("### Feature Engineering\nCreate new features from existing data.")
31
+
32
+ if st.button(":blue[πŸ€– Model Training]"):
33
+ st.markdown("### Model Training\nTrain the model using the training data and optimize its parameters.")
34
+
35
+ if st.button(":blue[πŸ”§ Model Testing]"):
36
+ st.markdown("### Model Testing\nAssess the model's performance using various metrics and cross-validation techniques.")
37
+
38
+ if st.button(":blue[πŸš€ Model Deployment]"):
39
+ st.markdown("### Model Deployment\nIntegrate the trained model into a production environment and monitor its performance.")
40
+
41
+ if st.button(":blue[πŸ“ Monitoring]"):
42
+ st.markdown("### Monitoring\nPeriodically retrain the model with new data and update features as needed.")
43
+
44
+ # ----------------- Data Collection Page -----------------
45
+ def data_collection_page():
46
+ st.title(":red[Data Collection]")
47
+ st.markdown("### Data Collection\nThis page discusses the process of Data Collection.")
48
+ st.markdown("Types of Data: **Structured**, **Unstructured**, **Semi-Structured**")
49
+
50
+ # Button for Structured Data
51
+ if st.button(":blue[🌟 Structured Data]"):
52
+ st.session_state.page = "structured_data"
53
+
54
+ # Button for Unstructured Data
55
+ if st.button(":blue[πŸ“· Unstructured Data]"):
56
+ st.session_state.page = "unstructured_data"
57
+
58
+ # Button for Semi-Structured Data
59
+ if st.button(":blue[πŸ—ƒοΈ Semi-Structured Data]"):
60
+ st.session_state.page = "semi_structured_data"
61
+
62
+ # Back to Home button
63
+ if st.button("Back to Home"):
64
+ st.session_state.page = "home"
65
+
66
+ # ----------------- Structured Data Page -----------------
67
+ def structured_data_page():
68
+ st.title(":blue[Structured Data]")
69
+ st.markdown("""
70
+ Structured data is highly organized and typically stored in tables like spreadsheets or databases. It is easy to search and analyze.
71
+ """)
72
+ st.markdown("### Examples: Excel files, CSV files")
73
+
74
+ # Button for Excel Details
75
+ if st.button(":green[πŸ“Š Excel]"):
76
+ st.session_state.page = "excel"
77
+
78
+ # Back to Data Collection
79
+ if st.button("Back to Data Collection"):
80
+ st.session_state.page = "data_collection"
81
+
82
+ # ----------------- Excel Data Page -----------------
83
+ def excel_page():
84
+ st.title(":green[Excel Data Format]")
85
+
86
+ # 4a. What it is
87
+ st.write("### What is Excel?")
88
+ st.write("Excel is a spreadsheet tool for storing data in tabular format with rows and columns. Common file extensions: `.xls`, `.xlsx`.")
89
+
90
+ # 4b. How to read Excel files
91
+ st.write("### How to Read Excel Files")
92
+ st.code("""
93
+ import pandas as pd
94
+
95
+ # Read an Excel file
96
+ df = pd.read_excel('data.xlsx', sheet_name='Sheet1')
97
+ print(df)
98
+ """, language='python')
99
+
100
+ # 4c. Issues encountered
101
+ st.write("### Issues Encountered")
102
+ st.write("""
103
+ - **File not found**: Incorrect file path.
104
+ - **Sheet name error**: Specified sheet doesn't exist.
105
+ - **Missing libraries**: `openpyxl` or `xlrd` might be missing.
106
+ """)
107
+
108
+ # 4d. Solutions
109
+ st.write("### Solutions to These Issues")
110
+ st.code("""
111
+ # Install required libraries
112
+ # pip install openpyxl xlrd
113
+
114
+ # Handle missing file
115
+ try:
116
+ df = pd.read_excel('data.xlsx', sheet_name='Sheet1')
117
+ except FileNotFoundError:
118
+ print("File not found. Check the file path.")
119
+
120
+ # List available sheet names
121
+ excel_file = pd.ExcelFile('data.xlsx')
122
+ print(excel_file.sheet_names)
123
+ """, language='python')
124
+
125
+ # Download Button for Jupyter Notebook
126
+ with open("excel_handling_guide.ipynb", "rb") as file:
127
+ st.download_button(
128
+ label="Download Jupyter Notebook",
129
+ data=file,
130
+ file_name="excel_handling_guide.ipynb",
131
+ mime="application/octet-stream"
132
+ )
133
+
134
+ # Back to Structured Data
135
+ if st.button("Back to Structured Data"):
136
+ st.session_state.page = "structured_data"
137
+
138
+ # ----------------- Unstructured Data Page -----------------
139
+ def unstructured_data_page():
140
+ st.title(":blue[Unstructured Data]")
141
+ st.markdown("""
142
+ Unstructured data does not have a predefined format. Examples include text documents, images, videos, and audio files.
143
+ """)
144
+
145
+ # Back to Data Collection
146
+ if st.button("Back to Data Collection"):
147
+ st.session_state.page = "data_collection"
148
+
149
+ # ----------------- Semi-Structured Data Page -----------------
150
+ def semi_structured_data_page():
151
+ st.title(":blue[Semi-Structured Data]")
152
+ st.markdown("""
153
+ Semi-structured data has some organizational properties but doesn't fit into strict tables. Examples: JSON, XML files.
154
+ """)
155
+
156
+ # Back to Data Collection
157
+ if st.button("Back to Data Collection"):
158
+ st.session_state.page = "data_collection"
159
+
160
+ # ----------------- Router -----------------
161
+ def router():
162
+ if st.session_state.page == "home":
163
+ home_page()
164
+ elif st.session_state.page == "data_collection":
165
+ data_collection_page()
166
+ elif st.session_state.page == "structured_data":
167
+ structured_data_page()
168
+ elif st.session_state.page == "excel":
169
+ excel_page()
170
+ elif st.session_state.page == "unstructured_data":
171
+ unstructured_data_page()
172
+ elif st.session_state.page == "semi_structured_data":
173
+ semi_structured_data_page()
174
+
175
+ # Run the router function
176
+ if __name__ == "__main__":
177
+ router()
178
+
179
+