当前位置:网站首页>AdaBoost use
AdaBoost use
2022-07-05 08:50:00 【Python code doctor】
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
# Load data
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(' House price forecast ',pred_y)
print(' Mean square error = ',round(mse,2))
# Decision tree regression model
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(' House price forecast ',pred_y)
print(' Mean square error of decision tree = ',round(mse,2))
# KNN The regression model
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(' House price forecast ',pred_y)
print('KNN Mean square error = ',round(mse,2))
边栏推荐
猜你喜欢
[matlab] matlab reads and writes Excel
Hello everyone, welcome to my CSDN blog!
Halcon clolor_ pieces. Hedv: classifier_ Color recognition
Business modeling of software model | stakeholders
[牛客网刷题 Day4] JZ55 二叉树的深度
It cold knowledge (updating ing~)
EA introduction notes
Run菜单解析
猜谜语啦(11)
An enterprise information integration system
随机推荐
Array, date, string object method
Business modeling of software model | overview
图解网络:什么是网关负载均衡协议GLBP?
轮子1:QCustomPlot初始化模板
location search 属性获取登录用户名
C# LINQ源码分析之Count
Infix expression evaluation
TF coordinate transformation of common components of ros-9 ROS
Halcon wood texture recognition
C#【必备技能篇】ConfigurationManager 类的使用(文件App.config的使用)
ORACLE进阶(三)数据字典详解
Halcon clolor_ pieces. Hedv: classifier_ Color recognition
Cmder of win artifact
Wechat H5 official account to get openid climbing account
Halcon snap, get the area and position of coins
猜谜语啦(142)
Apaas platform of TOP10 abroad
How to manage the performance of R & D team?
Adaboost使用
kubeadm系列-02-kubelet的配置和启动