【2023.8.8 学习日志】XGBoost

参考文献:Dataworkshop

XGBoost

全称
extreme gradient boost
regularized gradient boost
它用于监督学习问题,比如:分类、回归和排序。

详细代码,见jupyter文件xgboost_study2

  • 数据项描述
    datetime - hourly date + timestamp
    season - 1 = spring, 2 = summer, 3 = fall, 4 = winter
    holiday - whether the day is considered a holiday
    workingday - whether the day is neither a weekend nor holiday
    weather -
    1: Clear, Few clouds, Partly cloudy, Partly cloudy
    2: Mist + Cloudy, Mist + Broken clouds, Mist + Few clouds, Mist
    3: Light Snow, Light Rain + Thunderstorm + Scattered clouds, Light Rain + Scattered clouds
    4: Heavy Rain + Ice Pallets + Thunderstorm + Mist, Snow + Fog
    temp - temperature in Celsius
    atemp - “feels like” temperature in Celsius
    humidity - relative humidity
    windspeed - wind speed
    casual - number of non-registered user rentals initiated
    registered - number of registered user rentals initiated
    count - number of total rentals

下面简要记录文件的思路

内容:使用xgboost方法,根据特征数据预测count,registered,casual等响应变量,其中count=registed+casual
首先,从 datetime数据中提取出day,hour,dayofweek,weekend等信息,作为特征;
然后,

  • 尝试了以下几种方法去预测
  1. 使用 原数据的特征 直接预测 count;
  2. 使用 原数据的特征 间接预测count:具体地,首先使用XGBoost预测registedcasual,然后,二者加和得到count的预测值;
  3. 使用 原数据的特征 间接预测count:具体地,首先使用XGBoost预测log(count),然后,取对数得到count的预测值;
  4. 使用 原数据的特征 间接预测count:具体地,首先使用XGBoost预测log(registed+1)log(casual+1)(考虑到registered,casual可能取值为0),然后,二者取对数-1,再加和,得到count的预测值;
  5. 使用 原数据的特征的衍生特征(得到的数据集train_magic) 直接预测 count;
    比较上述所有方法的relative mean square log error.
  • 与其他方法作对比
    取“relative mean square log error”为性能指标(越小越好),比较XGBoost与随机森林、Adaboost,Bagging等其他机器学习集成方法的性能。

  • 调参
    除了网格搜索调参,这个项目还展示了贝叶斯优化方法搜索超参数的使用:具体地,调用python第三方库的使用hyperopt

remark:

小心过拟合

对比:
决策树虽然可解释性比较好,但是表现比较差;
集成学习方法:将弱分类器组成成强分类器,具体地,如随机森林、提升法.

日后再补……

你可能感兴趣的:(python数据处理恩仇录,学习)