当前位置:网站首页>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))
边栏推荐
- Arrangement of some library files
- MATLAB小技巧(28)模糊綜合評價
- Business modeling | process of software model
- Example 009: pause output for one second
- [牛客网刷题 Day4] JZ55 二叉树的深度
- 每日一题——输入一个日期,输出它是该年的第几天
- [noi simulation] juice tree (tree DP)
- C language data type replacement
- [formation quotidienne - Tencent Selection 50] 557. Inverser le mot III dans la chaîne
- 轮子1:QCustomPlot初始化模板
猜你喜欢
STM32 lights up the 1.8-inch screen under Arduino IDE
Guess riddles (7)
实例007:copy 将一个列表的数据复制到另一个列表中。
Lori remote control LEGO motor
Lori remote control commissioning record
Typical low code apaas manufacturer cases
Arduino+a4988 control stepper motor
EA introduction notes
Example 006: Fibonacci series
Mathematical modeling: factor analysis
随机推荐
Xrosstools tool installation for X-Series
Guess riddles (10)
Infected Tree(树形dp)
Typical low code apaas manufacturer cases
猜谜语啦(9)
Tips 1: Web video playback code
2022.7.4-----leetcode. one thousand and two hundred
How to manage the performance of R & D team?
Guess riddles (11)
Latex improve
Business modeling | process of software model
Halcon: check of blob analysis_ Blister capsule detection
[matlab] matlab reads and writes Excel
One dimensional vector transpose point multiplication np dot
leetcode - 445. Add two numbers II
Daily question - input a date and output the day of the year
C language data type replacement
Sword finger offer 09 Implementing queues with two stacks
Old Wang's esp8266 and old Wu's ws2818 light strip
Bluebridge cup internet of things basic graphic tutorial - GPIO input key control LD5 on and off