91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 195KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-22
  • 語言: 其他
  • 標簽: 機器學習??

資源簡介

在這個項目中,你將利用馬薩諸塞州波士頓郊區的房屋信息數據訓練和測試一個模型,并對模型的性能和預測能力進行測試。通過該數據訓練后的好的模型可以被用來對房屋做特定預測—尤其是對房屋的價值。對于房地產經紀等人的日常工作來說,這樣的預測模型被證明非常有價值。

資源截圖

代碼片段和文件信息

###########################################
#?Suppress?matplotlib?user?warnings
#?Necessary?for?newer?version?of?matplotlib
import?warnings
warnings.filterwarnings(“ignore“?category?=?UserWarning?module?=?“matplotlib“)
###########################################

import?matplotlib.pyplot?as?pl
import?numpy?as?np
import?sklearn.learning_curve?as?curves
from?sklearn.tree?import?DecisionTreeRegressor
from?sklearn.cross_validation?import?ShuffleSplit?train_test_split

def?ModelLearning(X?y):
????“““?Calculates?the?performance?of?several?models?with?varying?sizes?of?training?data.
????????The?learning?and?testing?scores?for?each?model?are?then?plotted.?“““
????
????#?Create?10?cross-validation?sets?for?training?and?testing
????cv?=?ShuffleSplit(X.shape[0]?n_iter?=?10?test_size?=?0.2?random_state?=?0)

????#?Generate?the?training?set?sizes?increasing?by?50
????train_sizes?=?np.rint(np.linspace(1?X.shape[0]*0.8?-?1?9)).astype(int)

????#?Create?the?figure?window
????fig?=?pl.figure(figsize=(107))

????#?Create?three?different?models?based?on?max_depth
????for?k?depth?in?enumerate([13610]):
????????
????????#?Create?a?Decision?tree?regressor?at?max_depth?=?depth
????????regressor?=?DecisionTreeRegressor(max_depth?=?depth)

????????#?Calculate?the?training?and?testing?scores
????????sizes?train_scores?test_scores?=?curves.learning_curve(regressor?X?y?\
????????????cv?=?cv?train_sizes?=?train_sizes?scoring?=?‘r2‘)
????????
????????#?Find?the?mean?and?standard?deviation?for?smoothing
????????train_std?=?np.std(train_scores?axis?=?1)
????????train_mean?=?np.mean(train_scores?axis?=?1)
????????test_std?=?np.std(test_scores?axis?=?1)
????????test_mean?=?np.mean(test_scores?axis?=?1)

????????#?Subplot?the?learning?curve?
????????ax?=?fig.add_subplot(2?2?k+1)
????????ax.plot(sizes?train_mean?‘o-‘?color?=?‘r‘?label?=?‘Training?Score‘)
????????ax.plot(sizes?test_mean?‘o-‘?color?=?‘g‘?label?=?‘Testing?Score‘)
????????ax.fill_between(sizes?train_mean?-?train_std?\
????????????train_mean?+?train_std?alpha?=?0.15?color?=?‘r‘)
????????ax.fill_between(sizes?test_mean?-?test_std?\
????????????test_mean?+?test_std?alpha?=?0.15?color?=?‘g‘)
????????
????????#?Labels
????????ax.set_title(‘max_depth?=?%s‘%(depth))
????????ax.set_xlabel(‘Number?of?Training?Points‘)
????????ax.set_ylabel(‘Score‘)
????????ax.set_xlim([0?X.shape[0]*0.8])
????????ax.set_ylim([-0.05?1.05])
????
????#?Visual?aesthetics
????ax.legend(bbox_to_anchor=(1.05?2.05)?loc=‘lower?left‘?borderaxespad?=?0.)
????fig.suptitle(‘Decision?Tree?Regressor?Learning?Performances‘?fontsize?=?16?y?=?1.03)
????fig.tight_layout()
????fig.show()


def?ModelComplexity(X?y):
????“““?Calculates?the?performance?of?the?model?as?model?complexity?increases.
????????The?learning?and?testing?errors?rates?are?then?plotted.?“““
????
????#?Create?10?cross-validation?sets?for?training?and?testing
????cv?=?ShuffleSplit(X.shape[0]?n_iter?=?10?test_size?=?0.2?random_state?=?0)

????#?V

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-01-08?15:11??boston_housing\
?????目錄???????????0??2018-01-07?21:16??boston_housing\.ipynb_checkpoints\
?????文件??????146801??2018-01-08?13:51??boston_housing\.ipynb_checkpoints\boston_housing-checkpoint.ipynb
?????文件??????143652??2018-01-08?15:11??boston_housing\boston_housing.ipynb
?????文件???????12435??2016-08-12?03:37??boston_housing\housing.csv
?????文件????????1768??2016-08-12?03:37??boston_housing\README.md
?????文件????????4882??2018-01-07?21:24??boston_housing\visuals.py
?????目錄???????????0??2018-01-07?21:24??boston_housing\__pycache__\
?????文件????????3672??2018-01-07?21:24??boston_housing\__pycache__\visuals.cpython-36.pyc

評論

共有 條評論