Ayush19112 commited on
Commit
12a5507
1 Parent(s): 71987a5

Upload 7 files

Browse files
Files changed (7) hide show
  1. banglore_home_prices_model.pickle +3 -0
  2. columns.json +1 -0
  3. index.html +53 -0
  4. script.js +62 -0
  5. style.css +133 -0
  6. tempCodeRunnerFile.py +27 -0
  7. util.py +48 -0
banglore_home_prices_model.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:940fcc8b7f0836360bbeba3911bce17a529f51390eaf577b64c502ee1a3cd8ca
3
+ size 8158
columns.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"data_columns": ["total_sqft", "bath", "bhk", "1st block jayanagar", "1st phase jp nagar", "2nd phase judicial layout", "2nd stage nagarbhavi", "5th block hbr layout", "5th phase jp nagar", "6th phase jp nagar", "7th phase jp nagar", "8th phase jp nagar", "9th phase jp nagar", "aecs layout", "abbigere", "akshaya nagar", "ambalipura", "ambedkar nagar", "amruthahalli", "anandapura", "ananth nagar", "anekal", "anjanapura", "ardendale", "arekere", "attibele", "beml layout", "btm 2nd stage", "btm layout", "babusapalaya", "badavala nagar", "balagere", "banashankari", "banashankari stage ii", "banashankari stage iii", "banashankari stage v", "banashankari stage vi", "banaswadi", "banjara layout", "bannerghatta", "bannerghatta road", "basavangudi", "basaveshwara nagar", "battarahalli", "begur", "begur road", "bellandur", "benson town", "bharathi nagar", "bhoganhalli", "billekahalli", "binny pete", "bisuvanahalli", "bommanahalli", "bommasandra", "bommasandra industrial area", "bommenahalli", "brookefield", "budigere", "cv raman nagar", "chamrajpet", "chandapura", "channasandra", "chikka tirupathi", "chikkabanavar", "chikkalasandra", "choodasandra", "cooke town", "cox town", "cunningham road", "dasanapura", "dasarahalli", "devanahalli", "devarachikkanahalli", "dodda nekkundi", "doddaballapur", "doddakallasandra", "doddathoguru", "domlur", "dommasandra", "epip zone", "electronic city", "electronic city phase ii", "electronics city phase 1", "frazer town", "gm palaya", "garudachar palya", "giri nagar", "gollarapalya hosahalli", "gottigere", "green glen layout", "gubbalala", "gunjur", "hal 2nd stage", "hbr layout", "hrbr layout", "hsr layout", "haralur road", "harlur", "hebbal", "hebbal kempapura", "hegde nagar", "hennur", "hennur road", "hoodi", "horamavu agara", "horamavu banaswadi", "hormavu", "hosa road", "hosakerehalli", "hoskote", "hosur road", "hulimavu", "isro layout", "itpl", "iblur village", "indira nagar", "jp nagar", "jakkur", "jalahalli", "jalahalli east", "jigani", "judicial layout", "kr puram", "kadubeesanahalli", "kadugodi", "kaggadasapura", "kaggalipura", "kaikondrahalli", "kalena agrahara", "kalyan nagar", "kambipura", "kammanahalli", "kammasandra", "kanakapura", "kanakpura road", "kannamangala", "karuna nagar", "kasavanhalli", "kasturi nagar", "kathriguppe", "kaval byrasandra", "kenchenahalli", "kengeri", "kengeri satellite town", "kereguddadahalli", "kodichikkanahalli", "kodigehaali", "kodigehalli", "kodihalli", "kogilu", "konanakunte", "koramangala", "kothannur", "kothanur", "kudlu", "kudlu gate", "kumaraswami layout", "kundalahalli", "lb shastri nagar", "laggere", "lakshminarayana pura", "lingadheeranahalli", "magadi road", "mahadevpura", "mahalakshmi layout", "mallasandra", "malleshpalya", "malleshwaram", "marathahalli", "margondanahalli", "marsur", "mico layout", "munnekollal", "murugeshpalya", "mysore road", "ngr layout", "nri layout", "nagarbhavi", "nagasandra", "nagavara", "nagavarapalya", "narayanapura", "neeladri nagar", "nehru nagar", "ombr layout", "old airport road", "old madras road", "padmanabhanagar", "pai layout", "panathur", "parappana agrahara", "pattandur agrahara", "poorna pragna layout", "prithvi layout", "r.t. nagar", "rachenahalli", "raja rajeshwari nagar", "rajaji nagar", "rajiv nagar", "ramagondanahalli", "ramamurthy nagar", "rayasandra", "sahakara nagar", "sanjay nagar", "sarakki nagar", "sarjapur", "sarjapur road", "sarjapura - attibele road", "sector 2 hsr layout", "sector 7 hsr layout", "seegehalli", "shampura", "shivaji nagar", "singasandra", "somasundara palya", "sompura", "sonnenahalli", "subramanyapura", "sultan palaya", "tc palaya", "talaghattapura", "thanisandra", "thigalarapalya", "thubarahalli", "thyagaraja nagar", "tindlu", "tumkur road", "ulsoor", "uttarahalli", "varthur", "varthur road", "vasanthapura", "vidyaranyapura", "vijayanagar", "vishveshwarya layout", "vishwapriya layout", "vittasandra", "whitefield", "yelachenahalli", "yelahanka", "yelahanka new town", "yelenahalli", "yeshwanthpur"]}
index.html ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Banglore Home Price Prediction</title>
5
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
6
+ <script src="script.js"></script>
7
+ <link rel="stylesheet" href="style.css">
8
+ </head>
9
+ <body>
10
+ <div class="img"></div>
11
+ <form class="form">
12
+ <h2>Area (Square Feet)</h2>
13
+ <input class="area" type="text" id="uiSqft" class="floatLabel" name="Squareft" value="1000">
14
+ <h2>BHK</h2>
15
+ <div class="switch-field">
16
+ <input type="radio" id="radio-bhk-1" name="uiBHK" value="1"/>
17
+ <label for="radio-bhk-1">1</label>
18
+ <input type="radio" id="radio-bhk-2" name="uiBHK" value="2" checked/>
19
+ <label for="radio-bhk-2">2</label>
20
+ <input type="radio" id="radio-bhk-3" name="uiBHK" value="3"/>
21
+ <label for="radio-bhk-3">3</label>
22
+ <input type="radio" id="radio-bhk-4" name="uiBHK" value="4"/>
23
+ <label for="radio-bhk-4">4</label>
24
+ <input type="radio" id="radio-bhk-5" name="uiBHK" value="5"/>
25
+ <label for="radio-bhk-5">5</label>
26
+ </div>
27
+ </form>
28
+ <form class="form">
29
+ <h2>Bath</h2>
30
+ <div class="switch-field">
31
+ <input type="radio" id="radio-bath-1" name="uiBathrooms" value="1"/>
32
+ <label for="radio-bath-1">1</label>
33
+ <input type="radio" id="radio-bath-2" name="uiBathrooms" value="2" checked/>
34
+ <label for="radio-bath-2">2</label>
35
+ <input type="radio" id="radio-bath-3" name="uiBathrooms" value="3"/>
36
+ <label for="radio-bath-3">3</label>
37
+ <input type="radio" id="radio-bath-4" name="uiBathrooms" value="4"/>
38
+ <label for="radio-bath-4">4</label>
39
+ <input type="radio" id="radio-bath-5" name="uiBathrooms" value="5"/>
40
+ <label for="radio-bath-5">5</label>
41
+ </div>
42
+ <h2>Location</h2>
43
+ <div>
44
+ <select class="location" name="" id="uiLocations">
45
+ <option value="" disabled="disabled" selected="selected">Choose a Location</option>
46
+ <option>Electronic City</option>
47
+ <option>Rajaji Nagar</option>
48
+ </select>
49
+ </div>
50
+ <button class="submit" onclick="onClickedEstimatePrice()" type="button">Estimate Price</button>
51
+ <div id="uiEstimatedPrice" class="result"> <h2></h2> </div>
52
+ </body>
53
+ </html>
script.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function getBathValue() {
2
+ var uiBathrooms = document.getElementsByName("uiBathrooms");
3
+ for(var i in uiBathrooms) {
4
+ if(uiBathrooms[i].checked) {
5
+ return parseInt(i)+1;
6
+ }
7
+ }
8
+ return -1;
9
+ }
10
+
11
+ function getBHKValue() {
12
+ var uiBHK = document.getElementsByName("uiBHK");
13
+ for(var i in uiBHK) {
14
+ if(uiBHK[i].checked) {
15
+ return parseInt(i)+1;
16
+ }
17
+ }
18
+ return -1;
19
+ }
20
+
21
+ function onClickedEstimatePrice() {
22
+ console.log("Estimate price button clicked");
23
+ var sqft = document.getElementById("uiSqft");
24
+ var bhk = getBHKValue();
25
+ var bathrooms = getBathValue();
26
+ var location = document.getElementById("uiLocations");
27
+ var estPrice = document.getElementById("uiEstimatedPrice");
28
+
29
+ // var url = "http://127.0.0.1:5000/predict_home_price";
30
+ var url = "api/predict_home_price";
31
+
32
+ $.post(url, {
33
+ total_sqft: parseFloat(sqft.value),
34
+ bhk: bhk,
35
+ bath: bathrooms,
36
+ location: location.value
37
+ },function(data, status) {
38
+ console.log(data.estimated_price);
39
+ estPrice.innerHTML = "<h2>" + data.estimated_price.toString() + " Lakh</h2>";
40
+ console.log(status);
41
+ });
42
+ }
43
+
44
+ function onPageLoad() {
45
+ console.log( "document loaded" );
46
+ // var url = "http://127.0.0.1:5000/get_location_names";
47
+ var url = "api/get_location_names";
48
+ $.get(url,function(data, status) {
49
+ console.log("got response for get_location_names request");
50
+ if(data) {
51
+ var locations = data.locations;
52
+ var uiLocations = document.getElementById("uiLocations");
53
+ $('#uiLocations').empty();
54
+ for(var i in locations) {
55
+ var opt = new Option(locations[i]);
56
+ $('#uiLocations').append(opt);
57
+ }
58
+ }
59
+ });
60
+ }
61
+
62
+ window.onload = onPageLoad;
style.css ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import url(https://fonts.googleapis.com/css?family=Roboto:300);
2
+
3
+ .switch-field {
4
+ display: flex;
5
+ margin-bottom: 36px;
6
+ overflow: hidden;
7
+ }
8
+
9
+ .switch-field input {
10
+ position: absolute !important;
11
+ clip: rect(0, 0, 0, 0);
12
+ height: 1px;
13
+ width: 1px;
14
+ border: 0;
15
+ overflow: hidden;
16
+ }
17
+
18
+ .switch-field label {
19
+ background-color: #e4e4e4;
20
+ color: rgba(0, 0, 0, 0.6);
21
+ font-size: 14px;
22
+ line-height: 1;
23
+ text-align: center;
24
+ padding: 8px 16px;
25
+ margin-right: -1px;
26
+ border: 1px solid rgba(0, 0, 0, 0.2);
27
+ box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
28
+ transition: all 0.1s ease-in-out;
29
+ }
30
+
31
+ .switch-field label:hover {
32
+ cursor: pointer;
33
+ }
34
+
35
+ .switch-field input:checked + label {
36
+ background-color: #a5dc86;
37
+ box-shadow: none;
38
+ }
39
+
40
+ .switch-field label:first-of-type {
41
+ border-radius: 4px 0 0 4px;
42
+ }
43
+
44
+ .switch-field label:last-of-type {
45
+ border-radius: 0 4px 4px 0;
46
+ }
47
+
48
+ .form {
49
+ max-width: 270px;
50
+ font-family: "Lucida Grande", Tahoma, Verdana, sans-serif;
51
+ font-weight: normal;
52
+ line-height: 1.625;
53
+ margin: 8px auto;
54
+ padding-left: 16px;
55
+ z-index: 2;
56
+ }
57
+
58
+ h2 {
59
+ font-size: 18px;
60
+ margin-bottom: 8px;
61
+ }
62
+ .area{
63
+ font-family: "Roboto", sans-serif;
64
+ outline: 0;
65
+ background: #f2f2f2;
66
+ width: 76%;
67
+ border: 0;
68
+ margin: 0 0 10px;
69
+ padding: 10px;
70
+ box-sizing: border-box;
71
+ font-size: 15px;
72
+ height: 35px;
73
+ border-radius: 5px;
74
+ }
75
+
76
+ .location{
77
+ font-family: "Roboto", sans-serif;
78
+ outline: 0;
79
+ background: #f2f2f2;
80
+ width: 76%;
81
+ border: 0;
82
+ margin: 0 0 10px;
83
+ padding: 10px;
84
+ box-sizing: border-box;
85
+ font-size: 15px;
86
+ height: 40px;
87
+ border-radius: 5px;
88
+ }
89
+
90
+ .submit{
91
+ background: #a5dc86;
92
+ width: 76%;
93
+ border: 0;
94
+ margin: 25px 0 10px;
95
+ box-sizing: border-box;
96
+ font-size: 15px;
97
+ height: 35px;
98
+ text-align: center;
99
+ border-radius: 5px;
100
+ }
101
+
102
+ .result{
103
+ background: #dcd686;
104
+ width: 76%;
105
+ border: 0;
106
+ margin: 25px 0 10px;
107
+ box-sizing: border-box;
108
+ font-size: 15px;
109
+ height: 35px;
110
+ text-align: center;
111
+ }
112
+
113
+ .img {
114
+ background: url('https://images.unsplash.com/photo-1564013799919-ab600027ffc6?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
115
+ background-repeat: no-repeat;
116
+ background-size: auto;
117
+ background-size:100% 100%;
118
+ -webkit-filter: blur(5px);
119
+ -moz-filter: blur(5px);
120
+ -o-filter: blur(5px);
121
+ -ms-filter: blur(5px);
122
+ filter: blur(15px);
123
+ position: fixed;
124
+ width: 100%;
125
+ height: 100%;
126
+ top: 0;
127
+ left: 0;
128
+ z-index: -1;
129
+ }
130
+
131
+ body, html {
132
+ height: 100%;
133
+ }
tempCodeRunnerFile.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import pickle
3
+
4
+
5
+ __locations=None
6
+ __data_columns = None
7
+ __model =None
8
+
9
+ def get_location_names():
10
+ pass
11
+
12
+ def load_saved_artifacts():
13
+ print("loading saved artifacts...start")
14
+ global __data_columns
15
+ global __locations
16
+
17
+ with open("./artifacts/columns.json",'r') as f:
18
+ __data_columns=json.load(f)['data_columns']
19
+ __locations = __data_columns[3:]
20
+
21
+ with open("./artifacts/banglore_home_prices_model.pickle",'rb') as f:
22
+ __model == pickle.load(f)
23
+ print("loading saved artifacts ..done")
24
+
25
+ if __name__ =='__main__':
26
+ load_saved_artifacts()
27
+ print(get_location_names())
util.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+
4
+ import json
5
+ import pickle
6
+ import numpy as np
7
+
8
+ __locations = None
9
+ __data_columns = None
10
+ __model = None
11
+
12
+ def get_estimated_price(location, sqft, bhk, bath):
13
+ try:
14
+ loc_index = __data_columns.index(location.lower())
15
+ except ValueError:
16
+ loc_index = -1
17
+
18
+ x = np.zeros(len(__data_columns))
19
+ x[0] = sqft
20
+ x[1] = bath
21
+ x[2] = bhk
22
+ if loc_index >= 0:
23
+ x[loc_index] = 1
24
+
25
+ return round(__model.predict([x])[0], 2)
26
+
27
+ def get_location_names():
28
+ return __locations
29
+
30
+ def load_saved_artifacts():
31
+ print("loading saved artifacts...start")
32
+ global __data_columns
33
+ global __locations
34
+ global __model
35
+
36
+ with open("./artifacts/columns.json", 'r') as f:
37
+ __data_columns = json.load(f)['data_columns']
38
+ __locations = __data_columns[2:]
39
+
40
+ with open("./artifacts/banglore_home_prices_model.pickle", 'rb') as f:
41
+ __model = pickle.load(f)
42
+
43
+ print("loading saved artifacts...done")
44
+
45
+ if __name__ == '__main__':
46
+ load_saved_artifacts()
47
+ print(get_location_names())
48
+ print(get_estimated_price('1st Phase JP Nagar', 1000, 3, 3))