Harika22 commited on
Commit
f520b3d
·
verified ·
1 Parent(s): 220bfcf

Update pages/3_Life cycle of ML.py

Browse files
Files changed (1) hide show
  1. pages/3_Life cycle of ML.py +56 -137
pages/3_Life cycle of ML.py CHANGED
@@ -1,147 +1,66 @@
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
-
80
- def main_page():
81
- st.markdown("<h1>Machine Learning Lifecycle</h1>", unsafe_allow_html=True)
82
- st.markdown(ml_lifecycle_html, unsafe_allow_html=True)
83
 
84
- def data_collection_page():
85
- st.title("Data Collection")
86
- st.write("""
87
- ### What is Data?
88
- Data refers to raw facts and figures that can be processed for generating insights. It can be categorized as:
89
- - **Structured Data**
90
- - **Semi-Structured Data**
91
- - **Unstructured Data**
92
- """)
93
 
94
- # Buttons for different types of data
95
- if st.button("Structured Data"):
96
- st.session_state.data_type = "structured"
97
- elif st.button("Semi-Structured Data"):
98
- st.session_state.data_type = "semi_structured"
99
- elif st.button("Unstructured Data"):
100
- st.session_state.data_type = "unstructured"
101
 
102
- if "data_type" in st.session_state:
103
- if st.session_state.data_type == "structured":
104
- st.subheader("Structured Data")
105
- if st.button("Excel"):
106
- st.write("""
107
- ### Excel
108
- - **What is it?** Spreadsheet software for storing tabular data.
109
- - **How to read?** Use Python libraries like `pandas`:
110
- ```python
111
- import pandas as pd
112
- df = pd.read_excel("file.xlsx")
113
- ```
114
- - **Common Issues:**
115
- - Large file sizes causing memory errors.
116
- - Formatting errors.
117
- - **Solutions:**
118
- - Use lightweight libraries like `openpyxl`.
119
- - Pre-clean the data before analysis.
120
- """)
121
- elif st.button("CSV"):
122
- st.write("""
123
- ### CSV
124
- - **What is it?** Comma-separated values for tabular data.
125
- - **How to read?**
126
- ```python
127
- import pandas as pd
128
- df = pd.read_csv("file.csv")
129
- ```
130
- - **Common Issues:**
131
- - Delimiter inconsistencies.
132
- - Missing values.
133
- - **Solutions:**
134
- - Specify the `delimiter` parameter.
135
- - Use methods like `fillna` to handle missing values.
136
- """)
137
 
138
- if st.button("Back to Main Page"):
139
- st.query_params(page="main")
140
 
141
- # Page routing
142
- if current_page == "data_collection":
143
- data_collection_page()
144
- else:
145
- main_page()
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
 
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": "The first step is to define the problem clearly. It involves identifying the objective of the machine learning model, whether it's classification, regression, or another type of problem.",
7
+ "Data Collection": "Data is collected from various sources like APIs, databases, or web scraping. It's crucial to have enough data for the model to learn effectively.",
8
+ "Simple EDA": "At this stage, we do a simple Exploratory Data Analysis (EDA) to understand the data better, identify patterns, and detect anomalies or missing values.",
9
+ "Data Pre-Processing": "This step includes cleaning the data: handling missing values, encoding categorical variables, normalizing numerical features, and splitting the data into training and testing sets.",
10
+ "EDA": "A deeper EDA helps to identify relationships between features, correlation, and insights that guide feature engineering and model selection.",
11
+ "Feature Engineering": "In this step, you create new features or modify existing features to improve the model's performance. Techniques like scaling, encoding, or creating polynomial features are common.",
12
+ "Model Training": "You select an appropriate algorithm and train the model using the training dataset. Common algorithms include decision trees, linear regression, or neural networks.",
13
+ "Testing": "After training the model, you test it using unseen data to assess its performance using evaluation metrics like accuracy, precision, recall, or mean squared error.",
14
+ "Deployment and Maintenance": "Once the model is deployed, it’s integrated into an application or system, and continuous monitoring is required to ensure it performs well and is updated as needed."
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
+ # Displaying the lifecycle steps as buttons
30
+ selected_step = st.sidebar.radio(
31
+ "Choose a step in the ML lifecycle:",
32
+ steps_list,
33
+ index=0 # Default selected step
34
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ # Main content area displaying the corresponding step details
37
+ st.title("Machine Learning Lifecycle")
38
 
39
+ # Show corresponding step details when a button is selected
40
+ display_lifecycle_step(selected_step)
 
 
 
41
 
42
+ # Add custom styling to make it look like a circular structure
43
+ st.markdown("""
44
+ <style>
45
+ .stApp {
46
+ background-color: #f0f0f5;
47
+ font-family: 'Arial', sans-serif;
48
+ }
49
+ .stSidebar .sidebar-content {
50
+ background-color: #e3e4e8;
51
+ border-radius: 10px;
52
+ padding: 10px;
53
+ }
54
+ .stButton > button {
55
+ background-color: #008CBA;
56
+ color: white;
57
+ border-radius: 50px;
58
+ font-size: 18px;
59
+ padding: 12px 24px;
60
+ }
61
+ .stButton > button:hover {
62
+ background-color: #007B8C;
63
+ }
64
+ </style>
65
+ """, unsafe_allow_html=True)
66