Spaces:
Build error
Build error
Update pages/LIFE_CYCLE_OF_MACHINE_LEARNING.py
Browse files
pages/LIFE_CYCLE_OF_MACHINE_LEARNING.py
CHANGED
|
@@ -72,7 +72,6 @@ def data_collection_page():
|
|
| 72 |
if st.button("Back to Home"):
|
| 73 |
st.session_state.page = "home"
|
| 74 |
|
| 75 |
-
|
| 76 |
# ----------------- Structured Data Page -----------------
|
| 77 |
def structured_data_page():
|
| 78 |
st.title(":blue[Structured Data]")
|
|
@@ -132,7 +131,7 @@ excel_file = pd.ExcelFile('data.xlsx')
|
|
| 132 |
print(excel_file.sheet_names)
|
| 133 |
""", language='python')
|
| 134 |
|
| 135 |
-
st.
|
| 136 |
|
| 137 |
if st.button("Back to Structured Data"):
|
| 138 |
st.session_state.page = "structured_data"
|
|
@@ -142,9 +141,11 @@ def csv_page():
|
|
| 142 |
st.title(":green[CSV Data Format]")
|
| 143 |
|
| 144 |
st.write("### What is CSV?")
|
| 145 |
-
st.write("
|
|
|
|
|
|
|
| 146 |
|
| 147 |
-
st.write("###
|
| 148 |
st.code("""
|
| 149 |
import pandas as pd
|
| 150 |
|
|
@@ -169,7 +170,14 @@ except UnicodeDecodeError:
|
|
| 169 |
print("Error: Encoding issue. Try specifying a different encoding like 'latin1' or 'utf-8'.")
|
| 170 |
""", language='python')
|
| 171 |
|
| 172 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
if st.button("Back to Structured Data"):
|
| 175 |
st.session_state.page = "structured_data"
|
|
@@ -180,9 +188,10 @@ def json_page():
|
|
| 180 |
|
| 181 |
st.write("### What is JSON?")
|
| 182 |
st.write("""
|
| 183 |
-
JSON (JavaScript Object Notation) is a lightweight data-interchange format.
|
| 184 |
""")
|
| 185 |
|
|
|
|
| 186 |
st.code("""
|
| 187 |
import json
|
| 188 |
|
|
@@ -192,11 +201,32 @@ with open('data.json', 'r') as file:
|
|
| 192 |
print(data)
|
| 193 |
""", language='python')
|
| 194 |
|
| 195 |
-
st.
|
|
|
|
|
|
|
| 196 |
|
| 197 |
-
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
# ----------------- Unstructured Data Page -----------------
|
| 202 |
def unstructured_data_page():
|
|
@@ -378,23 +408,24 @@ print(root.find('name').text) # Output: Bob
|
|
| 378 |
if st.button("Back to Data Collection"):
|
| 379 |
st.session_state.page = "data_collection"
|
| 380 |
|
| 381 |
-
#
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
|
|
|
| 398 |
# Run the router function
|
| 399 |
if __name__ == "__main__":
|
| 400 |
-
router()
|
|
|
|
| 72 |
if st.button("Back to Home"):
|
| 73 |
st.session_state.page = "home"
|
| 74 |
|
|
|
|
| 75 |
# ----------------- Structured Data Page -----------------
|
| 76 |
def structured_data_page():
|
| 77 |
st.title(":blue[Structured Data]")
|
|
|
|
| 131 |
print(excel_file.sheet_names)
|
| 132 |
""", language='python')
|
| 133 |
|
| 134 |
+
st.markdown('[Jupyter Notebook](https://colab.research.google.com/drive/1ZTKWTknL-4IQ9QbAfcyKzIP-_lNxmz2P?usp=sharing)')
|
| 135 |
|
| 136 |
if st.button("Back to Structured Data"):
|
| 137 |
st.session_state.page = "structured_data"
|
|
|
|
| 141 |
st.title(":green[CSV Data Format]")
|
| 142 |
|
| 143 |
st.write("### What is CSV?")
|
| 144 |
+
st.write("""
|
| 145 |
+
CSV (Comma-Separated Values) files store tabular data in plain text, where each line is a data record and columns are separated by commas.
|
| 146 |
+
""")
|
| 147 |
|
| 148 |
+
st.write("### Reading CSV Files")
|
| 149 |
st.code("""
|
| 150 |
import pandas as pd
|
| 151 |
|
|
|
|
| 170 |
print("Error: Encoding issue. Try specifying a different encoding like 'latin1' or 'utf-8'.")
|
| 171 |
""", language='python')
|
| 172 |
|
| 173 |
+
st.markdown("### Tips for Handling CSV Files")
|
| 174 |
+
st.write("""
|
| 175 |
+
- Always verify the delimiter used (e.g., commas, semicolons).
|
| 176 |
+
- Check for encoding compatibility, especially when dealing with international characters.
|
| 177 |
+
- Handle missing data effectively using functions like `fillna()` or `dropna()`.
|
| 178 |
+
""")
|
| 179 |
+
|
| 180 |
+
st.markdown('[Jupyter Notebook](https://colab.research.google.com/drive/your_csv_guide_link)')
|
| 181 |
|
| 182 |
if st.button("Back to Structured Data"):
|
| 183 |
st.session_state.page = "structured_data"
|
|
|
|
| 188 |
|
| 189 |
st.write("### What is JSON?")
|
| 190 |
st.write("""
|
| 191 |
+
JSON (JavaScript Object Notation) is a lightweight data-interchange format that's easy for humans to read and write, and easy for machines to parse and generate. JSON is often used in APIs, configuration files, and data transfer applications.
|
| 192 |
""")
|
| 193 |
|
| 194 |
+
st.write("### Reading JSON Files")
|
| 195 |
st.code("""
|
| 196 |
import json
|
| 197 |
|
|
|
|
| 201 |
print(data)
|
| 202 |
""", language='python')
|
| 203 |
|
| 204 |
+
st.write("### Writing JSON Files")
|
| 205 |
+
st.code("""
|
| 206 |
+
import json
|
| 207 |
|
| 208 |
+
# Write data to JSON file
|
| 209 |
+
data = {
|
| 210 |
+
"name": "Alice",
|
| 211 |
+
"age": 25,
|
| 212 |
+
"skills": ["Python", "Machine Learning"]
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
with open('data.json', 'w') as file:
|
| 216 |
+
json.dump(data, file, indent=4)
|
| 217 |
+
""", language='python')
|
| 218 |
+
|
| 219 |
+
st.markdown("### Tips for Handling JSON Files")
|
| 220 |
+
st.write("""
|
| 221 |
+
- JSON files can be nested, so you might need to navigate through dictionaries and lists.
|
| 222 |
+
- If the structure is complex, you can use libraries like `json_normalize()` in pandas to flatten the JSON into a more tabular format for easier analysis.
|
| 223 |
+
- JSON supports both strings and numbers, and other types like arrays and booleans, making it versatile for various data types.
|
| 224 |
+
""")
|
| 225 |
|
| 226 |
+
st.markdown('[Jupyter Notebook](https://colab.research.google.com/drive/your_json_guide_link)')
|
| 227 |
+
|
| 228 |
+
if st.button("Back to Structured Data"):
|
| 229 |
+
st.session_state.page = "structured_data"
|
| 230 |
|
| 231 |
# ----------------- Unstructured Data Page -----------------
|
| 232 |
def unstructured_data_page():
|
|
|
|
| 408 |
if st.button("Back to Data Collection"):
|
| 409 |
st.session_state.page = "data_collection"
|
| 410 |
|
| 411 |
+
# Main control to call appropriate page
|
| 412 |
+
if st.session_state.page == "home":
|
| 413 |
+
home_page()
|
| 414 |
+
elif st.session_state.page == "data_collection":
|
| 415 |
+
data_collection_page()
|
| 416 |
+
elif st.session_state.page == "structured_data":
|
| 417 |
+
structured_data_page()
|
| 418 |
+
elif st.session_state.page == "excel":
|
| 419 |
+
excel_page()
|
| 420 |
+
elif st.session_state.page == "csv":
|
| 421 |
+
csv_page()
|
| 422 |
+
elif st.session_state.page == "json":
|
| 423 |
+
json_page()
|
| 424 |
+
elif st.session_state.page == "unstructured_data":
|
| 425 |
+
unstructured_data_page()
|
| 426 |
+
elif st.session_state.page == "semi_structured_data":
|
| 427 |
+
semi_structured_data_page()
|
| 428 |
+
|
| 429 |
# Run the router function
|
| 430 |
if __name__ == "__main__":
|
| 431 |
+
router()
|