-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_predictions.py
executable file
·92 lines (83 loc) · 2.57 KB
/
make_predictions.py
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
from sklearn.externals import joblib
# Load the model we trained previously
model = joblib.load('trained_house_classifier_model.pkl')
# For the house we want to value, we need to provide the features in the exact same
# arrangement as our training data set.
house_to_value = [
# House features
2006, # year_built
1, # stories
4, # num_bedrooms
3, # full_bathrooms
0, # half_bathrooms
2200, # livable_sqft
2350, # total_sqft
0, # garage_sqft
0, # carport_sqft
True, # has_fireplace
False, # has_pool
True, # has_central_heating
True, # has_central_cooling
# Garage type: Choose only one
0, # attached
0, # detached
1, # none
# City: Choose only one
0, # Amystad
1, # Brownport
0, # Chadstad
0, # Clarkberg
0, # Coletown
0, # Davidfort
0, # Davidtown
0, # East Amychester
0, # East Janiceville
0, # East Justin
0, # East Lucas
0, # Fosterberg
0, # Hallfort
0, # Jeffreyhaven
0, # Jenniferberg
0, # Joshuafurt
0, # Julieberg
0, # Justinport
0, # Lake Carolyn
0, # Lake Christinaport
0, # Lake Dariusborough
0, # Lake Jack
0, # Lake Jennifer
0, # Leahview
0, # Lewishaven
0, # Martinezfort
0, # Morrisport
0, # New Michele
0, # New Robinton
0, # North Erinville
0, # Port Adamtown
0, # Port Andrealand
0, # Port Daniel
0, # Port Jonathanborough
0, # Richardport
0, # Rickytown
0, # Scottberg
0, # South Anthony
0, # South Stevenfurt
0, # Toddshire
0, # Wendybury
0, # West Ann
0, # West Brittanyview
0, # West Gerald
0, # West Gregoryview
0, # West Lydia
0 # West Terrence
]
# scikit-learn assumes you want to predict the values for lots of houses at once, so it expects an array.
# We just want to look at a single house, so it will be the only item in our array.
homes_to_value = [
house_to_value
]
# Run the model and make a prediction for each house in the homes_to_value array
predicted_home_values = model.predict(homes_to_value)
# Since we are only predicting the price of one house, just look at the first prediction returned
predicted_value = predicted_home_values[0]
print("This house has an estimated value of ${:,.2f}".format(predicted_value))