Update pages/3_Life Cycle Of ML Project.py
Browse files
pages/3_Life Cycle Of ML Project.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import json
|
| 3 |
import xml.etree.ElementTree as ET
|
|
|
|
| 4 |
|
| 5 |
# Initialize page navigation state
|
| 6 |
if 'page' not in st.session_state:
|
|
@@ -215,30 +216,12 @@ while video.isOpened():
|
|
| 215 |
if not ret:
|
| 216 |
break
|
| 217 |
cv2.imshow('Frame', frame)
|
| 218 |
-
if cv2.waitKey(
|
| 219 |
break
|
| 220 |
video.release()
|
| 221 |
cv2.destroyAllWindows()
|
| 222 |
""", language='python')
|
| 223 |
|
| 224 |
-
st.header("π Handling Audio Data")
|
| 225 |
-
st.markdown("""
|
| 226 |
-
Audio data can be handled using libraries like librosa.
|
| 227 |
-
""")
|
| 228 |
-
st.code("""
|
| 229 |
-
import librosa
|
| 230 |
-
# Load an audio file
|
| 231 |
-
y, sr = librosa.load('sample_audio.wav')
|
| 232 |
-
# Display waveform
|
| 233 |
-
import matplotlib.pyplot as plt
|
| 234 |
-
plt.figure(figsize=(10, 4))
|
| 235 |
-
plt.plot(y)
|
| 236 |
-
plt.title("Audio Waveform")
|
| 237 |
-
plt.show()
|
| 238 |
-
""", language='python')
|
| 239 |
-
|
| 240 |
-
st.link_button(":blue[Open Jupyter Notebook](https://colab.research.google.com/drive/1sT35x4JH9s_hb31aMoUwtry-w8FE7fQg?usp=sharing)")
|
| 241 |
-
|
| 242 |
if st.button(":red[Back to Data Collection]"):
|
| 243 |
st.session_state.page = "data_collection"
|
| 244 |
|
|
@@ -246,129 +229,83 @@ plt.show()
|
|
| 246 |
elif st.session_state.page == "semi_structured_data":
|
| 247 |
st.title(":blue[Semi-Structured Data]")
|
| 248 |
st.markdown("""
|
| 249 |
-
Semi-structured data
|
| 250 |
-
Examples:
|
| 251 |
-
- XML files
|
| 252 |
-
- JSON files
|
| 253 |
-
- HTML documents
|
| 254 |
""")
|
| 255 |
|
| 256 |
-
if st.button(":blue[
|
| 257 |
st.session_state.page = "xml"
|
| 258 |
|
| 259 |
-
if st.button(":blue[
|
| 260 |
st.session_state.page = "json"
|
| 261 |
|
| 262 |
-
if st.button(":blue[π HTML]"):
|
| 263 |
-
st.session_state.page = "html"
|
| 264 |
-
|
| 265 |
if st.button(":red[Back to Data Collection]"):
|
| 266 |
st.session_state.page = "data_collection"
|
| 267 |
|
| 268 |
# ----------------- XML Data Page -----------------
|
| 269 |
elif st.session_state.page == "xml":
|
| 270 |
-
st.title(":
|
| 271 |
-
st.
|
| 272 |
-
XML (Extensible Markup Language) is
|
| 273 |
""")
|
| 274 |
-
st.markdown("###
|
| 275 |
st.code("""
|
| 276 |
import xml.etree.ElementTree as ET
|
|
|
|
| 277 |
tree = ET.parse('data.xml')
|
| 278 |
root = tree.getroot()
|
| 279 |
-
|
| 280 |
-
for
|
| 281 |
-
print(
|
| 282 |
-
for elem in child.iter():
|
| 283 |
-
print(elem.tag, elem.text)
|
| 284 |
""", language='python')
|
| 285 |
|
| 286 |
-
st.
|
| 287 |
st.write("""
|
| 288 |
-
- *
|
| 289 |
-
- *File not found*: Check the path to the XML file.
|
| 290 |
""")
|
| 291 |
|
| 292 |
-
st.write("### Solutions")
|
| 293 |
st.code("""
|
| 294 |
-
# Handle invalid XML structure
|
| 295 |
try:
|
| 296 |
tree = ET.parse('data.xml')
|
| 297 |
root = tree.getroot()
|
| 298 |
-
except
|
| 299 |
-
print("
|
| 300 |
""", language='python')
|
| 301 |
|
| 302 |
-
st.link_button(":blue[Open Jupyter Notebook](https://colab.research.google.com/drive/1sT35x4JH9s_hb31aMoUwtry-w8FE7fQg?usp=sharing)")
|
| 303 |
-
|
| 304 |
if st.button(":red[Back to Semi-Structured Data]"):
|
| 305 |
st.session_state.page = "semi_structured_data"
|
| 306 |
|
| 307 |
# ----------------- JSON Data Page -----------------
|
| 308 |
elif st.session_state.page == "json":
|
| 309 |
-
st.title(":
|
| 310 |
-
st.markdown("""
|
| 311 |
-
JSON (JavaScript Object Notation) is a lightweight format for storing and exchanging data. It is human-readable and easy to parse.
|
| 312 |
-
""")
|
| 313 |
-
st.markdown("### How to Read JSON Data")
|
| 314 |
-
st.code("""
|
| 315 |
-
import json
|
| 316 |
-
# Open and load the JSON data
|
| 317 |
-
with open('data.json') as json_file:
|
| 318 |
-
data = json.load(json_file)
|
| 319 |
-
print(data)
|
| 320 |
-
""", language='python')
|
| 321 |
-
|
| 322 |
-
st.markdown("### Issues Encountered")
|
| 323 |
st.write("""
|
| 324 |
-
|
| 325 |
-
- *File not found*: Incorrect path to JSON file.
|
| 326 |
""")
|
| 327 |
|
| 328 |
-
st.
|
| 329 |
st.code("""
|
| 330 |
-
|
| 331 |
-
try:
|
| 332 |
-
with open('data.json') as json_file:
|
| 333 |
-
data = json.load(json_file)
|
| 334 |
-
except json.JSONDecodeError:
|
| 335 |
-
print("Error: Invalid JSON format")
|
| 336 |
-
""", language='python')
|
| 337 |
-
|
| 338 |
-
st.link_button(":blue[Open Jupyter Notebook](https://colab.research.google.com/drive/1sT35x4JH9s_hb31aMoUwtry-w8FE7fQg?usp=sharing)")
|
| 339 |
|
| 340 |
-
|
| 341 |
-
|
|
|
|
| 342 |
|
| 343 |
-
|
| 344 |
-
elif st.session_state.page == "html":
|
| 345 |
-
st.title(":red[HTML Data Format]")
|
| 346 |
-
st.markdown("""
|
| 347 |
-
HTML (Hypertext Markup Language) is the standard markup language for documents designed to be displayed in a web browser.
|
| 348 |
-
""")
|
| 349 |
-
st.markdown("### How to Handle HTML Data")
|
| 350 |
-
st.code("""
|
| 351 |
-
from bs4 import BeautifulSoup
|
| 352 |
-
|
| 353 |
-
html_content = '''<html><head><title>Test Page</title></head><body><h1>Welcome</h1></body></html>'''
|
| 354 |
-
soup = BeautifulSoup(html_content, 'html.parser')
|
| 355 |
-
print(soup.prettify())
|
| 356 |
""", language='python')
|
| 357 |
|
| 358 |
-
st.
|
| 359 |
st.write("""
|
| 360 |
-
- *
|
| 361 |
-
- *Missing libraries*: BeautifulSoup might be missing.
|
| 362 |
""")
|
| 363 |
|
| 364 |
-
st.write("### Solutions")
|
| 365 |
st.code("""
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
|
|
|
|
|
|
| 369 |
""", language='python')
|
| 370 |
|
| 371 |
-
st.link_button(":blue[Open Jupyter Notebook](https://colab.research.google.com/drive/1sT35x4JH9s_hb31aMoUwtry-w8FE7fQg?usp=sharing)")
|
| 372 |
-
|
| 373 |
if st.button(":red[Back to Semi-Structured Data]"):
|
| 374 |
st.session_state.page = "semi_structured_data"
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import json
|
| 3 |
import xml.etree.ElementTree as ET
|
| 4 |
+
import pandas as pd
|
| 5 |
|
| 6 |
# Initialize page navigation state
|
| 7 |
if 'page' not in st.session_state:
|
|
|
|
| 216 |
if not ret:
|
| 217 |
break
|
| 218 |
cv2.imshow('Frame', frame)
|
| 219 |
+
if cv2.waitKey(1) & 0xFF == ord('q'):
|
| 220 |
break
|
| 221 |
video.release()
|
| 222 |
cv2.destroyAllWindows()
|
| 223 |
""", language='python')
|
| 224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
if st.button(":red[Back to Data Collection]"):
|
| 226 |
st.session_state.page = "data_collection"
|
| 227 |
|
|
|
|
| 229 |
elif st.session_state.page == "semi_structured_data":
|
| 230 |
st.title(":blue[Semi-Structured Data]")
|
| 231 |
st.markdown("""
|
| 232 |
+
Semi-structured data does not have a rigid structure but contains tags and markers to separate different data elements, like XML or JSON.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
""")
|
| 234 |
|
| 235 |
+
if st.button(":blue[XML Data]"):
|
| 236 |
st.session_state.page = "xml"
|
| 237 |
|
| 238 |
+
if st.button(":blue[JSON Data]"):
|
| 239 |
st.session_state.page = "json"
|
| 240 |
|
|
|
|
|
|
|
|
|
|
| 241 |
if st.button(":red[Back to Data Collection]"):
|
| 242 |
st.session_state.page = "data_collection"
|
| 243 |
|
| 244 |
# ----------------- XML Data Page -----------------
|
| 245 |
elif st.session_state.page == "xml":
|
| 246 |
+
st.title(":blue[XML Data Format]")
|
| 247 |
+
st.write("""
|
| 248 |
+
XML (Extensible Markup Language) is a markup language that defines rules for encoding documents in a format that is both human-readable and machine-readable.
|
| 249 |
""")
|
| 250 |
+
st.markdown("### Example: Reading XML data")
|
| 251 |
st.code("""
|
| 252 |
import xml.etree.ElementTree as ET
|
| 253 |
+
|
| 254 |
tree = ET.parse('data.xml')
|
| 255 |
root = tree.getroot()
|
| 256 |
+
|
| 257 |
+
for elem in root:
|
| 258 |
+
print(elem.tag, elem.text)
|
|
|
|
|
|
|
| 259 |
""", language='python')
|
| 260 |
|
| 261 |
+
st.write("### Issues Encountered")
|
| 262 |
st.write("""
|
| 263 |
+
- *File not found*: Incorrect file path.
|
|
|
|
| 264 |
""")
|
| 265 |
|
| 266 |
+
st.write("### Solutions to These Issues")
|
| 267 |
st.code("""
|
|
|
|
| 268 |
try:
|
| 269 |
tree = ET.parse('data.xml')
|
| 270 |
root = tree.getroot()
|
| 271 |
+
except FileNotFoundError:
|
| 272 |
+
print("File not found. Check the file path.")
|
| 273 |
""", language='python')
|
| 274 |
|
|
|
|
|
|
|
| 275 |
if st.button(":red[Back to Semi-Structured Data]"):
|
| 276 |
st.session_state.page = "semi_structured_data"
|
| 277 |
|
| 278 |
# ----------------- JSON Data Page -----------------
|
| 279 |
elif st.session_state.page == "json":
|
| 280 |
+
st.title(":blue[JSON Data Format]")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
st.write("""
|
| 282 |
+
JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate.
|
|
|
|
| 283 |
""")
|
| 284 |
|
| 285 |
+
st.markdown("### Example: Reading JSON data")
|
| 286 |
st.code("""
|
| 287 |
+
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
|
| 289 |
+
# Reading a JSON file
|
| 290 |
+
with open('data.json', 'r') as file:
|
| 291 |
+
data = json.load(file)
|
| 292 |
|
| 293 |
+
print(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
""", language='python')
|
| 295 |
|
| 296 |
+
st.write("### Issues Encountered")
|
| 297 |
st.write("""
|
| 298 |
+
- *File not found*: Incorrect file path.
|
|
|
|
| 299 |
""")
|
| 300 |
|
| 301 |
+
st.write("### Solutions to These Issues")
|
| 302 |
st.code("""
|
| 303 |
+
try:
|
| 304 |
+
with open('data.json', 'r') as file:
|
| 305 |
+
data = json.load(file)
|
| 306 |
+
except FileNotFoundError:
|
| 307 |
+
print("File not found. Check the file path.")
|
| 308 |
""", language='python')
|
| 309 |
|
|
|
|
|
|
|
| 310 |
if st.button(":red[Back to Semi-Structured Data]"):
|
| 311 |
st.session_state.page = "semi_structured_data"
|