import streamlit as st import pandas as pd import os # Set up the app's title and description st.title("Hotel Data Analysis App") st.markdown(""" Welcome to the **Hotel Data Analysis App**. This app is designed to help you analyze hotel datasets, perform feature engineering, and create predictive models. Use the sidebar to navigate through the pages. ### Features: - Download the dataset for exploration. - Perform exploratory data analysis (EDA) and feature engineering. - Create and evaluate machine learning models. - Conclude insights from the analysis. ### About the Data: The dataset includes hotel-related information such as price, ratings, discounts, cashback, and categories. It is designed for understanding relationships between features and building predictive models. """) # File upload section st.markdown("## Upload Your Dataset") uploaded_file = st.file_uploader("Choose a CSV file", type="csv") # Handle file upload and dataset processing if uploaded_file is not None: try: # Read the uploaded CSV file sample_data = pd.read_csv(uploaded_file) df = pd.DataFrame(sample_data) # Display a preview of the dataset st.markdown("### Dataset Preview") st.dataframe(df.head()) # Convert the dataset to CSV for download csv = df.to_csv(index=False).encode('utf-8') # Add a download button for the processed dataset st.markdown("### Download Processed Dataset") st.download_button( label="Download Sample Dataset", data=csv, file_name="hotel_data.csv", mime="text/csv" ) except Exception as e: st.error(f"An error occurred while processing the file: {e}") else: st.warning("Please upload a dataset to proceed.")