bhuvi06 commited on
Commit
47900ee
·
verified ·
1 Parent(s): 456bf27

Upload 4 files

Browse files
Home.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # App Title
4
+ st.set_page_config(page_title="Machine Learning:", layout="wide")
5
+
6
+ st.title("🤖 Welcome to Machine Learning: 🤖")
7
+ st.markdown("""
8
+ **Machine Learning:** is your comprehensive guide to mastering the fascinating world of machine learning, from the basics to advanced concepts.
9
+
10
+ ### What You’ll Discover:
11
+ - **Simplified Concepts**: Learn machine learning in a clear and accessible way.
12
+ - **Hands-On Experience**: Practical examples and case studies for real-world applications.
13
+ - **Latest Trends**: Insights into the future of ML.
14
+ This app is designed for learners, enthusiasts, and professionals alike. Whether you're starting from scratch or expanding your expertise, this is the perfect place to begin your journey into the exciting world of ML.
15
+ ### About Author
16
+ I’m **ch.bhuvaneswari**, an aspiring Data Scientist passionate about uncovering insights from data. I specialize in Machine Learning, Python, SQL, and Exploratory Data Analysis (EDA), aiming to solve real-world problems with data-driven solutions.
17
+
18
+ """)
pages/information.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ st.title("What is Data Science?")
3
+
4
+ st.write("""
5
+ **Data** is simply information. It can be numbers, text, images, or any kind of information that can be collected and analyzed. For example, the number of people who visited a store or the temperature on different days are types of data.
6
+ **Science** is the process of studying the world around us, understanding how things work, and discovering new facts. It involves observation, experimentation, and drawing conclusions based on evidence.
7
+ ### Putting them together:
8
+ **Data Science** is the field where we use data (information) and apply scientific methods (like observation and analysis) to understand patterns, make predictions, and solve problems. It combines collecting, analyzing, and interpreting data to make better decisions.
9
+ """)
10
+ st.title('Machine Learning')
11
+ st.write('''
12
+ **Machine Learning** is a subset of Artificial Intelligence. Machine Learning is a tool which mimics/copy Natural Intelligence with the ability of learning to create an Artificial Intelligence.
13
+ -The machine improves its performance over time based on the patterns it finds in the data.
14
+ - Example:
15
+ \nImagine you want a program to recognize emails as "spam" or "not spam." You provide the program with examples of both types of emails, and it learns from these examples. As it sees more emails, it gets better at predicting whether a new email is spam or not, based on the patterns it learned.
16
+ ''')
pages/life_cycle of_ml.py ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+
4
+ # Set page configuration
5
+ st.set_page_config(page_title="Your Custom ML Lifecycle", layout="centered")
6
+
7
+ # Custom CSS for background color, button alignment, and styling
8
+ st.markdown("""
9
+ <style>
10
+ /* Set full-page background color */
11
+ .main {
12
+ background-color: #f0f8ff; /* Alice Blue */
13
+ }
14
+ /* Center the buttons and style as rounded rectangles */
15
+ .stButton > button {
16
+ display: block;
17
+ margin: 10px auto;
18
+ width: 80%; /* Adjust button width */
19
+ background-color: #588c7e; /* Orange */
20
+ color: white;
21
+ border: none;
22
+ padding: 15px 30px;
23
+ text-align: center;
24
+ font-size: 16px;
25
+ border-radius: 10px; /* Rounded corners */
26
+ cursor: pointer;
27
+ transition-duration: 0.4s;
28
+ }
29
+ /* Add hover effect to buttons */
30
+ .stButton > button:hover {
31
+ background-color: #E64D00; /* Darker orange */
32
+ }
33
+ /* Style headers */
34
+ h1, h2 {
35
+ color: #2c3e50; /* Dark blue-grey */
36
+ text-align: center;
37
+ }
38
+ /* Style for arrows */
39
+ .arrow {
40
+ font-size: 30px;
41
+ text-align: center;
42
+ display: block;
43
+ width: 100%;
44
+ margin-top: 10px;
45
+ margin-bottom: 10px;
46
+ }
47
+ </style>
48
+ """, unsafe_allow_html=True)
49
+
50
+ # Navigation logic using session state
51
+ if "page" not in st.session_state:
52
+ st.session_state.page = "main"
53
+
54
+ def go_to_main_page():
55
+ st.session_state.page = "main"
56
+
57
+ def go_to_data_collection_page():
58
+ st.session_state.page = "data_collection"
59
+
60
+ def go_to_semi_structured_data_page():
61
+ st.session_state.page = "semi_structured_data"
62
+
63
+ def go_to_csv_page():
64
+ st.session_state.page = "csv"
65
+
66
+ # Main Lifecycle Steps Page
67
+ def main_page():
68
+ st.title("Machine Learning Project Lifecycle")
69
+
70
+ steps = [
71
+ "1. Problem Statement",
72
+ "2. Data Collection",
73
+ "3. Simple EDA",
74
+ "4. Data Preprocessing",
75
+ "5. EDA",
76
+ "6. Feature Engineering",
77
+ "7. Training the Model",
78
+ "8. Testing the Model",
79
+ "9. Deployment",
80
+ "10. Monitoring"
81
+ ]
82
+
83
+ descriptions = {
84
+ "1. Problem Statement": "Defines the goal to achieve by the end of the project.",
85
+ "2. Data Collection": "Collect the data based on the problem statement from websites, APIs, web scraping, or manually.",
86
+ "3. Simple EDA": "Simple EDA evaluates data quality by identifying issues like missing values, outliers, and duplicates.",
87
+ "4. Data Preprocessing": "Converts raw data into clean, preprocessed data:",
88
+ "5. EDA": "Exploratory Data Analysis gives a clear understanding of the dataset.",
89
+ "6. Feature Engineering": "Feature engineering improves model performance by creating, transforming, or selecting relevant features.",
90
+ "7. Training the Model": "Train the model on 70% of the data to learn the relationship between input and output features.",
91
+ "8. Testing the Model": "Evaluate the model on 30% of the data to assess its performance.",
92
+ "9. Deployment": "Deploy the model on a web server, app, or platform to make it accessible to users.",
93
+ "10. Monitoring": "Continuously track the model’s performance and retrain it if necessary."
94
+ }
95
+
96
+ for i, step in enumerate(steps):
97
+ if step == "2. Data Collection" and st.button(step, key=f"data_collection_{i}"):
98
+ go_to_data_collection_page()
99
+ elif st.button(step, key=f"step_{i}"):
100
+ st.subheader(step)
101
+ st.write(descriptions[step])
102
+ st.write("---")
103
+
104
+ # Data Collection Page
105
+ def data_collection_page():
106
+ st.header("Data Collection")
107
+ st.write("### What is Data?")
108
+ st.write("Data refers to information that is processed or stored by a computer. This can include text, numbers, images, audio, or video.")
109
+ st.write("### What is Data Collection?")
110
+ st.write("Data Collection is collection of data from various sources based on the Problem statement.")
111
+ st.write("#### Step 1: Problem-Based Approach")
112
+ st.write("Align data collection with the specific problem statement.")
113
+
114
+ st.write("#### Step 2: Data Source Prioritization")
115
+ st.markdown("""
116
+ 1. **Website:** Check for direct availability.
117
+ 2. **APIs:** Use for programmatic access.
118
+ 3. **Web Scraping:** Extract data from websites.
119
+ 4. **Manual Collection:** As a last resort, collect data manually.
120
+ """)
121
+ image_url = "Modern Square Typographic Fashion Brand Logo.png"
122
+ st.image(image_url)
123
+ if st.button(":blue[🌟 Structured Data]"):
124
+ st.session_state.page = "structured_data"
125
+
126
+ if st.button(":blue[📷 Unstructured Data]"):
127
+ st.session_state.page = "unstructured_data"
128
+
129
+ if st.button(":blue[🗃️ Semi-Structured Data]"):
130
+ go_to_semi_structured_data_page()
131
+
132
+ if st.button("Back to Home"):
133
+ st.session_state.page = "home"
134
+ st.button("Back to Main Page", on_click=go_to_main_page)
135
+
136
+ # Semi-Structured Data Page
137
+ def semi_structured_data_page():
138
+ st.title(":blue[Semi-Structured Data]")
139
+ st.markdown("""
140
+ Semi-structured data is not organized in traditional table formats but has some organizational properties.
141
+ Examples include JSON, XML, and CSV files.
142
+ """)
143
+
144
+ if st.button(":orange[CSV File Info]"):
145
+ go_to_csv_page()
146
+
147
+ if st.button("Back to Data Collection"):
148
+ go_to_data_collection_page()
149
+
150
+ ##CSV File Page
151
+ def csv_page():
152
+ st.title(":orange[CSV File Format]")
153
+ st.write("### What is a CSV File?")
154
+ st.write("CSV (Comma-Separated Values) is a plain text format used to represent tabular data, where each line corresponds to a row and each value is separated by a comma.")
155
+
156
+ st.write("### How to Work with CSV Files in Python")
157
+ st.markdown("""
158
+ To read a CSV file in Python:
159
+ ```python
160
+ import pandas as pd
161
+ data = pd.read_csv('file_path.csv')
162
+ ```
163
+
164
+ To write to a CSV file in Python:
165
+ ```python
166
+ data.to_csv('file_path.csv', index=False)
167
+ ```
168
+ """)
169
+
170
+ st.write("### Example Data")
171
+ example_data = {
172
+ "Name": ["Alice", "Bob", "Charlie"],
173
+ "Age": [25, 30, 35],
174
+ "City": ["New York", "Los Angeles", "Chicago"]
175
+ }
176
+ df = pd.DataFrame(example_data)
177
+ st.write("Example DataFrame:")
178
+ st.dataframe(df)
179
+
180
+ st.write("CSV representation:")
181
+ st.code(df.to_csv(index=False), language="csv")
182
+
183
+ if st.button("Back to Semi-Structured Data"):
184
+ go_to_semi_structured_data_page()
185
+
186
+ def go_to_json_page():
187
+ st.session_state.page = "json"
188
+
189
+
190
+ # JSON File Page
191
+ def json_page():
192
+ st.title(":orange[JSON Format]")
193
+ st.write("### What is JSON?")
194
+ st.write("JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write and easy for machines to parse and generate.")
195
+
196
+ st.write("### Example JSON Data")
197
+ st.code("""
198
+ {
199
+ "Name": "Alice",
200
+ "Age": 25,
201
+ "City": "New York"
202
+ }
203
+ """, language="json")
204
+ st.write("### How to Work with JSON in Python")
205
+ st.markdown("""
206
+ To read JSON data in Python:
207
+ ```python
208
+ import pandas as pd
209
+ import json
210
+ # Reading JSON as a dictionary
211
+ with open('file.json', 'r') as file:
212
+ data = json.load(file)
213
+ # Convert JSON to DataFrame
214
+ df = pd.DataFrame(data)
215
+ ```
216
+ To write to a JSON file:
217
+ ```python
218
+ with open('file.json', 'w') as file:
219
+ json.dump(data, file, indent=4)
220
+ ```
221
+ """)
222
+
223
+ st.write("### JSON Example Table")
224
+ example_json = {
225
+ "Name": ["Alice", "Bob", "Charlie"],
226
+ "Age": [25, 30, 35],
227
+ "City": ["New York", "Los Angeles", "Chicago"]
228
+ }
229
+ df_json = pd.DataFrame(example_json)
230
+ st.dataframe(df_json)
231
+
232
+ if st.button("Back to Semi-Structured Data"):
233
+ go_to_semi_structured_data_page()
234
+
235
+ def go_to_xml_page():
236
+ st.session_state.page = "xml"
237
+
238
+
239
+ # XML File Page
240
+ def xml_page():
241
+ st.title(":orange[XML Format]")
242
+ st.write("### What is XML?")
243
+ st.write("XML (eXtensible Markup Language) is a markup language used for storing and transporting data. It is both human-readable and machine-readable.")
244
+
245
+ st.write("### Example XML Data")
246
+ st.code("""
247
+ <root>
248
+ <person>
249
+ <name>Alice</name>
250
+ <age>25</age>
251
+ <city>New York</city>
252
+ </person>
253
+ </root>
254
+ """, language="xml")
255
+
256
+ st.write("### How to Work with XML in Python")
257
+ st.markdown("""
258
+ To read XML data in Python:
259
+ ```python
260
+ import xml.etree.ElementTree as ET
261
+ import pandas as pd
262
+ # Parse XML file
263
+ tree = ET.parse('file.xml')
264
+ root = tree.getroot()
265
+ # Extract data
266
+ data = []
267
+ for person in root.findall('person'):
268
+ data.append({
269
+ 'name': person.find('name').text,
270
+ 'age': int(person.find('age').text),
271
+ 'city': person.find('city').text
272
+ })
273
+ # Convert to DataFrame
274
+ df = pd.DataFrame(data)
275
+ ```
276
+ To write to an XML file, libraries like `xml.etree` or `lxml` can be used to construct nodes and save to a file.
277
+ """)
278
+
279
+ st.write("### XML Example Table")
280
+ example_xml = {
281
+ "Name": ["Alice", "Bob", "Charlie"],
282
+ "Age": [25, 30, 35],
283
+ "City": ["New York", "Los Angeles", "Chicago"]
284
+ }
285
+ df_xml = pd.DataFrame(example_xml)
286
+ st.dataframe(df_xml)
287
+
288
+ if st.button("Back to Semi-Structured Data"):
289
+ go_to_semi_structured_data_page()
290
+
291
+
292
+ def go_to_html_page():
293
+ st.session_state.page = "html"
294
+
295
+ # HTML File Page
296
+ def html_page():
297
+ st.title(":orange[HTML Format]")
298
+ st.write("### What is HTML?")
299
+ st.write("""
300
+ HTML (HyperText Markup Language) is the standard markup language used to create web pages.
301
+ HTML documents structure content with elements like headings, paragraphs, tables, and links.
302
+ """)
303
+
304
+ st.write("### Example HTML Data")
305
+ st.code("""
306
+ <html>
307
+ <body>
308
+ <table>
309
+ <tr>
310
+ <th>Name</th>
311
+ <th>Age</th>
312
+ <th>City</th>
313
+ </tr>
314
+ <tr>
315
+ <td>Alice</td>
316
+ <td>25</td>
317
+ <td>New York</td>
318
+ </tr>
319
+ <tr>
320
+ <td>Bob</td>
321
+ <td>30</td>
322
+ <td>Los Angeles</td>
323
+ </tr>
324
+ </table>
325
+ </body>
326
+ </html>
327
+ """, language="html")
328
+
329
+ st.write("### How to Work with HTML in Python")
330
+ st.markdown("""
331
+ Use libraries like `pandas` or `BeautifulSoup` to extract and process data from HTML files.
332
+ **Example: Reading an HTML Table with Pandas**
333
+ ```python
334
+ import pandas as pd
335
+ # Read HTML table from a file or URL
336
+ df = pd.read_html('file_path_or_url.html')[0]
337
+ print(df)
338
+ ```
339
+ **Example: Extracting Data with BeautifulSoup**
340
+ ```python
341
+ from bs4 import BeautifulSoup
342
+ # Parse HTML file
343
+ with open('file.html', 'r') as file:
344
+ soup = BeautifulSoup(file, 'html.parser')
345
+ # Extract table data
346
+ table = soup.find('table')
347
+ rows = table.find_all('tr')
348
+ data = []
349
+ for row in rows[1:]:
350
+ cols = row.find_all('td')
351
+ data.append([col.text for col in cols])
352
+ # Convert to DataFrame
353
+ import pandas as pd
354
+ df = pd.DataFrame(data, columns=["Name", "Age", "City"])
355
+ print(df)
356
+ ```
357
+ """)
358
+
359
+ st.write("### HTML Example Table")
360
+ example_html = {
361
+ "Name": ["Alice", "Bob", "Charlie"],
362
+ "Age": [25, 30, 35],
363
+ "City": ["New York", "Los Angeles", "Chicago"]
364
+ }
365
+ df_html = pd.DataFrame(example_html)
366
+ st.dataframe(df_html)
367
+
368
+ if st.button("Back to Semi-Structured Data"):
369
+ go_to_semi_structured_data_page()
370
+
371
+ # Update Semi-Structured Data Page Navigation
372
+ def semi_structured_data_page():
373
+ st.title(":blue[Semi-Structured Data]")
374
+ st.markdown("""
375
+ Semi-structured data is not organized in traditional table formats but has some organizational properties.
376
+ Examples include JSON, XML, HTML, and CSV files.
377
+ """)
378
+
379
+ if st.button(":orange[CSV File Info]"):
380
+ go_to_csv_page()
381
+
382
+ if st.button(":orange[JSON Info]"):
383
+ go_to_json_page()
384
+
385
+ if st.button(":orange[XML Info]"):
386
+ go_to_xml_page()
387
+
388
+ if st.button(":orange[HTML Info]"):
389
+ go_to_html_page()
390
+
391
+ if st.button("Back to Data Collection"):
392
+ go_to_data_collection_page()
393
+
394
+ # Page Routing Update
395
+ if st.session_state.page == "main":
396
+ main_page()
397
+ elif st.session_state.page == "data_collection":
398
+ data_collection_page()
399
+ elif st.session_state.page == "semi_structured_data":
400
+ semi_structured_data_page()
401
+ elif st.session_state.page == "csv":
402
+ csv_page()
403
+ elif st.session_state.page == "json":
404
+ json_page()
405
+ elif st.session_state.page == "xml":
406
+ xml_page()
407
+ elif st.session_state.page == "html":
408
+ html_page()
pages/machinelearning.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+
4
+ # Title
5
+ st.title(" Machine Learning")
6
+ st.write("ML are used to mimic or copy the learning ability of biological neurons.")
7
+
8
+ # Data for the table
9
+ data = {
10
+ "Criteria": [
11
+ "Learning Approach",
12
+ "Data Requirements",
13
+ "Data Type",
14
+ "Memory Usage",
15
+ "Training Time",
16
+ "Computational Requirements"
17
+ ],
18
+ "Machine Learning (ML)": [
19
+ "Uses statistical concepts to mimic learning abilities.",
20
+ "Requires less data to train but performance may saturate with small data.",
21
+ "Works on structured data; unstructured data needs conversion, causing data loss.",
22
+ "Low memory usage.",
23
+ "Takes less time to train.",
24
+ "Can work on a low-end computer/PC."
25
+ ],}
26
+ # Create a DataFrame
27
+ df = pd.DataFrame(data)
28
+ st.table(df)