当前位置:网站首页>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))
边栏推荐
- 轮子1:QCustomPlot初始化模板
- Arduino operation stm32
- Arduino burning program and Arduino burning bootloader
- Affected tree (tree DP)
- Classification of plastic surgery: short in long long long
- 实例001:数字组合 有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
- 剑指 Offer 09. 用两个栈实现队列
- Program error record 1:valueerror: invalid literal for int() with base 10: '2.3‘
- Redis实现高性能的全文搜索引擎---RediSearch
- Meizu Bluetooth remote control temperature and humidity access homeassistant
猜你喜欢

IT冷知识(更新ing~)

Arduino burning program and Arduino burning bootloader

EA introduction notes

Guess riddles (10)

Halcon blob analysis (ball.hdev)

Halcon affine transformations to regions

Numpy pit: after the addition of dimension (n, 1) and dimension (n,) array, the dimension becomes (n, n)

Typescript hands-on tutorial, easy to understand

Example 004: for the day of the day, enter a day of a month of a year to judge the day of the year?

Numpy 小坑:维度 (n, 1) 和 维度 (n, ) 数组相加运算后维度变为 (n, n)
随机推荐
Guess riddles (11)
Chapter 18 using work queue manager (1)
2020-05-21
TypeScript手把手教程,简单易懂
Business modeling of software model | vision
Guess riddles (5)
[formation quotidienne - Tencent Selection 50] 557. Inverser le mot III dans la chaîne
猜谜语啦(142)
Reasons for the insecurity of C language standard function scanf
Business modeling of software model | stakeholders
猜谜语啦(4)
Bluebridge cup internet of things basic graphic tutorial - GPIO input key control LD5 on and off
[three tier architecture]
[matlab] matlab reads and writes Excel
ABC#237 C
[nas1] (2021cvpr) attentivenas: improving neural architecture search via attentive sampling (unfinished)
UE pixel stream, come to a "diet pill"!
实例004:这天第几天 输入某年某月某日,判断这一天是这一年的第几天?
Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?
暑假第一周