当前位置:网站首页>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))
边栏推荐
- Is the security account given by Yixue school safe? Where can I open an account
- An enterprise information integration system
- 实例005:三数排序 输入三个整数x,y,z,请把这三个数由小到大输出。
- Yolov4 target detection backbone
- Halcon: check of blob analysis_ Blister capsule detection
- STM32 summary (HAL Library) - DHT11 temperature sensor (intelligent safety assisted driving system)
- [daily training -- Tencent selected 50] 557 Reverse word III in string
- Matlab tips (28) fuzzy comprehensive evaluation
- 287. Looking for repeats - fast and slow pointer
- Halcon clolor_ pieces. Hedv: classifier_ Color recognition
猜你喜欢

Arduino operation stm32

Business modeling of software model | vision
![[matlab] matlab reads and writes Excel](/img/80/78e4c7fcd27473526e480d4b930e2c.jpg)
[matlab] matlab reads and writes Excel

Guess riddles (10)

Bluebridge cup internet of things basic graphic tutorial - GPIO input key control LD5 on and off

Guess riddles (3)

实例003:完全平方数 一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?

猜谜语啦(5)

Guess riddles (142)

Shift operation of complement
随机推荐
Numpy pit: after the addition of dimension (n, 1) and dimension (n,) array, the dimension becomes (n, n)
【日常訓練--騰訊精選50】557. 反轉字符串中的單詞 III
ABC#237 C
696. Count binary substring
Guess riddles (6)
UE pixel stream, come to a "diet pill"!
Digital analog 2: integer programming
【日常训练--腾讯精选50】557. 反转字符串中的单词 III
实例001:数字组合 有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
leetcode - 445. Add two numbers II
Guess riddles (3)
Halcon blob analysis (ball.hdev)
How to write cover letter?
IT冷知识(更新ing~)
MATLAB小技巧(28)模糊綜合評價
Redis实现高性能的全文搜索引擎---RediSearch
Typical low code apaas manufacturer cases
[牛客网刷题 Day4] JZ35 复杂链表的复制
Example 004: for the day of the day, enter a day of a month of a year to judge the day of the year?
Agile project management of project management