Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import pandas as pd | |
| st.set_page_config( | |
| page_title="HomePage", | |
| page_icon="π", | |
| layout="wide" | |
| ) | |
| # Global CSS for consistent styling across all pages | |
| st.markdown(""" | |
| <style> | |
| body, .stApp { | |
| color: #4F4F4F; /* Replace with your desired font color */ | |
| background-color: #FFFFFF; | |
| } | |
| h1, h2, h3, h4, h5, h6 { | |
| color: #BB3385; | |
| } | |
| p { | |
| color: #4F4F4F; | |
| } | |
| ul li { | |
| color: #4F4F4F; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| st.markdown( | |
| """ | |
| <style> | |
| .stApp { | |
| background-image: url("https://huggingface.co/spaces/LakshmiHarika/MachineLearning/resolve/main/DALL%C2%B7E%202024-12-03%2023.34.47%20-%20A%20simple%20and%20elegant%20background%20image%20for%20an%20AI-themed%20web%20application.%20The%20background%20should%20feature%20a%20soft%20gradient%20transitioning%20from%20white%20to%20ligh.webp"); | |
| background-size: cover; | |
| background-repeat: no-repeat; | |
| background-attachment: fixed; | |
| } | |
| </style> | |
| """, | |
| unsafe_allow_html=True | |
| ) | |
| # Ensure session state for navigation | |
| if "current_page" not in st.session_state: | |
| st.session_state.current_page = "main" | |
| # Navigation function | |
| def navigate_to(page_name): | |
| st.session_state.current_page = page_name | |
| # Main Page | |
| if st.session_state.current_page == "main": | |
| # Page Title | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h2 style="color: #BB3385;">What is Data?πβ¨</h2> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| # Introduction Text | |
| st.write(""" | |
| **Data** is the measurements that are collected as a source of Information. | |
| It refers raw facts, figures, and observations that can be collected, stored, and processed. | |
| It has no meaning on its own until it is organized or analyzed to derive useful information.""") | |
| # Types of Data Section | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h2 style="color: #2a52be;">Types of Data</h2> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| # Radio Button for Data Type Selection | |
| data_type = st.radio( | |
| "Select the type of Data:", | |
| ("Structured Data", "Unstructured Data", "Semi-Structured Data") | |
| ) | |
| if data_type == "Structured Data": | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h3 style="color: #e25822;">What is Structured Data?</h3> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Definition:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| **Structured data** refers to information that is organized and formatted in a predefined manner, making it easy to store, retrieve, and analyze. | |
| It is typically stored in tabular formats like rows and columns, where each field contains a specific type of information. | |
| """) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Characteristics:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| - Follows a fixed schema. | |
| - Can be easily searched using query languages like SQL. | |
| - Suitable for quantitative analysis. | |
| """) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Examples:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| A database of students with fields like ID, name, age, and gender: | |
| """) | |
| student_data = { | |
| "Id": [100, 101, 102, 103], | |
| "Name": ["Lakshmi Harika", "Varshitha", "Hari Chandan", "Shamitha"], | |
| "Age": [22, 23, 22, 23], | |
| "Gender": ["Female", "Female", "Male", "Female"] | |
| } | |
| df = pd.DataFrame(student_data) | |
| st.markdown(df.style.set_table_styles( | |
| [{'selector': 'thead th', 'props': 'font-weight: bold;'}] | |
| ).hide(axis="index").to_html(), unsafe_allow_html=True) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Data Formats in Structured Data:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write("Click to explore Structured Data Formats:") | |
| if st.button("Explore Excel"): | |
| navigate_to("explore_excel") | |
| elif data_type == "Unstructured Data": | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h3 style="color: #e25822;">What is Unstructured Data?</h3> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Definition:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| **Unstructured data** refers to information that does not follow a predefined format or structure. | |
| It is typically raw data that lacks a clear, organized schema, making it harder to store and analyze using traditional tools. | |
| Examples include multimedia files (images, videos, audio), emails, and social media posts. | |
| """) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Characteristics:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| - Does not follow a specific schema or structure. | |
| - Cannot be stored in traditional tabular formats like rows and columns. | |
| - Requires advanced tools like machine learning or natural language processing (NLP) for analysis. | |
| """) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Examples:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| - **Images**: Photos, screenshots, or scanned documents. | |
| - **Audio**: Podcasts, voice recordings, or music files. | |
| - **Videos**: Recorded lectures, surveillance footage, or YouTube videos. | |
| - **Text**: Emails, social media posts, and blog articles. | |
| """) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Data Formats in UnStructured Data:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write("Click to explore Unstructured Data Formats:") | |
| if st.button("Explore Images & Videos"): | |
| navigate_to("explore_images_video") | |
| if st.button("Explore Audio"): | |
| navigate_to("explore_audio") | |
| if st.button("Explore Text"): | |
| navigate_to("explore_text") | |
| elif data_type == "Semi-Structured Data": | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h3 style="color: #e25822;">What is Semi-Structured Data?</h3> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Definition:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| **Semi-Structured data** refers to information that does not follow a strict tabular format but contains tags or markers to separate data elements. | |
| This type of data is more flexible than structured data but still organized enough to allow for easier analysis than unstructured data. | |
| """) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Characteristics:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| - Contains markers or tags (e.g., XML, JSON keys) to provide structure. | |
| - More flexible than structured data, allowing for varying schemas. | |
| - Easier to process than unstructured data. | |
| - Can store hierarchical relationships. | |
| """) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Examples:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| Examples of semi-structured data include: | |
| - **CSV**: Comma-separated values in plain-text files. | |
| - **JSON**: A lightweight data-interchange format used in web applications. | |
| - **XML**: Extensible Markup Language for structured document encoding. | |
| - **HTML**: Markup language for web pages. | |
| """) | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h4 style="color: #5b2c6f;">Data Formats in Semi-Structured Data:</h4> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| st.write("Click to explore Semi-Structured Data Formats:") | |
| if st.button("Explore CSV"): | |
| navigate_to("explore_csv") | |
| if st.button("Explore JSON"): | |
| navigate_to("explore_json") | |
| if st.button("Explore XML"): | |
| navigate_to("explore_xml") | |
| if st.button("Explore HTML"): | |
| navigate_to("explore_html") | |
| # Pages for Each Format | |
| elif st.session_state.current_page == "explore_excel": | |
| st.markdown(""" | |
| <h3 style="color: #e25822;">Exploring Excel</h3> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| Excel is a structured data format used to store and analyze data in tabular form. It supports features like formulas, charts, and pivot tables. | |
| """) | |
| if st.button("Go Back"): | |
| navigate_to("main") | |
| elif st.session_state.current_page == "explore_images_video": | |
| st.markdown(""" | |
| <h2 style="color: #BB3385;">Introduction to Images and VideosπΈπΌοΈ</h2> | |
| """, unsafe_allow_html=True) | |
| # Subheading 1: What is an Image? | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h3 style="color: #5b2c6f;">What is an Image?πβ¨</h3> | |
| <p style="font-size: 16px; color: #333;"> | |
| An image is a two-dimensional representation of the visible light spectrum, often captured | |
| using devices like cameras or scanners. It can store details such as colors, shapes, and textures, | |
| enabling us to visually interpret and analyze information. | |
| Common formats include JPEG, PNG, and BMP. | |
| </p> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| # Subheading 2: What is a Video? | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h3 style="color: #5b2c6f;">What is a Video?π₯β¨</h3> | |
| <p style="font-size: 16px; color: #333;"> | |
| A video is a collection of images, often referred to as frames, displayed one after another quickly | |
| to show continuous movement. Each frame captures a moment in time, and when these frames are played | |
| sequentially, they show continuous movement. | |
| Videos typically have a frame rate (e.g., 30 frames | |
| per second or 60 frames per second), which determines how many frames are displayed per second. | |
| Common video formats include MP4, AVI, and MOV. | |
| </p> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| # Subheading 3: Why is an Image Called a Grid-Like Structure? | |
| st.markdown(""" | |
| <div style="text-align: left; margin-top: 20px;"> | |
| <h3 style="color: #5b2c6f;">Why is an Image Called a Grid-Like Structure?π²β¨</h3> | |
| <p style="font-size: 16px; color: #333;"> | |
| Images are called **grid-like structures** because they are composed of **pixels** arranged in rows and columns, | |
| forming a rectangular grid. Each pixel contains information about **shape**, **color**, and **patterns**, which | |
| together define the image's content. | |
| The total number of pixels is determined by the image's height and width (resolution), and a higher resolution provides better clarity. | |
| </p> | |
| <p style="font-size: 16px; color: #333;"> | |
| In images, **pixels act as features**, and the entire grid represents a single data point. This combination | |
| of features and data points gives images their grid-like nature. | |
| </p> | |
| <p style="font-size: 16px; color: #333;"> | |
| While images and tabular data are both grid-like, the difference lies in interpretation: in images, the | |
| grid represents one data point, while in tabular data, rows represent data points, and columns represent features. | |
| </p> | |
| </div> | |
| """, unsafe_allow_html=True) | |
| # Visualization for Grid-Like Structure | |
| st.markdown("<h4 style='color: #BB3385;'>Image as a Grid Structure</h4>", unsafe_allow_html=True) | |
| height, width = 6, 6 | |
| grid = np.random.rand(height, width) | |
| fig, ax = plt.subplots() | |
| cax = ax.imshow(grid, cmap='viridis') | |
| # Annotate the grid with pixel labels | |
| for i in range(height): | |
| for j in range(width): | |
| ax.text(j, i, f'{grid[i, j]:.2f}', ha='center', va='center', color='white', fontsize=10) | |
| # Set axis labels and title | |
| ax.set_title("Image as a Grid-Like Structure", fontsize=12) | |
| ax.set_xlabel("Width (Pixels)", fontsize=10) | |
| ax.set_ylabel("Height (Pixels)", fontsize=10) | |
| ax.set_xticks(range(width)) | |
| ax.set_yticks(range(height)) | |
| ax.set_xticklabels([f'Col {j+1}' for j in range(width)]) | |
| ax.set_yticklabels([f'Row {i+1}' for i in range(height)]) | |
| ax.grid(color='white', linestyle='-', linewidth=1) | |
| fig.colorbar(cax, ax=ax, orientation='vertical', label='Pixel Value') | |
| st.pyplot(fig) | |
| # Go Back Button | |
| if st.button("Go Back"): | |
| navigate_to("main") | |
| elif st.session_state.current_page == "explore_audio": | |
| st.markdown(""" | |
| <h3 style="color: #e25822;">Exploring Audio</h3> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| Audio formats include MP3 and WAV for storing sound. | |
| """) | |
| if st.button("Go Back"): | |
| navigate_to("main") | |
| elif st.session_state.current_page == "explore_text": | |
| st.markdown(""" | |
| <h3 style="color: #e25822;">Exploring Text</h3> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| Text includes unstructured data like emails or plain-text files. | |
| """) | |
| if st.button("Go Back"): | |
| navigate_to("main") | |
| elif st.session_state.current_page == "explore_csv": | |
| st.markdown(""" | |
| <h3 style="color: #e25822;">Exploring CSV</h3> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| CSV is a simple text-based format where data fields are separated by commas. | |
| """) | |
| if st.button("Go Back"): | |
| navigate_to("main") | |
| elif st.session_state.current_page == "explore_json": | |
| st.markdown(""" | |
| <h3 style="color: #e25822;">Exploring JSON</h3> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| JSON is a semi-structured format used for APIs and data exchange. | |
| """) | |
| if st.button("Go Back"): | |
| navigate_to("main") | |
| elif st.session_state.current_page == "explore_xml": | |
| st.markdown(""" | |
| <h3 style="color: #e25822;">Exploring XML</h3> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| XML uses tags to structure semi-structured data. | |
| """) | |
| if st.button("Go Back"): | |
| navigate_to("main") | |
| elif st.session_state.current_page == "explore_html": | |
| st.markdown(""" | |
| <h3 style="color: #e25822;">Exploring HTML</h3> | |
| """, unsafe_allow_html=True) | |
| st.write(""" | |
| HTML structures web pages using elements like <div> and <p>. | |
| """) | |
| if st.button("Go Back"): | |
| navigate_to("main") | |