ML之RF&DT:利用RF(RFR)、DT(DTR)两种算法实现对boston(波士顿房价)数据集进行训练并预测
ML之RF&DT:利用RF(RFR)、DT(DTR)两种算法实现对boston(波士顿房价)数据集进行训练并预测
输出结果
1、两种算法的预测结果
2、回归树的可视化
实现代码
boston_house = load_boston()
boston_feature_name = boston_house.feature_names
boston_features = boston_house.data
boston_target = boston_house.target
print('boston_feature_name','\n',boston_feature_name)
print('boston_features[:5,:]','\n',boston_features[:5,:])
print('boston_target','\n',boston_target[:10])
RFR = RandomForestRegressor(n_estimators=15)
RFR = RFR.fit(boston_features, boston_target)
RFR_result=RFR.predict(boston_features)
print('RFR_result','\n',RFR_result[:10])
赞 (0)