trohith89 commited on
Commit
f88b23b
Β·
verified Β·
1 Parent(s): 3cfee8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -60
app.py CHANGED
@@ -1,69 +1,72 @@
1
  import streamlit as st
2
  import pandas as pd
3
- import os
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
- # Sidebar Navigation
20
- st.sidebar.title("Navigation")
21
- page = st.sidebar.radio("Go to", ["Home", "Dataset", "Other Pages"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- # Global state for dataset
24
- if "dataset" not in st.session_state:
25
- st.session_state.dataset = load_default_dataset()
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
- if page == "Home":
39
- st.header("Welcome to the Static Dataset App")
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
- elif page == "Dataset":
44
- st.header("Dataset")
45
-
46
- # Dataset Preview
47
- st.write("### Dataset Preview")
48
- if not st.session_state.dataset.empty:
49
- st.dataframe(st.session_state.dataset)
50
-
51
- # Download button for the displayed dataset
52
- st.write("### Download the Dataset")
53
- csv_data = st.session_state.dataset.to_csv(index=False).encode("utf-8")
54
- st.download_button(
55
- label="Download Dataset",
56
- data=csv_data,
57
- file_name="dataset.csv",
58
- mime="text/csv",
59
- )
60
- else:
61
- st.write("No dataset available. Please upload a dataset below.")
62
-
63
- # Upload a new dataset
64
- st.write("### Upload a New Dataset")
65
- handle_upload()
66
-
67
- elif page == "Other Pages":
68
- st.header("Other Pages")
69
- st.write("This section can be customized further based on the app's needs.")
 
 
 
 
 
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("![Beige Neutral Flowchart Graph Template.gif](https://cdn-uploads.huggingface.co/production/uploads/675fab3a2d0851e23d23cad3/owTdXfE7l7CdXQPSaAqBX.gif)")
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
+ )