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("""
""", unsafe_allow_html=True)
st.markdown(
"""
""",
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("""
What is Data?πβ¨
""", 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("""
Types of Data
""", 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("""
What is Structured Data?
""", unsafe_allow_html=True)
st.markdown("""
Definition:
""", 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("""
Characteristics:
""", 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("""
Examples:
""", 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("""
Data Formats in Structured Data:
""", 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("""
What is Unstructured Data?
""", unsafe_allow_html=True)
st.markdown("""
Definition:
""", 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("""
Characteristics:
""", 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("""
Examples:
""", 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("""
Data Formats in UnStructured Data:
""", 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("""
What is Semi-Structured Data?
""", unsafe_allow_html=True)
st.markdown("""
Definition:
""", 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("""
Characteristics:
""", 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("""
Examples:
""", 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("""
Data Formats in Semi-Structured Data:
""", 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("""
Exploring Excel
""", 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("""
Introduction to Images and VideosπΈπΌοΈ
""", unsafe_allow_html=True)
# Subheading 1: What is an Image?
st.markdown("""
What is an Image?πβ¨
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.
""", unsafe_allow_html=True)
# Subheading 2: What is a Video?
st.markdown("""
What is a Video?π₯β¨
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.
""", unsafe_allow_html=True)
# Subheading 3: Why is an Image Called a Grid-Like Structure?
st.markdown("""
Why is an Image Called a Grid-Like Structure?π²β¨
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.
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.
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.
""", unsafe_allow_html=True)
# Visualization for Grid-Like Structure
st.markdown("Image as a Grid Structure
", 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("""
Exploring Audio
""", 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("""
Exploring Text
""", 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("""
Exploring CSV
""", 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("""
Exploring JSON
""", 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("""
Exploring XML
""", 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("""
Exploring HTML
""", unsafe_allow_html=True)
st.write("""
HTML structures web pages using elements like and
.
""")
if st.button("Go Back"):
navigate_to("main")