Skip to content

Optimize Hyperparameters

1. Objective

To execute Optimize Hyperparameters for high-performing AI systems.

2. When to use / When not to use

When to use:

  • When working on optimize hyperparameters.

When not to use:

  • Without sufficient data.

3. Inputs (Required/Optional)

Required:

  • Training Data
  • Model Config

Optional:

  • Relevant documentation

4. Outputs (Artifacts)

  • Model Artifact: Description of the Model Artifact artifact.
  • Metrics Report: Description of the Metrics Report artifact.

5. Operating Modes

ModeDescriptionVerification Level
FastFocus on speed, minimal validation.Basic syntax/lint checks only.
StandardBalanced approach.Unit tests and standard linting.
DeepComprehensive analysis and optimization.Full test suite, performance profiling, security scan.

6. Constraints & Guardrails

  • No Broken Builds: Ensure all changes pass the build process.
  • Code Style: Strictly adhere to the project's linting and formatting rules.
  • Security: Do not introduce new vulnerabilities; sanitize all inputs.
  • Performance: Avoid O(n^2) or worse complexity unless strictly necessary and documented.
  • Testing: Maintain or improve code coverage; do not degrade it.

7. Procedure

Phase 1: Data Prep

  1. Clean data.
  2. Split train/test.
  3. Normalize features.

Phase 2: Training

  1. Configure model.
  2. Run training loop.
  3. Log metrics.

Phase 3: Evaluation

  1. Calculate accuracy/F1.
  2. Check bias.
  3. Save artifact.

8. Quality Gates (Definition of Done)

  • [ ] code compiles/runs without errors.
  • [ ] All new components include identical or improved test coverage.
  • [ ] No new linting errors or warnings introduced.
  • [ ] Documentation updated (inline and external).
  • [ ] Security scan passes (no high/critical severities).

9. Failure Modes & Recovery

Failure ModeRecovery Action
Build FailureCheck error logs, revert recent changes, verify dependencies.
Test FailureIsolate failing test, debug logic, or update test if requirements changed.
Linting ErrorRun auto-formatter and manually fix remaining issues.
Merge ConflictRebase on main, resolve conflicts manually, run tests again.

10. Copy-Paste Prompt

text
Role: Act as a Senior Data Scientist.
Task: Execute the Optimize Hyperparameters workflow.

## Objective & Scope
- **Goal**: Systematically find the optimal hyperparameters for a machine learning model to maximize performance.
- **Scope**: Search Strategy (Grid/Random/Bayes), Metric Selection, Cross-Validation, and Result Analysis.

## Inputs
- [ ] MODEL: The model algorithm (e.g., Random Forest).
- [ ] DATASET: Training and Validation data.
- [ ] PARAM_GRID: Dictionary of parameters and ranges to search.
- [ ] METRIC: Target metric (e.g., F1-Score, AUC).

## Output Artifacts
- [ ] Best Parameter Set (JSON)
- [ ] Optimization Report (CV Results)
- [ ] Final Tuned Model

## Execution Steps
1. **Configure**
   - Define the search space (using Optuna or Scikit-Learn `GridSearchCV`). Set the cross-validation strategy.
2. **Search**
   - Run the optimization loop. Use early stopping if available to save resources.
3. **Analyze**
   - Extract the best parameters. Evaluate the impact of each parameter on the metric.

## Quality Gates
- [ ] Search completed successfully.
- [ ] Best hyperparameters identified.
- [ ] Performance improvement verified against baseline.
- [ ] No overfitting on validation set.

## Failure Handling
- If blocked, output a "Clarification Brief" detailing missing info or blockers.

## Constraints
- **Resource**: Respect compute and time budget.
- **Methodology**: Use K-Fold Cross-Validation to ensure robustness.

## Command
Now execute this workflow step-by-step.

Cập nhật lần cuối: