File size: 5,889 Bytes
81522e3
e0a433a
 
60808c3
58f019a
 
60808c3
58f019a
60808c3
 
10aeb0d
81522e3
 
e0a433a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58f019a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
---
layout: default
title: Real Estate Price Prediction API
description: real estate price prediction tool with web interface
license: apache-2.0
sdk: docker
app_file: app.py
emoji: πŸ“Š
colorFrom: green
colorTo: gray
pinned: true
---

# 🏠 **Real Estate Price Prediction API**

## 🌟 **Project Motto**
This project aims to provide an accurate and interactive **Real Estate Price Prediction tool**. Users can input details such as property location, square footage, number of bedrooms, and bathrooms to get an **instant price prediction** based on a trained **machine learning model**.  

This API bridges the gap between **data science** and **user-friendly deployment**, allowing seamless integration of advanced predictions into real-world applications.  

---

## πŸ’‘ **How It Works**

1. **Data Processing & Model Training**  
   - A dataset of real estate transactions was cleaned and processed.  
   - Key features such as `location`, `total_sqft`, `bath`, and `bhk` were selected.  
   - A **Linear Regression model** was trained and stored as a `.pkl` file for deployment.  

2. **Prediction Mechanism**  
   - The trained model is loaded and predicts property prices based on user inputs.  
   - Location data is one-hot encoded to handle categorical features.  

3. **Interactive Frontend**  
   - A Flask-powered web app provides an intuitive interface for predictions.  
   - Users input details via forms, and results are displayed instantly.  

4. **API Integration**  
   - A `/predict` endpoint allows developers to integrate the model with other applications.
---

## πŸŽ₯ Watch the Demo(click image belowπŸ‘‡)

[![Watch on YouTube](https://img.youtube.com/vi/NcmXkE907io/0.jpg)](https://www.youtube.com/watch?v=NcmXkE907io)


---

## πŸ“· **Screenshots**
### Home Page
![Home Page](images/homepage.png)

### Prediction Results
![Prediction Result](images/predicted_results.jpg)

---

## πŸ“‚ **Project Structure**

```
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── python-app.yml          # CI/CD workflow configuration
β”œβ”€β”€ data/                           # Dataset directory
β”‚   └── bengaluru_house_prices.csv  # Dataset file for the project
β”œβ”€β”€ models/                         # Saved models and feature names
β”‚   β”œβ”€β”€ feature_names.pkl           # Pickled feature names
β”‚   └── lr_regg.pkl                 # Trained regression model
β”œβ”€β”€ src/                            # Source code for the project
β”‚   β”œβ”€β”€ EDA.py                      # Exploratory Data Analysis script
β”‚   β”œβ”€β”€ model.py                    # Model training and evaluation script
β”‚   └── preprocessing.py            # Data preprocessing logic
β”œβ”€β”€ templates/                      # HTML templates for the Flask web app
β”‚   β”œβ”€β”€ index.html                  # User input form for predictions
β”‚   └── results.html                # Displays prediction results
β”œβ”€β”€ tests/                          # Unit testing for the project
β”‚   β”œβ”€β”€ __init__.py                 # Marks the directory as a package
β”‚   β”œβ”€β”€ test_model.py               # Tests for the model
β”‚   └── test2direct.py              # Additional test script
β”œβ”€β”€ .gitignore                      # Specifies ignored files for Git
β”œβ”€β”€ app.py                          # Flask application entry point
β”œβ”€β”€ main.py                         # Main execution script
β”œβ”€β”€ requirements.txt                # List of dependencies for the project
β”œβ”€β”€ setup.py                        # Setup script for packaging the project
β”œβ”€β”€ README.md                       # Project overview and documentation

```

---

## πŸš€ **Features**
- **Accurate Price Predictions** using a trained regression model.  
- **Interactive Web Interface** for user-friendly predictions.  
- **API Integration** for developers to use the model programmatically.  
- **Scalable and Extendable** to new locations or additional features.  

---

## πŸ› οΈ **Installation and Setup**

### Prerequisites  
- Python 3.8+  
- Flask  
- Pickle  

### Installation Steps  
1. Clone the repository:  
   ```bash
 git clone https://github.com/Maazuddin1/Banglore_RealEstate_forecast-using-CICD-piplines.git  
 cd Banglore_RealEstate_forecast-using-CICD-piplines
 
   ```

2. Create a virtual environment:  
   ```bash
   python -m venv env
   source env/bin/activate  # Linux/Mac
   env\Scripts\activate     # Windows
   ```

3. Install dependencies:  
   ```bash
   pip install -r requirements.txt
   ```

4. Start the Flask application:  
   ```bash
   python app.py
   ```

5. Open your browser and navigate to `http://127.0.0.1:5000/`.  

---

## 🌐 **API Usage**

### Endpoint: `/predict`  
**Method**: `POST`  
**Input** (JSON):  
```json
{
  "location": "Whitefield",
  "sqft": 1200,
  "bath": 2,
  "bhk": 3
}
```

**Output**:  
```json
{
  "predicted_price": 94.23 Lakhs
}
```

---

## πŸ” **Model Details**
The trained model uses **Linear Regression** with key features like:
- **total_sqft**: Total square footage of the property.  
- **bath**: Number of bathrooms.  
- **bhk**: Number of bedrooms.  
- **Location**: One-hot encoded for categorical support.  

---

## πŸ“ˆ **Future Enhancements**
- Add support for more advanced machine learning models like Random Forest or XGBoost.  
- Improve UI design with frameworks like Bootstrap.  
- Expand location datasets for better predictions.  
- Add real-time price scraping for dynamic updates.  

---

## πŸ–ΌοΈ **Visual Workflow**
```mermaid
graph TD
A[User Input] --> B[Flask App]
B --> C[Process Input Features]
C --> D[Trained ML Model]
D --> E[Predict Price]
E --> F[Display Results]
```

---

## 🌟 **Contributions**  
Contributions are welcome! Feel free to fork this repository, open issues, or submit pull requests.

---

## πŸ“„ **License**
-
---