|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Hyperactive is an optimization and data collection toolbox for convenient and fast prototyping of computationally expensive models. It provides various optimization algorithms including random search, grid search, Bayesian optimization, and many others for hyperparameter tuning and general optimization problems. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +### Core Components |
| 12 | + |
| 13 | +- **`src/hyperactive/`** - Main package with src-layout structure |
| 14 | + - **`base/`** - Base classes for experiments and optimizers using skbase framework |
| 15 | + - **`opt/`** - Optimization algorithms organized by backend: |
| 16 | + - **`gfo/`** - Gradient-Free-Optimizers backend algorithms |
| 17 | + - **`optuna/`** - Optuna backend integration |
| 18 | + - **`gridsearch/`** - Scikit-learn grid search integration |
| 19 | + - **`integrations/`** - Framework integrations (sklearn, sktime) |
| 20 | + - **`experiment/`** - Experiment definitions and benchmark functions |
| 21 | + - **`utils/`** - Utility functions for parallel computing and validation |
| 22 | + |
| 23 | +### Key Design Patterns |
| 24 | + |
| 25 | +- Uses **skbase** framework for base classes with tagging system for metadata |
| 26 | +- **Plugin architecture** - optimizers and experiments inherit from base classes |
| 27 | +- **Multiple backends** - supports GFO, Optuna, and sklearn optimization backends |
| 28 | +- **Integration layer** - separate modules for ML framework integrations |
| 29 | + |
| 30 | +## Development Commands |
| 31 | + |
| 32 | +### Build and Install |
| 33 | +```bash |
| 34 | +make build # Build the package using python -m build |
| 35 | +make install # Install from built wheel |
| 36 | +make install-editable # Install in development mode |
| 37 | +make reinstall # Uninstall and reinstall |
| 38 | +``` |
| 39 | + |
| 40 | +### Testing |
| 41 | +```bash |
| 42 | +make test # Run all tests (src, pytest, local) |
| 43 | +make test-pytest # Run main test suite with pytest |
| 44 | +make test-src # Run tests within src/hyperactive/ |
| 45 | +make test-extensive # Run comprehensive tests including examples |
| 46 | +make test-examples # Test all example files |
| 47 | +``` |
| 48 | + |
| 49 | +### Code Quality |
| 50 | +```bash |
| 51 | +make lint # Check code with ruff linter |
| 52 | +make lint-fix # Auto-fix linting issues |
| 53 | +make format # Format code with ruff |
| 54 | +make format-check # Check formatting without changes |
| 55 | +make check # Run all quality checks (lint + format + imports) |
| 56 | +make fix # Fix all auto-fixable issues |
| 57 | +``` |
| 58 | + |
| 59 | +### Dependencies |
| 60 | +```bash |
| 61 | +make install-test-requirements # Install test dependencies |
| 62 | +make install-all-extras-for-test # Install all optional dependencies for testing |
| 63 | +``` |
| 64 | + |
| 65 | +## Testing Structure |
| 66 | + |
| 67 | +- **`tests/`** - Main test directory (currently minimal, mostly in src/) |
| 68 | +- **`src/hyperactive/*/tests/`** - Component-specific tests within source code |
| 69 | +- **`examples/test_examples.py`** - Example validation tests |
| 70 | +- Uses **pytest** as the test runner |
| 71 | +- Test configuration in `pyproject.toml` under `[tool.test]` dependencies |
| 72 | + |
| 73 | +## Key Configuration Files |
| 74 | + |
| 75 | +- **`pyproject.toml`** - Modern Python packaging configuration with dependencies, build system, and ruff configuration |
| 76 | +- **`Makefile`** - Comprehensive build, test, and quality commands |
| 77 | +- **`.github/workflows/`** - CI/CD workflows for automated testing |
| 78 | + |
| 79 | +## Code Style and Linting |
| 80 | + |
| 81 | +- Uses **ruff** for linting and formatting (configured in pyproject.toml) |
| 82 | +- Follows **numpy docstring convention** |
| 83 | +- Python 3.9+ support |
| 84 | +- Line length: 88 characters |
| 85 | +- Import sorting with ruff's isort functionality |
| 86 | + |
| 87 | +## Dependencies |
| 88 | + |
| 89 | +### Core Dependencies |
| 90 | +- `numpy`, `pandas` - Data handling |
| 91 | +- `tqdm` - Progress bars |
| 92 | +- `gradient-free-optimizers` - Main optimization backend |
| 93 | +- `scikit-base` - Base class framework |
| 94 | +- `scikit-learn` - ML integration |
| 95 | + |
| 96 | +### Optional Dependencies |
| 97 | +- `sklearn-integration` - Enhanced sklearn support |
| 98 | +- `sktime-integration` - Time series forecasting |
| 99 | +- `test` - Testing dependencies (pytest, flake8, etc.) |
| 100 | +- `all_extras` - All optional features |
| 101 | + |
| 102 | +## Examples Structure |
| 103 | + |
| 104 | +- **`examples/gfo/`** - Gradient-Free-Optimizers examples |
| 105 | +- **`examples/optuna/`** - Optuna backend examples |
| 106 | +- **`examples/sklearn/`** - Scikit-learn integration examples |
| 107 | +- Each example directory has its own README.md |
| 108 | + |
| 109 | +## Common Development Tasks |
| 110 | + |
| 111 | +### Adding New Optimizers |
| 112 | +1. Create optimizer class in appropriate `opt/` subdirectory |
| 113 | +2. Inherit from `BaseOptimizer` and implement required methods |
| 114 | +3. Add appropriate tags for metadata |
| 115 | +4. Register in `_registry/` if needed |
| 116 | +5. Add tests in corresponding `tests/` directory |
| 117 | +6. Add usage example in `examples/` |
| 118 | + |
| 119 | +### Running Single Tests |
| 120 | +```bash |
| 121 | +python -m pytest tests/specific_test.py -v |
| 122 | +python -m pytest src/hyperactive/component/tests/test_file.py |
| 123 | +``` |
| 124 | + |
| 125 | +### Version Management |
| 126 | +- Version defined in `pyproject.toml` |
| 127 | +- Uses `importlib.metadata` for runtime version access |
| 128 | +- Current version: 4.8.1 |
0 commit comments