Multi-task LightGBM安装

Multi-task LightGBM库(lightgbmmt)安装

Multi-task LightGBM库(lightgbmmt)安装

本文提供多任务机器学习 (MTML)库中的MT-LightGBM安装方式。

之前使用了阿里大佬开源的树模型多任务机器学习库,基于LightGBM改造的lightgbmmt包,不论是在Mac还是windows上安装都十分费劲,主要是C++相关编译非常麻烦。
最后索性在Docker上安装成功了,现把相关的依赖推送在镜像仓库,供有同样需求的小伙伴直接拉取使用。
镜像名:gianthb/mtgbm
使用 docker pull gianthb/mtgbm:latest
即可拉取成功
原代码仓连接

:\pycharm\代码\.venv\Scripts\python.exe E:\pycharm\代码\代码调试9.py ⚠️ skopt未安装!贝叶斯优化不可用。请运行: pip install scikit-optimize ⚠️ shap未安装!SHAP可解释性不可用。请运行: pip install shap ========================================================================================== 【增强版机器学习分析系统】 基于张继权教授‘四因子理论’:致灾因子、孕灾环境、承灾体、防灾减灾能力 功能:自动区分分类/回归 + 多模型 + 缺失值修复 + 结果可视化 ========================================================================================== 📁 数据路径: E:\pycharm\meta\整合数据.csv 🎯 目标变量: PFOA 1. 加载数据... ❌ 编码 'utf-8' 解码失败,尝试下一个... ✅ 数据加载成功!编码: gbk | 形状: (137, 111) 🧹 已删除 96 个 'Unnamed' 列。 2.1 应用张继权教授四因子理论进行特征分组... 【四因子特征分组表】 风险因子 特征数量 特征列表 致灾因子 2 PFBA;PFOS 孕灾环境 2 经度;纬度 承灾体 2 城市;作物类型 防灾减灾能力 0 无 其他 8 样本编号;PFPeA;PFHxA;PFHpA;PFNA;PFDA;PFBS;PFHxS 2. 探索性数据分析(EDA)... 统计项 值 样本数 137 特征数 14 目标变量 PFOA 唯一值数 111 🔍 检测到连续型目标变量 'PFOA'(唯一值占比0.81),切换为回归任务。 3. 数据预处理与标准化... 🧹 删除 12 行因 'PFOA' 缺失 (NaN) 训练集: (100, 14), 测试集: (25, 14) 4. 初始化 回归 模型... ✅ 已加载 5 个回归模型 5. 模型训练与评分评估... ➜ 训练 线性回归... ➜ 训练 随机森林回归... ➜ 训练 XGBoost回归... ➜ 训练 LightGBM回归... [LightGBM] [Info] Auto-choosing row-wise multi-threading, the overhead of testing was 0.000047 seconds. You can set `force_row_wise=true` to remove the overhead. And if memory is not enough, you can set `force_col_wise=true`. [LightGBM] [Info] Total Bins 263 [LightGBM] [Info] Number of data points in the train set: 100, number of used features: 11 [LightGBM] [Info] Start training from score 2.342153 [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf File "E:\pycharm\代码\.venv\lib\site-packages\joblib\externals\loky\backend\context.py", line 257, in _count_physical_cores cpu_info = subprocess.run( File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 493, in run with Popen(*popenargs, **kwargs) as process: File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 858, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1311, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf ➜ 训练 CatBoost回归... 【回归模型性能对比表】 r2 mse rmse 模型 XGBoost回归 0.878321 0.074486 0.272921 随机森林回归 0.74793 0.154304 0.392816 CatBoost回归 0.416065 0.357455 0.597875 线性回归 -13.316012 8.763525 2.960325 LightGBM回归 -28.162328 17.851676 4.225124 🏆 最佳模型: XGBoost回归 (R²: 0.8783) ========================================================================================== ✅ 完整机器学习分析流程执行完毕! ========================================================================================== 进程已结束,退出代码为 0 继续解决报错,代码中加入相关性分析等,生成更多的图
11-12
E:\pycharm\代码\.venv\Scripts\python.exe E:\pycharm\代码\代码调试9.py ⚠️ skopt未安装!贝叶斯优化不可用。请运行: pip install scikit-optimize ⚠️ shap未安装!SHAP可解释性不可用。请运行: pip install shap ========================================================================================== 【增强版机器学习分析系统】 基于张继权教授‘四因子理论’:致灾因子、孕灾环境、承灾体、防灾减灾能力 功能:自动区分分类/回归 + 多模型 + PCA降维 + 贝叶斯超参优化 + SHAP可解释性 + 中文可视化 ========================================================================================== 📁 数据路径: E:\pycharm\meta\整合数据.csv 🎯 目标变量: PFOA 1. 加载数据... ❌ 编码 'utf-8' 解码失败,尝试下一个... ✅ 数据加载成功!编码: gbk | 形状: (137, 111) 🧹 已删除 96 个 'Unnamed' 列。 2.1 应用张继权教授四因子理论进行特征分组... 【四因子特征分组表】 风险因子 特征数量 特征列表 致灾因子 2 PFBA;PFOS 孕灾环境 2 经度;纬度 承灾体 2 城市;作物类型 防灾减灾能力 0 无 其他 8 样本编号;PFPeA;PFHxA;PFHpA;PFNA;PFDA;PFBS;PFHxS 2. 探索性数据分析(EDA)... 数据基本信息: 统计项 值 样本数 137 特征数 14 目标变量 PFOA 类别数/唯一值 111 🔍 检测到目标变量 'PFOA' 为连续型变量(唯一值占比0.81),切换为回归任务。 3. 数据预处理与标准化... 🧹 检测到 21 个异常值,已限制在合理范围。 训练集: (109, 14), 测试集: (28, 14) 4. 初始化 回归 模型... ✅ 已加载 10 个回归模型 5. 模型训练与评分评估... ➜ 训练 线性回归... ❌ 线性回归 失败: Input y contains NaN. ➜ 训练 决策树回归... ❌ 决策树回归 失败: Input y contains NaN. ➜ 训练 随机森林回归... ❌ 随机森林回归 失败: Input y contains NaN. ➜ 训练 梯度提升回归... ❌ 梯度提升回归 失败: Input y contains NaN. ➜ 训练 XGBoost回归... ❌ XGBoost回归 失败: [16:00:55] C:\buildkite-agent\builds\buildkite-windows-cpu-autoscaling-group-i-08cbc0333d8d4aae1-1\xgboost\xgboost-ci-windows\src\data\data.cc:514: Check failed: valid: Label contains NaN, infinity or a value too large. ➜ 训练 LightGBM回归... File "E:\pycharm\代码\.venv\lib\site-packages\joblib\externals\loky\backend\context.py", line 257, in _count_physical_cores cpu_info = subprocess.run( File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 493, in run with Popen(*popenargs, **kwargs) as process: File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 858, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1311, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, [LightGBM] [Info] Auto-choosing col-wise multi-threading, the overhead of testing was 0.000098 seconds. You can set `force_col_wise=true` to remove the overhead. [LightGBM] [Info] Total Bins 270 [LightGBM] [Info] Number of data points in the train set: 109, number of used features: 11 [LightGBM] [Info] Start training from score 0.152646 [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf ❌ LightGBM回归 失败: Input contains NaN. ➜ 训练 KNN回归... ❌ KNN回归 失败: Input y contains NaN. ➜ 训练 SVR... ❌ SVR 失败: Input y contains NaN. ➜ 训练 MLP回归... ❌ MLP回归 失败: Input y contains NaN. ➜ 训练 CatBoost回归... ❌ CatBoost回归 失败: catboost/libs/metrics/metric.cpp:6956: metric/loss-function RMSE do not allows nan value on target Traceback (most recent call last): File "E:\pycharm\代码\代码调试9.py", line 390, in <module> pipeline.run_complete_pipeline() File "E:\pycharm\代码\代码调试9.py", line 376, in run_complete_pipeline self.train_and_evaluate() File "E:\pycharm\代码\代码调试9.py", line 350, in train_and_evaluate results_df.sort_values('r2', ascending=False, inplace=True) File "E:\pycharm\代码\.venv\lib\site-packages\pandas\core\frame.py", line 6758, in sort_values k = self._get_label_or_level_values(by, axis=axis) File "E:\pycharm\代码\.venv\lib\site-packages\pandas\core\generic.py", line 1778, in _get_label_or_level_values raise KeyError(key) KeyError: 'r2' 进程已结束,退出代码为 1 继续解决报错并安装安装的代码,生成完整代码
11-12
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值