|
|
import os |
|
|
import pandas as pd |
|
|
import streamlit as st |
|
|
from io import StringIO |
|
|
|
|
|
|
|
|
DATA_FILE_PATH = "consumer_electronics_sales_data.csv" |
|
|
|
|
|
|
|
|
st.markdown("<h1 style='text-align:center; color:white;'>Electronics Sales Data Set</h1>", unsafe_allow_html=True) |
|
|
|
|
|
|
|
|
def load_dataset(): |
|
|
if os.path.exists(DATA_FILE_PATH): |
|
|
return pd.read_csv(DATA_FILE_PATH) |
|
|
else: |
|
|
return None |
|
|
|
|
|
|
|
|
if "dataset" not in st.session_state: |
|
|
st.session_state["dataset"] = load_dataset() |
|
|
|
|
|
|
|
|
uploaded_file = st.file_uploader("Choose a CSV file", type=["csv"]) |
|
|
|
|
|
if uploaded_file is not None: |
|
|
|
|
|
df = pd.read_csv(uploaded_file) |
|
|
|
|
|
|
|
|
df.to_csv(DATA_FILE_PATH, index=False) |
|
|
|
|
|
|
|
|
st.session_state["dataset"] = df |
|
|
|
|
|
|
|
|
st.success(f"Dataset uploaded and saved permanently as {DATA_FILE_PATH}!") |
|
|
|
|
|
|
|
|
df = st.session_state.get("dataset") |
|
|
|
|
|
if df is not None: |
|
|
st.subheader("Dataset Preview:") |
|
|
st.write(df, use_container_width=True) |
|
|
|
|
|
st.subheader("Info of the Dataset:") |
|
|
buffer = StringIO() |
|
|
df.info(buf=buffer) |
|
|
st.text(buffer.getvalue()) |
|
|
|
|
|
st.subheader("Dataset Shape (Rows, Columns):") |
|
|
st.write(df.shape) |
|
|
|
|
|
st.markdown('''**Dataset :** |
|
|
|
|
|
| **Feature** | **Description** | **Example** | |
|
|
|-------------------------|--------------------------------------------------------------------|------------------------------| |
|
|
| **ProductID** | Unique identifier for each product. | 12345 | |
|
|
| **ProductCategory** | Category of the consumer electronics product. | Smartphones, Laptops | |
|
|
| **ProductBrand** | Brand of the product. | Apple, Samsung | |
|
|
| **ProductPrice** | Price of the product (in dollars). | 999.99 | |
|
|
| **CustomerAge** | Age of the customer. | 35 | |
|
|
| **CustomerGender** | Gender of the customer (0 - Male, 1 - Female). | 1 | |
|
|
| **PurchaseFrequency** | Average number of purchases per year. | 3 | |
|
|
| **CustomerSatisfaction** | Customer satisfaction rating (1 - 5). | 4 | |
|
|
| **PurchaseIntent** | Target variable: Intent to purchase (classification target). | 0 (No), 1 (Yes) | |
|
|
''') |
|
|
|
|
|
|
|
|
|
|
|
else: |
|
|
st.info("No dataset found. Please upload a CSV file.") |
|
|
|
|
|
|
|
|
background_image_url = "https://cdn-uploads.huggingface.co/production/uploads/67441c51a784a9d15cb12871/xpoN_mbctlrQAgRU06EPt.jpeg" |
|
|
|
|
|
|
|
|
st.markdown( |
|
|
f""" |
|
|
<style> |
|
|
.stApp {{ |
|
|
background-image: url("{background_image_url}"); |
|
|
background-size: cover; |
|
|
background-position: center; |
|
|
height: 100vh; |
|
|
}} |
|
|
|
|
|
/* Semi-transparent overlay */ |
|
|
.stApp::before {{ |
|
|
content: ""; |
|
|
position: absolute; |
|
|
top: 0; |
|
|
left: 0; |
|
|
width: 100%; |
|
|
height: 100%; |
|
|
background: rgba(0, 0, 0, 0.4); |
|
|
z-index: -1; |
|
|
}} |
|
|
|
|
|
/* Styling the content to ensure text visibility */ |
|
|
.stMarkdown {{ |
|
|
color: white; |
|
|
font-size: 100px; |
|
|
}} |
|
|
</style> |
|
|
""", |
|
|
unsafe_allow_html=True |
|
|
) |
|
|
|
|
|
|
|
|
if st.button("Previous ⏮️"): |
|
|
st.switch_page("pages/0_Problem-Statement_and_Aim.py") |
|
|
if st.button("Next ⏭️"): |
|
|
st.switch_page("pages/2_Data_CLeaning_and_Preprocessing.py") |