3
3
predict house price.
4
4
"""
5
5
6
- import pandas as pd
7
6
import matplotlib .pyplot as plt
7
+ import pandas as pd
8
8
from sklearn .datasets import load_boston
9
- from sklearn .metrics import mean_squared_error , r2_score
10
9
from sklearn .ensemble import GradientBoostingRegressor
10
+ from sklearn .metrics import mean_squared_error , r2_score
11
11
from sklearn .model_selection import train_test_split
12
12
13
13
@@ -42,10 +42,7 @@ def main():
42
42
training_score = model .score (X_train , y_train ).round (3 )
43
43
test_score = model .score (X_test , y_test ).round (3 )
44
44
print ("Training score of GradientBoosting is :" , training_score )
45
- print (
46
- "The test score of GradientBoosting is :" ,
47
- test_score
48
- )
45
+ print ("The test score of GradientBoosting is :" , test_score )
49
46
# Let us evaluation the model by finding the errors
50
47
y_pred = model .predict (X_test )
51
48
@@ -57,8 +54,7 @@ def main():
57
54
# So let's run the model against the test data
58
55
fig , ax = plt .subplots ()
59
56
ax .scatter (y_test , y_pred , edgecolors = (0 , 0 , 0 ))
60
- ax .plot ([y_test .min (), y_test .max ()],
61
- [y_test .min (), y_test .max ()], "k--" , lw = 4 )
57
+ ax .plot ([y_test .min (), y_test .max ()], [y_test .min (), y_test .max ()], "k--" , lw = 4 )
62
58
ax .set_xlabel ("Actual" )
63
59
ax .set_ylabel ("Predicted" )
64
60
ax .set_title ("Truth vs Predicted" )
0 commit comments