当前位置:网站首页>Adaboost使用
Adaboost使用
2022-07-05 08:42:00 【python-码博士】
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
from sklearn.datasets import load_boston
from sklearn.ensemble import AdaBoostClassifier
from sklearn.ensemble import AdaBoostRegressor
# 加载数据
data = load_boston()
# print(data.data)
# print(data.target)
train_x, test_x, train_y, test_y = train_test_split(data.data, data.target, test_size=0.2)
regressor = AdaBoostRegressor()
regressor.fit(train_x,train_y)
pred_y = regressor.predict(test_x)
mse = mean_squared_error(test_y,pred_y)
# print('房价预测结果',pred_y)
print('均方误差 = ',round(mse,2))
# 决策树回归模型
from sklearn.tree import DecisionTreeRegressor
dec_regressor = DecisionTreeRegressor()
dec_regressor.fit(train_x,train_y)
pred_y = dec_regressor.predict(test_x)
mse = mean_squared_error(test_y,pred_y)
# print('房价预测结果',pred_y)
print('决策树均方误差 = ',round(mse,2))
# KNN回归模型
from sklearn.neighbors import KNeighborsRegressor
knn_regressor = KNeighborsRegressor()
knn_regressor.fit(train_x,train_y)
pred_y = knn_regressor.predict(test_x)
mse = mean_squared_error(test_y,pred_y)
# print('房价预测结果',pred_y)
print('KNN均方误差 = ',round(mse,2))
边栏推荐
- Go dependency injection -- Google open source library wire
- 猜谜语啦(11)
- Example 001: the number combination has four numbers: 1, 2, 3, 4. How many three digits can be formed that are different from each other and have no duplicate numbers? How many are each?
- 猜谜语啦(10)
- Esphone Feixun DC1 soft change access homeassstant
- 319. 灯泡开关
- Wheel 1:qcustomplot initialization template
- Halcon color recognition_ fuses. hdev:classify fuses by color
- MATLAB小技巧(28)模糊綜合評價
- MATLAB skills (28) Fuzzy Comprehensive Evaluation
猜你喜欢

实例007:copy 将一个列表的数据复制到另一个列表中。
![[three tier architecture]](/img/73/c4c75a453f03830e83cabb0762eb9b.png)
[three tier architecture]

Bluebridge cup internet of things competition basic graphic tutorial - clock selection

Low code platform | apaas platform construction analysis

猜谜语啦(8)
![[牛客网刷题 Day4] JZ35 复杂链表的复制](/img/bc/ce90bb3cb6f52605255f1d6d6894b0.png)
[牛客网刷题 Day4] JZ35 复杂链表的复制

Halcon: check of blob analysis_ Blister capsule detection

Daily question - input a date and output the day of the year

MATLAB小技巧(28)模糊综合评价

【三层架构及JDBC总结】
随机推荐
696. Count binary substring
Low code platform | apaas platform construction analysis
实例007:copy 将一个列表的数据复制到另一个列表中。
图解八道经典指针笔试题
猜谜语啦(2)
Guess riddles (8)
Five design details of linear regulator
Classification of plastic surgery: short in long long long
Digital analog 2: integer programming
Sword finger offer 05 Replace spaces
C language data type replacement
Old Wang's esp8266 and old Wu's ws2818 light strip
Bit operation related operations
Business modeling of software model | vision
Digital analog 1: linear programming
猜谜语啦(7)
GEO数据库中搜索数据
Several problems to be considered and solved in the design of multi tenant architecture
第十八章 使用工作队列管理器(一)
Basic number theory - factors