tuning-hyperparameters

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Hyperparameter Tuner

超参数调优工具

This skill provides automated assistance for hyperparameter tuner tasks.
该技能可为超参数调优任务提供自动化辅助。

Overview

概述

This skill empowers Claude to fine-tune machine learning models by automatically searching for the optimal hyperparameter configurations. It leverages different search strategies (grid, random, Bayesian) to efficiently explore the hyperparameter space and identify settings that maximize model performance.
该技能使Claude能够通过自动搜索最优超参数配置来微调机器学习模型。它利用不同的搜索策略(网格搜索、随机搜索、贝叶斯优化)高效探索超参数空间,找出能最大化模型性能的配置。

How It Works

工作原理

  1. Analyzing Requirements: Claude analyzes the user's request to determine the model, the hyperparameters to tune, the search strategy, and the evaluation metric.
  2. Generating Code: Claude generates Python code using appropriate ML libraries (e.g., scikit-learn, Optuna) to implement the specified hyperparameter search. The code includes data loading, preprocessing, model training, and evaluation.
  3. Executing Search: The generated code is executed to perform the hyperparameter search. The plugin iterates through different hyperparameter combinations, trains the model with each combination, and evaluates its performance.
  4. Reporting Results: Claude reports the best hyperparameter configuration found during the search, along with the corresponding performance metrics. It also provides insights into the search process and potential areas for further optimization.
  1. 需求分析:Claude会分析用户的请求,确定要使用的模型、待调优的超参数、搜索策略以及评估指标。
  2. 生成代码:Claude会使用合适的机器学习库(如scikit-learn、Optuna)生成Python代码,以实现指定的超参数搜索。代码包含数据加载、预处理、模型训练和评估环节。
  3. 执行搜索:运行生成的代码以执行超参数搜索。插件会遍历不同的超参数组合,用每组组合训练模型并评估其性能。
  4. 结果报告:Claude会报告搜索过程中找到的最佳超参数配置,以及对应的性能指标。同时还会提供关于搜索过程的见解和进一步优化的潜在方向。

When to Use This Skill

使用场景

This skill activates when you need to:
  • Optimize the performance of a machine learning model.
  • Automatically search for the best hyperparameter settings.
  • Compare different hyperparameter search strategies.
  • Improve model accuracy, precision, recall, or other relevant metrics.
当你需要以下操作时,可激活该技能:
  • 优化机器学习模型的性能。
  • 自动搜索最佳超参数设置。
  • 比较不同的超参数搜索策略。
  • 提升模型的准确率、精确率、召回率或其他相关指标。

Examples

示例

Example 1: Optimizing a Random Forest Model

示例1:优化随机森林模型

User request: "Tune hyperparameters of a Random Forest model using grid search to maximize accuracy on the iris dataset. Consider n_estimators and max_depth."
The skill will:
  1. Generate code to perform a grid search over the specified hyperparameters (n_estimators, max_depth) of a Random Forest model using the iris dataset.
  2. Execute the grid search and report the best hyperparameter combination and the corresponding accuracy score.
用户请求:“使用网格搜索调优随机森林模型的超参数,以最大化鸢尾花数据集上的准确率。考虑n_estimators和max_depth这两个参数。”
该技能会:
  1. 生成代码,针对鸢尾花数据集上的Random Forest模型,对指定的超参数(n_estimators、max_depth)执行网格搜索。
  2. 执行网格搜索并报告最佳超参数组合及对应的准确率得分。

Example 2: Using Bayesian Optimization

示例2:使用贝叶斯优化

User request: "Optimize a Gradient Boosting model using Bayesian optimization with Optuna to minimize the root mean squared error on the Boston housing dataset."
The skill will:
  1. Generate code to perform Bayesian optimization using Optuna to find the best hyperparameters for a Gradient Boosting model on the Boston housing dataset.
  2. Execute the optimization and report the best hyperparameter combination and the corresponding RMSE.
用户请求:“使用Optuna的贝叶斯优化来优化梯度提升模型,以最小化波士顿房价数据集上的均方根误差。”
该技能会:
  1. 生成代码,使用Optuna执行贝叶斯优化,为波士顿房价数据集上的Gradient Boosting模型寻找最佳超参数。
  2. 执行优化并报告最佳超参数组合及对应的RMSE。

Best Practices

最佳实践

  • Define Search Space: Clearly define the range and type of values for each hyperparameter to be tuned.
  • Choose Appropriate Strategy: Select the hyperparameter search strategy (grid, random, Bayesian) based on the complexity of the hyperparameter space and the available computational resources. Bayesian optimization is generally more efficient for complex spaces.
  • Use Cross-Validation: Implement cross-validation to ensure the robustness of the evaluation metric and prevent overfitting.
  • 定义搜索空间:明确每个待调优超参数的取值范围和类型。
  • 选择合适策略:根据超参数空间的复杂度和可用计算资源,选择超参数搜索策略(网格、随机、贝叶斯)。贝叶斯优化通常在复杂空间中效率更高。
  • 使用交叉验证:实现交叉验证以确保评估指标的鲁棒性,防止过拟合。

Integration

集成

This skill integrates seamlessly with other Claude Code plugins that involve machine learning tasks, such as data analysis, model training, and deployment. It can be used in conjunction with data visualization tools to gain insights into the impact of different hyperparameter settings on model performance.
该技能可与其他涉及机器学习任务的Claude Code插件无缝集成,例如数据分析、模型训练和部署。它还可与数据可视化工具结合使用,以深入了解不同超参数设置对模型性能的影响。

Prerequisites

前置条件

  • Appropriate file access permissions
  • Required dependencies installed
  • 具备适当的文件访问权限
  • 已安装所需依赖项

Instructions

操作步骤

  1. Invoke this skill when the trigger conditions are met
  2. Provide necessary context and parameters
  3. Review the generated output
  4. Apply modifications as needed
  1. 满足触发条件时调用该技能
  2. 提供必要的上下文和参数
  3. 审查生成的输出
  4. 根据需要进行修改

Output

输出

The skill produces structured output relevant to the task.
该技能会生成与任务相关的结构化输出。

Error Handling

错误处理

  • Invalid input: Prompts for correction
  • Missing dependencies: Lists required components
  • Permission errors: Suggests remediation steps
  • 无效输入:提示用户修正
  • 缺失依赖项:列出所需组件
  • 权限错误:建议补救措施

Resources

资源

  • Project documentation
  • Related skills and commands
  • 项目文档
  • 相关技能和命令