diff --git a/life style data b/life style data new file mode 100644 index 00000000..6dba80d6 --- /dev/null +++ b/life style data @@ -0,0 +1,112 @@ +"Based on the correlation matrix, what is the strength and direction of the linear relationship between sleep duration and mood score in this dataset?" +# 1. Import necessary libraries +import pandas as pd +import numpy as np +import matplotlib.pyplot as plt +import seaborn as sns + +# Set visualization style +sns.set_style('darkgrid') +plt.rcParams['figure.figsize'] = (14, 7) + +# --- 2. Data Loading --- +# NOTE: Replace 'lifestyle_data.csv' with your actual file path. +# Assuming a dataset with columns: Date, Steps, CaloriesBurned, Distance, SleepDuration (hours) +try: + df = pd.read_csv('lifestyle_data.csv') + print("Life Style data successfully loaded!") +except FileNotFoundError: + print("Error: Make sure 'lifestyle_data.csv' is in the correct directory.") + print("Creating a dummy DataFrame for demonstration.") + # Create a minimal dummy DataFrame for structural demonstration if loading fails + data = { + 'Date': pd.to_datetime(pd.date_range(start='2024-01-01', periods=30, freq='D')), + 'Steps': np.random.randint(3000, 15000, 30), + 'CaloriesBurned': np.random.randint(500, 2000, 30), + 'Distance': np.round(np.random.uniform(2.0, 10.0, 30), 2), + 'SleepDuration': np.round(np.random.uniform(5.5, 9.0, 30), 1), + 'MoodScore': np.random.randint(1, 11, 30) # 1=Bad, 10=Excellent + } + df = pd.DataFrame(data) + +# Initial Data Exploration +print("\n--- Initial Data Info ---") +print(df.head()) +print(df.info()) + + +# --- 3. Data Cleaning and Preprocessing --- + +# 3.1. Convert 'Date' column to datetime objects +if 'Date' in df.columns and df['Date'].dtype != '