当前位置:网站首页>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))
边栏推荐
- One question per day - replace spaces
- 如何写Cover Letter?
- Halcon clolor_ pieces. Hedv: classifier_ Color recognition
- Esphone retrofits old fans
- Typescript hands-on tutorial, easy to understand
- Matlab tips (28) fuzzy comprehensive evaluation
- Old Wang's esp8266 and old Wu's ws2818 light strip
- [NAS1](2021CVPR)AttentiveNAS: Improving Neural Architecture Search via Attentive Sampling (未完)
- 实例005:三数排序 输入三个整数x,y,z,请把这三个数由小到大输出。
- Halcon blob analysis (ball.hdev)
猜你喜欢

L298N module use

Example 002: the bonus paid by the "individual income tax calculation" enterprise is based on the profit commission. When the profit (I) is less than or equal to 100000 yuan, the bonus can be increase

How to manage the performance of R & D team?

Example 006: Fibonacci series

【三层架构及JDBC总结】

Guess riddles (9)

IT冷知识(更新ing~)

Guess riddles (3)

Run菜单解析

猜谜语啦(4)
随机推荐
Arduino operation stm32
[daily training] 1200 Minimum absolute difference
How to write cover letter?
C语言标准函数scanf不安全的原因
猜谜语啦(10)
Halcon affine transformations to regions
One question per day - replace spaces
Tips 1: Web video playback code
Go dependency injection -- Google open source library wire
leetcode - 445. Add two numbers II
Guess riddles (10)
[three tier architecture and JDBC summary]
Yolov4 target detection backbone
猜谜语啦(7)
猜谜语啦(5)
EA introduction notes
Bit operation related operations
【日常训练】1200. 最小绝对差
Agile project management of project management
Guess riddles (9)