Update app.py
Browse files
app.py
CHANGED
|
@@ -1,69 +1,72 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
-
import
|
| 4 |
|
| 5 |
-
# Load the default dataset or upload a new one
|
| 6 |
-
@st.cache_data
|
| 7 |
-
def load_default_dataset():
|
| 8 |
-
file_path = "consumer_electronics_sales_data.csv"
|
| 9 |
-
if os.path.exists(file_path):
|
| 10 |
-
return pd.read_csv(file_path)
|
| 11 |
-
else:
|
| 12 |
-
st.error("Default dataset not found. Please upload a dataset.")
|
| 13 |
-
return pd.DataFrame()
|
| 14 |
|
| 15 |
-
# Main App
|
| 16 |
-
st.set_page_config(page_title="Streamlit App with Static Dataset", layout="wide")
|
| 17 |
-
st.title("Static Dataset App with Upload Feature")
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
-
# Upload a new dataset
|
| 28 |
-
def handle_upload():
|
| 29 |
-
uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])
|
| 30 |
-
if uploaded_file is not None:
|
| 31 |
-
try:
|
| 32 |
-
data = pd.read_csv(uploaded_file)
|
| 33 |
-
st.session_state.dataset = data
|
| 34 |
-
st.success("Dataset uploaded successfully!")
|
| 35 |
-
except Exception as e:
|
| 36 |
-
st.error(f"Error reading file: {e}")
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
st.write("This app uses a static dataset but also supports uploading a new dataset.")
|
| 41 |
-
st.write("Navigate to the 'Dataset' page to view or upload a dataset.")
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
st.markdown("""
|
| 8 |
+
<h1 style="text-align:center; color:orange;">Hotel Data Analysis & Machine Learning</h1>
|
| 9 |
+
""", unsafe_allow_html=True)
|
| 10 |
+
st.markdown(
|
| 11 |
+
"""
|
| 12 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/675fab3a2d0851e23d23cad3/vBi2udNoFPwTnjec40wbw.jpeg" width="100%" />
|
| 13 |
+
""",
|
| 14 |
+
unsafe_allow_html=True
|
| 15 |
+
)
|
| 16 |
+
st.markdown("""
|
| 17 |
+
## Predicting Customer Preferences and Optimizing Pricing:
|
| 18 |
+
##### π Data Exploration and Preprocessing:
|
| 19 |
+
- <span style="font-size:20px;">Cleaning and preparing data by handling missing values, encoding categorical features like *"category"* and *"location,"* and normalizing numerical data such as *"price"* and *"rating."*</span>
|
| 20 |
+
- <span style="font-size:20px;">Analyzing trends in **customer reviews**, **cashback offers**, **discounts**, and **free services** to identify influential factors.
|
| 21 |
+
##### π€ Predictive Modeling:
|
| 22 |
+
- <span style="font-size:20px;">**Target Variable**: Predicting key metrics like *price category*, *likelihood of cancellation*, or *hotel ratings.*</span>
|
| 23 |
+
- <span style="font-size:20px;">**Model Selection**: Building ML models such as **Decision Trees**, **Random Forests**, or **Gradient Boosting** for classification or regression tasks.</span>
|
| 24 |
+
- <span style="font-size:20px;">**Feature Engineering**: Extracting insights from **review text** (via text sentiment analysis) or **free services** (binary encoding).</span>
|
| 25 |
+
##### π Model Evaluation:
|
| 26 |
+
- <span style="font-size:20px;">Comparing model performance using metrics like **accuracy**, **F1 score**, or **RMSE**, depending on the task.</span>
|
| 27 |
+
- <span style="font-size:20px;">Employing techniques like **hyperparameter tuning** and **cross-validation** for optimization.</span>
|
| 28 |
+
##### πΌ Insights and Deployment:
|
| 29 |
+
- <span style="font-size:20px;">Unveiling actionable insights from **feature importance** to guide hotel marketing and pricing strategies.</span>
|
| 30 |
+
- <span style="font-size:20px;">Deploying the model in a user-friendly interface to support stakeholders in making real-time decisions.</span>
|
| 31 |
+
##### By integrating **machine learning** with **data analysis**, this project empowers hotel businesses to enhance customer satisfaction, optimize pricing strategies, and maximize profitability.
|
| 32 |
+
""", unsafe_allow_html=True)
|
| 33 |
|
| 34 |
+
# # Display an image from a file
|
| 35 |
+
st.subheader("Hotel Data Analysis Model Creation Flow")
|
| 36 |
+
st.markdown("")
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
# Define the URL of the background image (use your own image URL)
|
| 40 |
+
background_image_url = "https://cdn-uploads.huggingface.co/production/uploads/675fab3a2d0851e23d23cad3/FlisTFfpU7flDCWj_KttH.jpeg"
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
# Apply custom CSS for the background image and overlay
|
| 43 |
+
st.markdown(
|
| 44 |
+
f"""
|
| 45 |
+
<style>
|
| 46 |
+
.stApp {{
|
| 47 |
+
background-image: url("{background_image_url}");
|
| 48 |
+
background-size: cover;
|
| 49 |
+
background-position: center;
|
| 50 |
+
height: 100vh;
|
| 51 |
+
}}
|
| 52 |
+
|
| 53 |
+
/* Semi-transparent overlay */
|
| 54 |
+
.stApp::before {{
|
| 55 |
+
content: "";
|
| 56 |
+
position: absolute;
|
| 57 |
+
top: 0;
|
| 58 |
+
left: 0;
|
| 59 |
+
width: 100%;
|
| 60 |
+
height: 100%;
|
| 61 |
+
background: rgba(0, 0, 0, 0.4); /* Adjust transparency here (0.4 for 40% transparency) */
|
| 62 |
+
z-index: -1;
|
| 63 |
+
}}
|
| 64 |
+
/* Styling the content to ensure text visibility */
|
| 65 |
+
.stMarkdown {{
|
| 66 |
+
color: black; /* White text to ensure visibility */
|
| 67 |
+
font-size: 30px; /* Adjust font size for better readability */
|
| 68 |
+
}}
|
| 69 |
+
</style>
|
| 70 |
+
""",
|
| 71 |
+
unsafe_allow_html=True
|
| 72 |
+
)
|