Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Rishika S

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
546 changes: 546 additions & 0 deletions NDV_Code_By_RishikaS_House_Price_Prediction/Housing.csv

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions NDV_Code_By_RishikaS_House_Price_Prediction/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import streamlit as st
import pandas as pd
import joblib
import numpy as np
import matplotlib.pyplot as plt

# Load model and encoders
model = joblib.load(r"C:\Users\RISHIKA\Downloads\model.pkl")
encoders = joblib.load(r"C:\Users\RISHIKA\Downloads\encoders.pkl")

# Set page config and background styling
st.set_page_config(page_title="🏡 Real Estate Price Predictor", layout="centered")

# Custom background and header using updated Streamlit selector
st.markdown(
"""
<style>
.stApp {
background: url("https://images.unsplash.com/photo-1600585154340-be6161a56a0c") no-repeat center center fixed;
background-size: cover;
}

/* ❌ Removed blurry overlay */
/* .stApp::before {
content: "";
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.75);
z-index: 0;
} */

.main, .block-container {
position: relative;
z-index: 1;
background-color: rgba(255, 255, 255, 0.95); /* You can make this more transparent if needed */
padding: 2rem;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

h1 {
color: #004D40;
text-align: center;
}

.stButton button {
background-color: #26A69A;
color: white;
font-weight: bold;
border-radius: 8px;
padding: 0.5rem 1rem;
}
</style>
""",
unsafe_allow_html=True
)

# Title
st.title("🏠 Real Estate Price Prediction App")
st.markdown("Use the form below to get an estimated price for your dream home.")

# Form layout
with st.form("prediction_form"):
st.subheader("🔍 Property Details")
col1, col2 = st.columns(2)

with col1:
area = st.number_input("📐 Area (sq. ft)", min_value=100)
bedrooms = st.slider("🛏️ Bedrooms", 1, 10)
bathrooms = st.slider("🛁 Bathrooms", 1, 10)
stories = st.selectbox("🏢 Stories", [1, 2, 3, 4])
parking = st.slider("🚗 Parking Spaces", 0, 4)
mainroad = st.selectbox("🛣️ Main Road", ["Yes", "No"])

with col2:
guestroom = st.selectbox("🧳 Guest Room", ["Yes", "No"])
basement = st.selectbox("🏚️ Basement", ["Yes", "No"])
hotwaterheating = st.selectbox("🔥 Hot Water Heating", ["Yes", "No"])
airconditioning = st.selectbox("❄️ Air Conditioning", ["Yes", "No"])
prefarea = st.selectbox("📍 Preferred Area", ["Yes", "No"])
furnishingstatus = st.selectbox("🛋️ Furnishing Status", ["Unfurnished", "Semi-Furnished", "Furnished"])
location = st.selectbox("🌆 Location", ["downtown", "suburb", "countryside"])

submitted = st.form_submit_button("🔮 Predict Price")

if submitted:
# Encode input using saved encoders
input_dict = {
"area": area,
"bedrooms": bedrooms,
"bathrooms": bathrooms,
"stories": stories,
"mainroad": encoders["mainroad"].transform([mainroad.lower()])[0],
"guestroom": encoders["guestroom"].transform([guestroom.lower()])[0],
"basement": encoders["basement"].transform([basement.lower()])[0],
"hotwaterheating": encoders["hotwaterheating"].transform([hotwaterheating.lower()])[0],
"airconditioning": encoders["airconditioning"].transform([airconditioning.lower()])[0],
"parking": parking,
"prefarea": encoders["prefarea"].transform([prefarea.lower()])[0],
"furnishingstatus": encoders["furnishingstatus"].transform([furnishingstatus.lower()])[0],
"location": encoders["location"].transform([location.lower()])[0]
}

input_df = pd.DataFrame([input_dict])
prediction = model.predict(input_df)[0]

st.success(f"💰 **Estimated Property Price:** ₹ {int(prediction):,}")

# Feature importance chart
st.subheader("📊 Feature Importance")
feat_imp = pd.Series(model.feature_importances_, index=input_df.columns)
st.bar_chart(feat_imp)

# Divider
st.markdown("---")
st.header("📂 Batch Prediction (Upload CSV)")

uploaded_file = st.file_uploader("Upload a CSV file with property details", type=["csv"])
if uploaded_file is not None:
try:
batch_data = pd.read_csv(uploaded_file)
for col in encoders:
if col in batch_data.columns:
batch_data[col] = batch_data[col].astype(str).str.lower()
batch_data[col] = encoders[col].transform(batch_data[col])
predictions = model.predict(batch_data)
batch_data["Predicted Price"] = [f"₹ {int(p):,}" for p in predictions]
st.success("✅ Batch Prediction Complete!")
st.dataframe(batch_data)
except Exception as e:
st.error(f"❌ Error: {e}")
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
97 changes: 97 additions & 0 deletions NDV_Code_By_RishikaS_House_Price_Prediction/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@

# 🏠 Real Estate Price Prediction Dashboard

An interactive web application built using **Streamlit** that predicts the price of a house based on various features such as area, bedrooms, amenities, and location. The app uses a machine learning model trained on a real estate dataset to provide accurate price predictions in real time.

---

## 📌 Project Features

- 🔮 Predict property price based on user inputs

- 🧠 Trained Random Forest Regressor model

- 📂 Batch prediction from uploaded CSV files

- 📊 Feature importance visualized using charts

- 🎨 Styled UI with custom background and layout

---

## 🧰 Tech Stack

| Tool | Purpose |
|------------------|-----------------------------|
| Python | Programming Language |
| Pandas, NumPy | Data manipulation |
| Scikit-learn | Model training & evaluation |
| Matplotlib, Seaborn | Data visualization |
| Joblib | Model serialization |
| Streamlit | Web app development |

---

## 🗂️ Dataset

- 📥 Source: [Housing Price Prediction – Kaggle](https://www.kaggle.com/datasets/harishkumardatalab/housing-price-prediction)

- 🔎 Features include:

- Area (sq. ft)

- Bedrooms, Bathrooms, Stories

- Main road access, Guest room, Basement

- Hot water heating, Air conditioning

- Parking availability

- Furnishing status, Preferred area

- Location

---

## 🚀 How to Run the Project

### 🛠️ Local Setup

1. **Clone the repo**

2. **Install dependencies**
```bash
pip install -r requirements.txt
```

3. **Run the app**
```bash
streamlit run app.py
```

4. ✅ The app will open in your browser at `http://localhost:8501`either automatically or when you click on the link in your terminal.

---

## 📦 File Structure

```
├── app.py # Streamlit app script

├── model.pkl # Trained model

├── encoders.pkl # Encoded label mappings

├── sample_input.csv # Sample input for batch prediction

├── requirements.txt # Project dependencies

└── README.md # Project documentation
```

---

## 📄 License

This project is under the MIT License.
7 changes: 7 additions & 0 deletions NDV_Code_By_RishikaS_House_Price_Prediction/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
streamlit==1.35.0
pandas==2.2.2
numpy==1.26.4
scikit-learn==1.3.2
matplotlib==3.8.4
seaborn==0.13.2
joblib==1.4.2
6 changes: 6 additions & 0 deletions NDV_Code_By_RishikaS_House_Price_Prediction/sample_input.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
area,bedrooms,bathrooms,stories,mainroad,guestroom,basement,hotwaterheating,airconditioning,parking,prefarea,furnishingstatus,location
3450,3,1,1,yes,no,yes,no,no,2,no,unfurnished,countryside
4960,2,1,1,yes,no,no,no,no,0,no,unfurnished,downtown
1950,3,2,2,yes,no,yes,no,no,0,yes,unfurnished,downtown
1950,3,1,1,no,no,no,yes,no,0,no,unfurnished,suburb
2135,3,2,2,no,no,no,no,no,0,no,unfurnished,suburb