当前位置:   article > 正文

回归模型使用实战xgb.XGBRegressor

xgb.xgbregressor
  1. from sklearn.datasets import load_boston
  2. from sklearn.model_selection import train_test_split
  3. import xgboost as xgb,numpy as np
  4. from sklearn.metrics import mean_squared_error
  5. boston = load_boston()
  6. X = boston.data # 特征值
  7. y = boston.target # 目标值
  8. # 划分数据集,80% 训练数据和 20% 测试数据
  9. X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

 

  1. print(X_train.shape)
  2. print(X_train)

 

(404, 13)
[[2.59406e+01 0.00000e+00 1.81000e+01 ... 2.02000e+01 1.27360e+02
  2.66400e+01]
 [1.88360e-01 0.00000e+00 6.91000e+00 ... 1.79000e+01 3.96900e+02
  1.41500e+01]
 [8.87300e-02 2.10000e+01 5.64000e+00 ... 1.68000e+01 3.95560e+02
  1.34500e+01]
 ...
 [3.73800e-02 0.00000e+00 5.19000e+00 ... 2.02000e+01 3.89400e+02
  6.75000e+00]
 [1.40520e-01 0.00000e+00 1.05900e+01 ... 1.86000e+01
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/552283
推荐阅读
相关标签
  

闽ICP备14008679号