# 1.
Import Libraries
import pandas as pd
import numpy as np
# 2. Load Dataset
df = pd.read_csv("house_prices_500_realistic.csv")
print("Original Dataset Shape:", [Link])
print([Link]())
# 3. Check Missing Values
print("\nMissing Values Count:")
print([Link]().sum())
# 4. Handle Missing Values
# Numerical columns → Fill with Mean
num_cols = ['Size_sqft', 'Bedrooms', 'Property_Age', 'Distance_City_km', 'Price_Lakhs']
df[num_cols] = df[num_cols].fillna(df[num_cols].mean())
# Categorical columns → Fill with Mode (most frequent value)
cat_cols = ['Location', 'Furnished', 'Parking']
for col in cat_cols:
df[col] = df[col].fillna(df[col].mode()[0])
# 5. Encode Categorical Variables (One-Hot Encoding)
df_encoded = pd.get_dummies(df, drop_first=True)
# 6. Feature and Target Separation
X = df_encoded.drop('Price_Lakhs', axis=1)
y = df_encoded['Price_Lakhs']
# 7. Train-Test Split
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42
# 8. Feature Scaling (Optional but Recommended)
from [Link] import StandardScaler
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = [Link](X_test)
# Final Check
print("\nPreprocessing Completed!")
print("Training Shape:", X_train.shape)
print("Testing Shape:", X_test.shape)