返回顶部
a

automl-skill自动机器学习

>

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.2.0
安全检测
已通过
543
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

automl-skill

PyCaret AutoML 技能指南

本技能帮助用户使用 PyCaret 快速构建端到端的机器学习工作流。PyCaret 是一个开源的低代码机器学习库,可以将数百行代码简化为几行。

核心功能

  • - 自动化模型选择 - 自动比较多个模型并选择最佳模型
  • 自动化超参数调优 - 使用 Optuna/Hyperopt 自动优化模型参数
  • 自动化特征工程 - 自动进行数据预处理、特征转换和特征选择
  • 模型集成 - 支持 Bagging、Boosting、Stacking、Blending
  • 模型可解释性 - 支持 SHAP、Permutation Importance 等解释方法
  • 模型部署就绪 - 生成可复现的生产级 Pipeline
  • 统计推断增强 - 支持置信区间、假设检验、统计显著性分析

统计推断增强 (statsmodels)

当需要统计推断、假设检验、置信区间时,可以使用 statsmodels 补充 PyCaret:

线性回归模型

python import statsmodels.api as sm

OLS 回归(带统计显著性)

X = sm.add_constant(X) # 添加截距 model = sm.OLS(y, X).fit() print(model.summary()) # R², F检验, P值, 置信区间

广义线性模型 (GLM)

python

二项分布 GLM (Logistic 回归)

glm_model = sm.GLM(y, X, family=sm.families.Binomial()).fit()

泊松回归 (计数数据)

poisson_model = sm.GLM(y, X, family=sm.families.Poisson()).fit()

假设检验

python from scipy import stats

t 检验

tstat, pvalue = stats.ttest_ind(group1, group2)

卡方检验

chi2, pvalue, dof, expected = stats.chi2contingency(contingency_table)

ANOVA

fstat, pvalue = stats.f_oneway(*groups)

时间序列分析

python from statsmodels.tsa.arima.model import ARIMA from statsmodels.tsa.statespace.sarimax import SARIMAX

ARIMA 模型

arimamodel = ARIMA(traindata, order=(1,1,1)).fit() forecast = arima_model.forecast(steps=12)

季节性 SARIMAX

sarimaxmodel = SARIMAX(data, order=(1,1,1), seasonalorder=(1,1,1,12)).fit()

统计诊断

python

残差自相关检验 (Durbin-Watson)

from statsmodels.stats.stattools import durbin_watson dw = durbin_watson(model.resid)

异方差检验

from statsmodels.stats.diagnostic import het_breuschpagan bptest = hetbreuschpagan(model.resid, model.model.exog)

正态性检验

from scipy import stats shapirostat, shapirop = stats.shapiro(model.resid)

混合效应模型 (随机效应)

python

混合线性模型 (Panel Data / 多层次数据)

from statsmodels.regression.mixedlinearmodel import MixedLM mixedmodel = MixedLM(y, X, groups=groupvar).fit()

PyCaret + statsmodels 组合使用

python

1. 用 PyCaret 快速建模和选择模型

from pycaret.classification import * clf = setup(data, target=target) best = compare_models() tuned = tune_model(best)

2. 用 statsmodels 做统计推断

import statsmodels.api as sm

获取 PyCaret 模型的特征和预测

Xwithconst = sm.addconstant(Xtest) smmodel = sm.Logit(ytest, Xwithconst).fit(disp=0) print(sm_model.summary()) # 系数显著性 P值

支持的机器学习任务

模块任务类型参考文档
pycaret.classification二分类、多分类classification.md
pycaret.regression
回归预测 | regression.md | | pycaret.clustering | 无监督聚类 | clustering.md | | pycaret.anomaly | 异常检测 | anomaly.md | | pycaret.timeseries | 时间序列预测 | timeseries.md | | pycaret.nlp | 文本分类、主题建模 | nlp.md | | pycaret.arules | 关联规则挖掘 | association_rules.md |

快速开始

1. 选择您的任务类型

根据您的机器学习任务,选择相应的模块:

  • - 分类问题 → 使用 pycaret.classification
  • 回归问题 → 使用 pycaret.regression
  • 客户分群 → 使用 pycaret.clustering
  • 异常检测 → 使用 pycaret.anomaly
  • 时间预测 → 使用 pycaret.time_series
  • 文本分析 → 使用 pycaret.nlp
  • 购物篮分析 → 使用 pycaret.arules

2. 标准 AutoML 工作流

完整的 AutoML 工作流程包含以下步骤:

Step 1: 数据收集与加载

python

数据加载

import pandas as pd train = pd.read_csv(train.csv) test = pd.read_csv(test.csv)

或使用 PyCaret 内置数据集

from pycaret.classification import get_data data = getdata(breastcancer)

Step 2: 数据理解与探索

python

基本信息

print(f数据形状: {data.shape}) print(f数据类型:\n{data.dtypes})

缺失值分析

missing = data.isnull().sum() missing_pct = (missing / len(data) * 100).round(2) print(f缺失值比例:\n{pd.concat([missing, missing_pct], axis=1)})

目标变量分布

data[target].value_counts()

数值特征统计

data.describe()

Step 3: 数据预处理 (setup 中自动完成)

python

初始化环境 - 数据预处理配置

clf = setup( data, target=target,

# ===== 缺失值处理 =====
numeric_imputation=mean, # 数值型: mean/median/mode/knn/iterative
categorical_imputation=mode, # 类别型: mode/constant

# ===== 异常值处理 =====
remove_outliers=True, # 移除异常值
outliers_method=iforest, # iforest/ee/lof
outliers_threshold=0.05, # 异常值比例

# ===== 类别不平衡处理 =====
fix_imbalance=True, # 处理类别不平衡
fiximbalancemethod=SMOTE, # SMOTE/ADASYN/RandomOverSampler

# ===== 数据类型指定 =====
numeric_features=[age, income, score],
categorical_features=[city, gender, occupation],
datefeatures=[Date, createdat],

session_id=42
)

Step 4: 特征工程 (setup 中自动完成)

python clf = setup( data, target=target,

# ===== 特征缩放 =====
normalize=True, # 归一化
normalize_method=zscore, # zscore/minmax/maxabs/robust

# ===== 特征变换 =====
transformation=True, # 变换使数据更接近正态分布
transformation_method=yeo-johnson, # yeo-johnson/quantile

# ===== 特征选择 =====
feature_selection=True, # 特征选择
featureselectionmethod=classic, # classic/univariate/sequential
nfeaturesto_select=0.2, # 选择20%最重要特征

# ===== 降维 =====
pca=True, # PCA降维
pca_method=linear, # linear/kernel/incremental
pca_components=0.95, # 保留95%方差

# ===== 多重共线性处理 =====
remove_multicollinearity=True,
multicollinearity_threshold=0.9,

# ===== 特征编码 =====
ordinalfeatures={education: [highschool, bachelor, master, phd]},
highcardinalityfeatures=frequency, # 处理

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 automl-skill-1776373864 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 automl-skill-1776373864 技能

通过命令行安装

skillhub install automl-skill-1776373864

下载

⬇ 下载 automl-skill v1.2.0(免费)

文件大小: 33.95 KB | 发布时间: 2026-4-17 14:09

v1.2.0 最新 2026-4-17 14:09
Version 1.2.0 of automl-skill adds statistical inference capabilities and workflow documentation improvements.

- Expanded trigger keywords and description to include statistical testing, significance analysis, and A/B testing.
- Added new documentation section demonstrating statistical inference, hypothesis testing, and model diagnostics using statsmodels and scipy.
- Enhanced example workflows for regression, classification, and time series to include data preprocessing and feature engineering.
- Detailed preprocessing, feature transformation, and model training steps for end-to-end usage clarity.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部