ボストン市の住宅価格を調べてみる
scikit-learnのデータを用いてボストン市の住宅価格を調べてみます。今回は回帰の分類となります。犯罪発生数や住居の平均部屋数などの10数個のデータより、ボストン市の住宅価格を求めます。全学習データは506件ですが、そのうち学習用に8割、残り2割を評価用に用います。
使用するデータ
全データ :506件 (学習用:404件)
属性データ:14件
CRIM | 人口 1 人当たりの犯罪発生数 |
ZN | 25,000 平方フィート以上の住居区画の占める割合 |
INDUS | 小売業以外の商業が占める面積の割合 |
CHAS | チャールズ川によるダミー変数 (1: 川の周辺, 0: それ以外) |
NOX | NOx の濃度 |
RM | 住居の平均部屋数 |
AGE | 1940 年より前に建てられた物件の割合 |
DIS | 5つのボストン市の雇用施設からの距離 |
RAD | 環状高速道路へのアクセスしやすさ |
TAX | $10,000 ドルあたりの不動産税率の総計 |
PTRATIO | 町毎の児童と教師の比率 |
B | 町毎の黒人 (Bk) の比率を次の式で表したもの。 1000(Bk – 0.63)^2 |
LSTAT | 給与の低い職業に従事する人口の割合 (%) |
MEDV | 所有者が占有している家屋の$ 1000単位の中央値 |
ソースコードの流れ
1、準備作業
2、学習用データの読み込み
3、学習用データの確認
4、学習用データの分割
5、学習
6、評価
ソースコード
ソースコードです。ソースコードの詳細は後で説明します。
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 |
#準備作業 from sklearn import linear_model from sklearn.datasets import load_boston from sklearn.model_selection import train_test_split #学習用データの読み込み data = load_boston() #学習用データの確認 print(data.DESCR) import pandas as pd names=pd.DataFrame(data=data.data,columns=data.feature_names) print(names) print(data.target) #学習用データの分割 X_train, X_test, y_train, y_test = train_test_split(data.data, data.target, test_size=0.2, random_state=0) X_train.shape X_test.shape #学習 clf = linear_model.LinearRegression() clf.fit(X_train,y_train) #評価 test=pd.DataFrame(data=X_test,columns=data.feature_names) print(test) print(clf.predict(X_test)) |
ソースコードの詳細
準備作業
1 2 3 |
from sklearn import linear_model from sklearn.datasets import load_boston from sklearn.model_selection import train_test_split |
scikit-learnからロンドンの住宅価格データをインポートします。今回は線形回帰モデルを利用するのでlinear_modelをインポートします。またデータを分割するためにtrain_test_splitについてもインポートします。
学習用データの読み込み
1 |
data = load_boston() |
学習用データの確認
1 |
print(data.DESCR) |
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 |
Boston House Prices dataset =========================== Notes ------ Data Set Characteristics: :Number of Instances: 506 :Number of Attributes: 13 numeric/categorical predictive :Median Value (attribute 14) is usually the target :Attribute Information (in order): - CRIM per capita crime rate by town - ZN proportion of residential land zoned for lots over 25,000 sq.ft. - INDUS proportion of non-retail business acres per town - CHAS Charles River dummy variable (= 1 if tract bounds river; 0 otherwise) - NOX nitric oxides concentration (parts per 10 million) - RM average number of rooms per dwelling - AGE proportion of owner-occupied units built prior to 1940 - DIS weighted distances to five Boston employment centres - RAD index of accessibility to radial highways - TAX full-value property-tax rate per $10,000 - PTRATIO pupil-teacher ratio by town - B 1000(Bk - 0.63)^2 where Bk is the proportion of blacks by town - LSTAT % lower status of the population - MEDV Median value of owner-occupied homes in $1000's :Missing Attribute Values: None :Creator: Harrison, D. and Rubinfeld, D.L. |
1 2 3 |
import pandas as pd names=pd.DataFrame(data=data.data,columns=data.feature_names) print(names) |
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 |
CRIM ZN INDUS CHAS NOX RM AGE DIS RAD TAX \ 0 0.00632 18.0 2.31 0.0 0.538 6.575 65.2 4.0900 1.0 296.0 1 0.02731 0.0 7.07 0.0 0.469 6.421 78.9 4.9671 2.0 242.0 2 0.02729 0.0 7.07 0.0 0.469 7.185 61.1 4.9671 2.0 242.0 3 0.03237 0.0 2.18 0.0 0.458 6.998 45.8 6.0622 3.0 222.0 4 0.06905 0.0 2.18 0.0 0.458 7.147 54.2 6.0622 3.0 222.0 5 0.02985 0.0 2.18 0.0 0.458 6.430 58.7 6.0622 3.0 222.0 6 0.08829 12.5 7.87 0.0 0.524 6.012 66.6 5.5605 5.0 311.0 7 0.14455 12.5 7.87 0.0 0.524 6.172 96.1 5.9505 5.0 311.0 8 0.21124 12.5 7.87 0.0 0.524 5.631 100.0 6.0821 5.0 311.0 9 0.17004 12.5 7.87 0.0 0.524 6.004 85.9 6.5921 5.0 311.0 10 0.22489 12.5 7.87 0.0 0.524 6.377 94.3 6.3467 5.0 311.0 11 0.11747 12.5 7.87 0.0 0.524 6.009 82.9 6.2267 5.0 311.0 12 0.09378 12.5 7.87 0.0 0.524 5.889 39.0 5.4509 5.0 311.0 13 0.62976 0.0 8.14 0.0 0.538 5.949 61.8 4.7075 4.0 307.0 14 0.63796 0.0 8.14 0.0 0.538 6.096 84.5 4.4619 4.0 307.0 15 0.62739 0.0 8.14 0.0 0.538 5.834 56.5 4.4986 4.0 307.0 16 1.05393 0.0 8.14 0.0 0.538 5.935 29.3 4.4986 4.0 307.0 17 0.78420 0.0 8.14 0.0 0.538 5.990 81.7 4.2579 4.0 307.0 18 0.80271 0.0 8.14 0.0 0.538 5.456 36.6 3.7965 4.0 307.0 19 0.72580 0.0 8.14 0.0 0.538 5.727 69.5 3.7965 4.0 307.0 20 1.25179 0.0 8.14 0.0 0.538 5.570 98.1 3.7979 4.0 307.0 21 0.85204 0.0 8.14 0.0 0.538 5.965 89.2 4.0123 4.0 307.0 22 1.23247 0.0 8.14 0.0 0.538 6.142 91.7 3.9769 4.0 307.0 23 0.98843 0.0 8.14 0.0 0.538 5.813 100.0 4.0952 4.0 307.0 24 0.75026 0.0 8.14 0.0 0.538 5.924 94.1 4.3996 4.0 307.0 25 0.84054 0.0 8.14 0.0 0.538 5.599 85.7 4.4546 4.0 307.0 26 0.67191 0.0 8.14 0.0 0.538 5.813 90.3 4.6820 4.0 307.0 27 0.95577 0.0 8.14 0.0 0.538 6.047 88.8 4.4534 4.0 307.0 28 0.77299 0.0 8.14 0.0 0.538 6.495 94.4 4.4547 4.0 307.0 29 1.00245 0.0 8.14 0.0 0.538 6.674 87.3 4.2390 4.0 307.0 .. ... ... ... ... ... ... ... ... ... ... 476 4.87141 0.0 18.10 0.0 0.614 6.484 93.6 2.3053 24.0 666.0 477 15.02340 0.0 18.10 0.0 0.614 5.304 97.3 2.1007 24.0 666.0 478 10.23300 0.0 18.10 0.0 0.614 6.185 96.7 2.1705 24.0 666.0 479 14.33370 0.0 18.10 0.0 0.614 6.229 88.0 1.9512 24.0 666.0 480 5.82401 0.0 18.10 0.0 0.532 6.242 64.7 3.4242 24.0 666.0 481 5.70818 0.0 18.10 0.0 0.532 6.750 74.9 3.3317 24.0 666.0 482 5.73116 0.0 18.10 0.0 0.532 7.061 77.0 3.4106 24.0 666.0 483 2.81838 0.0 18.10 0.0 0.532 5.762 40.3 4.0983 24.0 666.0 484 2.37857 0.0 18.10 0.0 0.583 5.871 41.9 3.7240 24.0 666.0 485 3.67367 0.0 18.10 0.0 0.583 6.312 51.9 3.9917 24.0 666.0 486 5.69175 0.0 18.10 0.0 0.583 6.114 79.8 3.5459 24.0 666.0 487 4.83567 0.0 18.10 0.0 0.583 5.905 53.2 3.1523 24.0 666.0 488 0.15086 0.0 27.74 0.0 0.609 5.454 92.7 1.8209 4.0 711.0 489 0.18337 0.0 27.74 0.0 0.609 5.414 98.3 1.7554 4.0 711.0 490 0.20746 0.0 27.74 0.0 0.609 5.093 98.0 1.8226 4.0 711.0 491 0.10574 0.0 27.74 0.0 0.609 5.983 98.8 1.8681 4.0 711.0 492 0.11132 0.0 27.74 0.0 0.609 5.983 83.5 2.1099 4.0 711.0 493 0.17331 0.0 9.69 0.0 0.585 5.707 54.0 2.3817 6.0 391.0 494 0.27957 0.0 9.69 0.0 0.585 5.926 42.6 2.3817 6.0 391.0 495 0.17899 0.0 9.69 0.0 0.585 5.670 28.8 2.7986 6.0 391.0 496 0.28960 0.0 9.69 0.0 0.585 5.390 72.9 2.7986 6.0 391.0 497 0.26838 0.0 9.69 0.0 0.585 5.794 70.6 2.8927 6.0 391.0 498 0.23912 0.0 9.69 0.0 0.585 6.019 65.3 2.4091 6.0 391.0 499 0.17783 0.0 9.69 0.0 0.585 5.569 73.5 2.3999 6.0 391.0 500 0.22438 0.0 9.69 0.0 0.585 6.027 79.7 2.4982 6.0 391.0 501 0.06263 0.0 11.93 0.0 0.573 6.593 69.1 2.4786 1.0 273.0 502 0.04527 0.0 11.93 0.0 0.573 6.120 76.7 2.2875 1.0 273.0 503 0.06076 0.0 11.93 0.0 0.573 6.976 91.0 2.1675 1.0 273.0 504 0.10959 0.0 11.93 0.0 0.573 6.794 89.3 2.3889 1.0 273.0 505 0.04741 0.0 11.93 0.0 0.573 6.030 80.8 2.5050 1.0 273.0 PTRATIO B LSTAT 0 15.3 396.90 4.98 1 17.8 396.90 9.14 2 17.8 392.83 4.03 3 18.7 394.63 2.94 4 18.7 396.90 5.33 5 18.7 394.12 5.21 6 15.2 395.60 12.43 7 15.2 396.90 19.15 8 15.2 386.63 29.93 9 15.2 386.71 17.10 10 15.2 392.52 20.45 11 15.2 396.90 13.27 12 15.2 390.50 15.71 13 21.0 396.90 8.26 14 21.0 380.02 10.26 15 21.0 395.62 8.47 16 21.0 386.85 6.58 17 21.0 386.75 14.67 18 21.0 288.99 11.69 19 21.0 390.95 11.28 20 21.0 376.57 21.02 21 21.0 392.53 13.83 22 21.0 396.90 18.72 23 21.0 394.54 19.88 24 21.0 394.33 16.30 25 21.0 303.42 16.51 26 21.0 376.88 14.81 27 21.0 306.38 17.28 28 21.0 387.94 12.80 29 21.0 380.23 11.98 .. ... ... ... 476 20.2 396.21 18.68 477 20.2 349.48 24.91 478 20.2 379.70 18.03 479 20.2 383.32 13.11 480 20.2 396.90 10.74 481 20.2 393.07 7.74 482 20.2 395.28 7.01 483 20.2 392.92 10.42 484 20.2 370.73 13.34 485 20.2 388.62 10.58 486 20.2 392.68 14.98 487 20.2 388.22 11.45 488 20.1 395.09 18.06 489 20.1 344.05 23.97 490 20.1 318.43 29.68 491 20.1 390.11 18.07 492 20.1 396.90 13.35 493 19.2 396.90 12.01 494 19.2 396.90 13.59 495 19.2 393.29 17.60 496 19.2 396.90 21.14 497 19.2 396.90 14.10 498 19.2 396.90 12.92 499 19.2 395.77 15.10 500 19.2 396.90 14.33 501 21.0 391.99 9.67 502 21.0 396.90 9.08 503 21.0 396.90 5.64 504 21.0 393.45 6.48 505 21.0 396.90 7.88 [506 rows x 13 columns] |
1 |
print(data.target) |
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 |
[ 24. 21.6 34.7 33.4 36.2 28.7 22.9 27.1 16.5 18.9 15. 18.9 21.7 20.4 18.2 19.9 23.1 17.5 20.2 18.2 13.6 19.6 15.2 14.5 15.6 13.9 16.6 14.8 18.4 21. 12.7 14.5 13.2 13.1 13.5 18.9 20. 21. 24.7 30.8 34.9 26.6 25.3 24.7 21.2 19.3 20. 16.6 14.4 19.4 19.7 20.5 25. 23.4 18.9 35.4 24.7 31.6 23.3 19.6 18.7 16. 22.2 25. 33. 23.5 19.4 22. 17.4 20.9 24.2 21.7 22.8 23.4 24.1 21.4 20. 20.8 21.2 20.3 28. 23.9 24.8 22.9 23.9 26.6 22.5 22.2 23.6 28.7 22.6 22. 22.9 25. 20.6 28.4 21.4 38.7 43.8 33.2 27.5 26.5 18.6 19.3 20.1 19.5 19.5 20.4 19.8 19.4 21.7 22.8 18.8 18.7 18.5 18.3 21.2 19.2 20.4 19.3 22. 20.3 20.5 17.3 18.8 21.4 15.7 16.2 18. 14.3 19.2 19.6 23. 18.4 15.6 18.1 17.4 17.1 13.3 17.8 14. 14.4 13.4 15.6 11.8 13.8 15.6 14.6 17.8 15.4 21.5 19.6 15.3 19.4 17. 15.6 13.1 41.3 24.3 23.3 27. 50. 50. 50. 22.7 25. 50. 23.8 23.8 22.3 17.4 19.1 23.1 23.6 22.6 29.4 23.2 24.6 29.9 37.2 39.8 36.2 37.9 32.5 26.4 29.6 50. 32. 29.8 34.9 37. 30.5 36.4 31.1 29.1 50. 33.3 30.3 34.6 34.9 32.9 24.1 42.3 48.5 50. 22.6 24.4 22.5 24.4 20. 21.7 19.3 22.4 28.1 23.7 25. 23.3 28.7 21.5 23. 26.7 21.7 27.5 30.1 44.8 50. 37.6 31.6 46.7 31.5 24.3 31.7 41.7 48.3 29. 24. 25.1 31.5 23.7 23.3 22. 20.1 22.2 23.7 17.6 18.5 24.3 20.5 24.5 26.2 24.4 24.8 29.6 42.8 21.9 20.9 44. 50. 36. 30.1 33.8 43.1 48.8 31. 36.5 22.8 30.7 50. 43.5 20.7 21.1 25.2 24.4 35.2 32.4 32. 33.2 33.1 29.1 35.1 45.4 35.4 46. 50. 32.2 22. 20.1 23.2 22.3 24.8 28.5 37.3 27.9 23.9 21.7 28.6 27.1 20.3 22.5 29. 24.8 22. 26.4 33.1 36.1 28.4 33.4 28.2 22.8 20.3 16.1 22.1 19.4 21.6 23.8 16.2 17.8 19.8 23.1 21. 23.8 23.1 20.4 18.5 25. 24.6 23. 22.2 19.3 22.6 19.8 17.1 19.4 22.2 20.7 21.1 19.5 18.5 20.6 19. 18.7 32.7 16.5 23.9 31.2 17.5 17.2 23.1 24.5 26.6 22.9 24.1 18.6 30.1 18.2 20.6 17.8 21.7 22.7 22.6 25. 19.9 20.8 16.8 21.9 27.5 21.9 23.1 50. 50. 50. 50. 50. 13.8 13.8 15. 13.9 13.3 13.1 10.2 10.4 10.9 11.3 12.3 8.8 7.2 10.5 7.4 10.2 11.5 15.1 23.2 9.7 13.8 12.7 13.1 12.5 8.5 5. 6.3 5.6 7.2 12.1 8.3 8.5 5. 11.9 27.9 17.2 27.5 15. 17.2 17.9 16.3 7. 7.2 7.5 10.4 8.8 8.4 16.7 14.2 20.8 13.4 11.7 8.3 10.2 10.9 11. 9.5 14.5 14.1 16.1 14.3 11.7 13.4 9.6 8.7 8.4 12.8 10.5 17.1 18.4 15.4 10.8 11.8 14.9 12.6 14.1 13. 13.4 15.2 16.1 17.8 14.9 14.1 12.7 13.5 14.9 20. 16.4 17.7 19.5 20.2 21.4 19.9 19. 19.1 19.1 20.1 19.9 19.6 23.2 29.8 13.8 13.3 16.7 12. 14.6 21.4 23. 23.7 25. 21.8 20.6 21.2 19.1 20.6 15.2 7. 8.1 13.6 20.1 21.8 24.5 23.1 19.7 18.3 21.2 17.5 16.8 22.4 20.6 23.9 22. 11.9] |
学習用データの分割
1 |
X_train, X_test, y_train, y_test = train_test_split(data.data, data.target, test_size=0.2, random_state=0) |
1 |
X_train.shape |
1 |
(404, 13) |
1 |
X_test.shape |
1 |
(102, 13) |
学習
1 2 |
clf = linear_model.LinearRegression() clf.fit(X_train,y_train) |
評価
1 2 |
test=pd.DataFrame(data=X_test,columns=data.feature_names) print(test) |
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 |
CRIM ZN INDUS CHAS NOX RM AGE DIS RAD TAX \ 0 0.06724 0.0 3.24 0.0 0.460 6.333 17.2 5.2146 4.0 430.0 1 9.23230 0.0 18.10 0.0 0.631 6.216 100.0 1.1691 24.0 666.0 2 0.11425 0.0 13.89 1.0 0.550 6.373 92.4 3.3633 5.0 276.0 3 24.80170 0.0 18.10 0.0 0.693 5.349 96.0 1.7028 24.0 666.0 4 0.05646 0.0 12.83 0.0 0.437 6.232 53.7 5.0141 5.0 398.0 5 0.62739 0.0 8.14 0.0 0.538 5.834 56.5 4.4986 4.0 307.0 6 4.83567 0.0 18.10 0.0 0.583 5.905 53.2 3.1523 24.0 666.0 7 0.06151 0.0 5.19 0.0 0.515 5.968 58.5 4.8122 5.0 224.0 8 2.63548 0.0 9.90 0.0 0.544 4.973 37.8 2.5194 4.0 304.0 9 0.22876 0.0 8.56 0.0 0.520 6.405 85.4 2.7147 5.0 384.0 10 73.53410 0.0 18.10 0.0 0.679 5.957 100.0 1.8026 24.0 666.0 11 14.05070 0.0 18.10 0.0 0.597 6.657 100.0 1.5275 24.0 666.0 12 6.28807 0.0 18.10 0.0 0.740 6.341 96.4 2.0720 24.0 666.0 13 24.39380 0.0 18.10 0.0 0.700 4.652 100.0 1.4672 24.0 666.0 14 1.83377 0.0 19.58 1.0 0.605 7.802 98.2 2.0407 5.0 403.0 15 0.05561 70.0 2.24 0.0 0.400 7.041 10.0 7.8278 5.0 358.0 16 5.82401 0.0 18.10 0.0 0.532 6.242 64.7 3.4242 24.0 666.0 17 0.04011 80.0 1.52 0.0 0.404 7.287 34.1 7.3090 2.0 329.0 18 0.06664 0.0 4.05 0.0 0.510 6.546 33.1 3.1323 5.0 296.0 19 0.08014 0.0 5.96 0.0 0.499 5.850 41.5 3.9342 5.0 279.0 20 0.16760 0.0 7.38 0.0 0.493 6.426 52.3 4.5404 5.0 287.0 21 2.31390 0.0 19.58 0.0 0.605 5.880 97.3 2.3887 5.0 403.0 22 0.13117 0.0 8.56 0.0 0.520 6.127 85.2 2.1224 5.0 384.0 23 0.07978 40.0 6.41 0.0 0.447 6.482 32.1 4.1403 4.0 254.0 24 0.17142 0.0 6.91 0.0 0.448 5.682 33.8 5.1004 3.0 233.0 25 13.52220 0.0 18.10 0.0 0.631 3.863 100.0 1.5106 24.0 666.0 26 0.85204 0.0 8.14 0.0 0.538 5.965 89.2 4.0123 4.0 307.0 27 2.14918 0.0 19.58 0.0 0.871 5.709 98.5 1.6232 5.0 403.0 28 0.12083 0.0 2.89 0.0 0.445 8.069 76.0 3.4952 2.0 276.0 29 0.22212 0.0 10.01 0.0 0.547 6.092 95.4 2.5480 6.0 432.0 .. ... ... ... ... ... ... ... ... ... ... 72 0.03584 80.0 3.37 0.0 0.398 6.290 17.8 6.6115 4.0 337.0 73 0.03049 55.0 3.78 0.0 0.484 6.874 28.1 6.4654 5.0 370.0 74 5.70818 0.0 18.10 0.0 0.532 6.750 74.9 3.3317 24.0 666.0 75 22.59710 0.0 18.10 0.0 0.700 5.000 89.5 1.5184 24.0 666.0 76 0.33147 0.0 6.20 0.0 0.507 8.247 70.4 3.6519 8.0 307.0 77 0.22969 0.0 10.59 0.0 0.489 6.326 52.5 4.3549 4.0 277.0 78 0.04684 0.0 3.41 0.0 0.489 6.417 66.1 3.0923 2.0 270.0 79 0.26838 0.0 9.69 0.0 0.585 5.794 70.6 2.8927 6.0 391.0 80 0.09252 30.0 4.93 0.0 0.428 6.606 42.2 6.1899 6.0 300.0 81 0.35233 0.0 21.89 0.0 0.624 6.454 98.4 1.8498 4.0 437.0 82 11.95110 0.0 18.10 0.0 0.659 5.608 100.0 1.2852 24.0 666.0 83 0.31533 0.0 6.20 0.0 0.504 8.266 78.3 2.8944 8.0 307.0 84 0.52693 0.0 6.20 0.0 0.504 8.725 83.0 2.8944 8.0 307.0 85 0.30347 0.0 7.38 0.0 0.493 6.312 28.9 5.4159 5.0 287.0 86 0.11504 0.0 2.89 0.0 0.445 6.163 69.6 3.4952 2.0 276.0 87 12.24720 0.0 18.10 0.0 0.584 5.837 59.7 1.9976 24.0 666.0 88 1.42502 0.0 19.58 0.0 0.871 6.510 100.0 1.7659 5.0 403.0 89 5.29305 0.0 18.10 0.0 0.700 6.051 82.5 2.1678 24.0 666.0 90 0.01360 75.0 4.00 0.0 0.410 5.888 47.6 7.3197 3.0 469.0 91 11.16040 0.0 18.10 0.0 0.740 6.629 94.6 2.1247 24.0 666.0 92 0.04819 80.0 3.64 0.0 0.392 6.108 32.0 9.2203 1.0 315.0 93 0.04417 70.0 2.24 0.0 0.400 6.871 47.4 7.8278 5.0 358.0 94 0.04741 0.0 11.93 0.0 0.573 6.030 80.8 2.5050 1.0 273.0 95 0.33983 22.0 5.86 0.0 0.431 6.108 34.9 8.0555 7.0 330.0 96 18.49820 0.0 18.10 0.0 0.668 4.138 100.0 1.1370 24.0 666.0 97 0.02055 85.0 0.74 0.0 0.410 6.383 35.7 9.1876 2.0 313.0 98 4.75237 0.0 18.10 0.0 0.713 6.525 86.5 2.4358 24.0 666.0 99 0.14932 25.0 5.13 0.0 0.453 5.741 66.2 7.2254 8.0 284.0 100 0.14052 0.0 10.59 0.0 0.489 6.375 32.3 3.9454 4.0 277.0 101 0.12802 0.0 8.56 0.0 0.520 6.474 97.1 2.4329 5.0 384.0 PTRATIO B LSTAT 0 16.9 375.21 7.34 1 20.2 366.15 9.53 2 16.4 393.74 10.50 3 20.2 396.90 19.77 4 18.7 386.40 12.34 5 21.0 395.62 8.47 6 20.2 388.22 11.45 7 20.2 396.90 9.29 8 18.4 350.45 12.64 9 20.9 70.80 10.63 10 20.2 16.45 20.62 11 20.2 35.05 21.22 12 20.2 318.01 17.79 13 20.2 396.90 28.28 14 14.7 389.61 1.92 15 14.8 371.58 4.74 16 20.2 396.90 10.74 17 12.6 396.90 4.08 18 16.6 390.96 5.33 19 19.2 396.90 8.77 20 19.6 396.90 7.20 21 14.7 348.13 12.03 22 20.9 387.69 14.09 23 17.6 396.90 7.19 24 17.9 396.90 10.21 25 20.2 131.42 13.33 26 21.0 392.53 13.83 27 14.7 261.95 15.79 28 18.0 396.90 4.21 29 17.8 396.90 17.09 .. ... ... ... 72 16.1 396.90 4.67 73 17.6 387.97 4.61 74 20.2 393.07 7.74 75 20.2 396.90 31.99 76 17.4 378.95 3.95 77 18.6 394.87 10.97 78 17.8 392.18 8.81 79 19.2 396.90 14.10 80 16.6 383.78 7.37 81 21.2 394.08 14.59 82 20.2 332.09 12.13 83 17.4 385.05 4.14 84 17.4 382.00 4.63 85 19.6 396.90 6.15 86 18.0 391.83 11.34 87 20.2 24.65 15.69 88 14.7 364.31 7.39 89 20.2 378.38 18.76 90 21.1 396.90 14.80 91 20.2 109.85 23.27 92 16.4 392.89 6.57 93 14.8 390.86 6.07 94 21.0 396.90 7.88 95 19.1 390.18 9.16 96 20.2 396.90 37.97 97 17.3 396.90 5.77 98 20.2 50.92 18.13 99 19.7 395.11 13.15 100 18.6 385.81 9.38 101 20.9 395.24 12.27 [102 rows x 13 columns] |
1 |
print(clf.predict(X_test)) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[ 24.89012999 23.72488246 29.37213304 12.14010251 21.4468654 19.28645278 20.4963729 21.361896 18.90187947 19.89240314 5.14887233 16.34684109 17.06012498 5.60903056 40.0046213 32.49427341 22.46081666 36.85586503 30.86579318 23.15478003 24.77656022 24.67996181 20.59378189 30.35624965 22.42640026 10.22873821 17.64814177 18.26038473 35.5307741 20.96125278 18.3033109 17.78873855 19.96636449 24.06489726 29.10613394 19.26824306 11.16302351 24.57838036 17.55060167 15.4775377 26.21443038 20.86590644 22.31521746 15.60756369 23.00542683 25.17799668 20.1224094 22.89324789 10.03421509 24.28328238 20.90741758 17.34683545 24.52357489 29.93973985 13.41445583 21.72648406 20.79476218 15.49582771 14.00076106 22.18730294 17.7328223 21.58942 32.9052782 31.11274689 17.74095677 32.76792649 18.69693213 19.78338311 19.00577539 22.90129865 22.96388226 24.0302524 30.73473079 28.82862993 25.90146307 5.23941707 36.71283639 23.77448475 27.27134636 19.29485488 28.62428371 19.17839754 18.97551342 37.81623842 39.20883283 23.71409982 24.93482847 15.8506365 26.09648351 16.67799923 15.83315513 13.0653193 24.72280719 31.25443519 22.17141029 20.25167573 0.59633964 25.44521598 15.52175986 17.93778172 25.30617772 22.37221992] |