Skip to content

Commit 4136af2

Browse files
authored
Merge pull request larymak#181 from aishwaryart02/main
Added house price predictor
2 parents be9de0d + fbe987a commit 4136af2

File tree

18 files changed

+2369
-0
lines changed

18 files changed

+2369
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.ipynb_checkpoints/
2+
__pycache__/
3+
contact.db
4+
result.txt
5+
tech.txt
6+
myTraning.py
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# House Price/Rent Predictor Website
2+
3+
While Buying or Renting House People usually want to get a range of price,
4+
5+
So for this purpose we had made this website to help peoples get approximate price they will have to pay according to the their requirment like 3BHK, Railway Station etc.
6+
7+
This website also have a SQL database(sqlalchemy) for Feedback from Users.
8+
9+
## Screenshots
10+
11+
Home Page
12+
![home](https://user-images.githubusercontent.com/78130964/149762241-462685ea-0c42-4e45-9699-c5331e1266a4.png)
13+
14+
About Page
15+
![about](https://user-images.githubusercontent.com/78130964/149762317-75833d93-63f3-4240-8b32-9e642e208458.png)
16+
17+
Choice form
18+
![uiform](https://user-images.githubusercontent.com/78130964/149762396-a1f4ab8d-d74b-4b74-933b-a30c315f1136.png)
19+
20+
House Price
21+
![price_main](https://user-images.githubusercontent.com/78130964/149762464-3bdd9b69-0d47-4afd-96a0-7e0a3e541178.png)
22+
23+
Rent
24+
![rent_main](https://user-images.githubusercontent.com/78130964/149762520-3d121b90-47b3-4ca8-878e-ad01efede04a.png)
25+
26+
27+
28+
29+
## Tech Stack
30+
31+
**Client:** HTML, CSS, Bootstrap
32+
33+
**Server:** Flask, Scikit, Sql-Alchemy
34+
35+
36+
## Run Locally
37+
38+
Install Python
39+
40+
Clone the project
41+
42+
Go to the project directory
43+
44+
```bash
45+
cd House-Price-Predictor
46+
```
47+
48+
Install dependencies
49+
50+
```bash
51+
pip install flask
52+
pip install SQLAlchemy
53+
pip install scikit-learn
54+
```
55+
56+
Start the server
57+
58+
```bash
59+
python main.py
60+
```
61+
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import pickle #pip install pickle
2+
3+
from flask import Flask, render_template, request #pip install flask
4+
5+
from flask_sqlalchemy import SQLAlchemy #pip install Flask-SQLAlchemy
6+
7+
app = Flask(__name__)
8+
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///contact.db"
9+
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
10+
db = SQLAlchemy(app)
11+
12+
13+
file = open('model.pkl', 'rb')
14+
clf = pickle.load(file)
15+
file.close()
16+
17+
18+
class Contact(db.Model):
19+
id = db.Column(db.Integer, primary_key=True)
20+
email = db.Column(db.String(200), nullable=False)
21+
concern = db.Column(db.String(500), nullable=False)
22+
# date_created = db.Column(db.DateTime, default=datetime.utcnow)
23+
24+
def __repr__(self) -> str:
25+
return f"{self.email} - {self.concern}"
26+
27+
# route
28+
@app.route('/', methods=["GET", "POST"])
29+
def index():
30+
if request.method == "POST":
31+
query = request.form['query']
32+
if query == "own":
33+
return render_template('form.html')
34+
elif query == "rent":
35+
# we can make two seperate form for owner and tenant but we will imrpove it
36+
return render_template('formrent.html')
37+
else:
38+
# we will make a seprate Error page for this in furture
39+
return "Page Not found please select valid input"
40+
return render_template('index.html')
41+
42+
43+
@app.route('/about', methods=["GET", "POST"])
44+
def about():
45+
if request.method == "POST":
46+
email = request.form['email']
47+
concern = request.form['con']
48+
detail = Contact(email=email, concern=concern)
49+
db.session.add(detail)
50+
db.session.commit()
51+
return render_template('about.html', res=True)
52+
return render_template('about.html')
53+
54+
55+
@app.route('/depend', methods=["GET", "POST"])
56+
def depend():
57+
return render_template('depend.html')
58+
59+
60+
@app.route('/form', methods=["GET", "POST"])
61+
def form():
62+
if request.method == "POST":
63+
bhk = int(request.form['bhk']) # range 1 to 3
64+
health = int(request.form['health']) # range 1 to 5
65+
school = int(request.form['school']) # range 1 to 4
66+
pool = int(request.form['pool']) # 1 for exist 0 for not
67+
park = int(request.form['park']) # range 1 to 5
68+
tax = int(request.form['tax']) # range 2000 to 5000
69+
train = int(request.form['train']) # range 1 to 5
70+
bus = int(request.form['bus']) # range 1 to 5
71+
market = int(request.form['market']) # range 1 to 5
72+
bank = int(request.form['bank']) # range 3 to 5
73+
police_Station = int(request.form['police_Station']) # range 1 to 3
74+
age = int(request.form['age']) # range 1 to 20
75+
area = int(request.form['area']) # 1 for urban 0 for rural
76+
mall = int(request.form['mall']) # range 1 to 3
77+
# range 5 to 10 for rural 10 to 20 for urban
78+
floor = int(request.form['floor'])
79+
worship = int(request.form['worship']) # range 1 to 12
80+
81+
inf = clf.predict([[pool, train, bus, school, park, 1, market, health,
82+
bank, bhk, tax, age, area, police_Station, mall, floor, worship]])[0]
83+
inf = -inf
84+
if area == 0:
85+
tag = "Lakh"
86+
else:
87+
inf = inf * 0.1
88+
tag = "Crore"
89+
inf = round(inf, 2)
90+
# print(inf)
91+
return render_template('show.html', str="Price", inf=inf, tag=tag)
92+
93+
94+
@app.route('/formRent', methods=["GET", "POST"])
95+
def form_Rent():
96+
if request.method == "POST":
97+
bhk = int(request.form['bhk']) # range 1 to 3
98+
health = int(request.form['health']) # range 1 to 5
99+
school = int(request.form['school']) # range 1 to 4
100+
pool = int(request.form['pool']) # 1 for exist 0 for not
101+
park = int(request.form['park']) # range 1 to 5
102+
tax = int(request.form['tax']) # range 2000 to 5000
103+
train = int(request.form['train']) # range 1 to 5
104+
bus = int(request.form['bus']) # range 1 to 5
105+
market = int(request.form['market']) # range 1 to 5
106+
bank = int(request.form['bank']) # range 3 to 5
107+
police_Station = int(request.form['police_Station']) # range 1 to 3
108+
age = int(request.form['age']) # range 1 to 20
109+
area = int(request.form['area']) # 1 for urban 0 for rural
110+
mall = int(request.form['mall']) # range 1 to 3
111+
# range 5 to 10 for rural 10 to 20 for urban
112+
floor = int(request.form['floor'])
113+
worship = int(request.form['worship']) # range 1 to 12
114+
115+
inf = clf.predict([[pool, train, bus, school, park, 1, market, health,
116+
bank, bhk, tax, age, area, police_Station, mall, floor, worship]])[0]
117+
inf = -inf
118+
if area == 1:
119+
inf = inf - (inf*0.1*4)
120+
else:
121+
inf = inf - (inf*0.1*8)
122+
inf = round(inf, 2)
123+
124+
# print(inf)
125+
return render_template('show.html', str="Rent", inf=inf, tag="thousand")
126+
127+
128+
if __name__ == "__main__":
129+
app.run(debug=True)

0 commit comments

Comments
 (0)