|
| 1 | +.. _faq_common_issues: |
| 2 | + |
| 3 | +============= |
| 4 | +Common Issues |
| 5 | +============= |
| 6 | + |
| 7 | +Why is my optimization slow? |
| 8 | +---------------------------- |
| 9 | + |
| 10 | +**Slow objective function**: The optimizer only controls search strategy. |
| 11 | +If each evaluation takes a long time, consider: |
| 12 | + |
| 13 | +- Reducing cross-validation folds |
| 14 | +- Using a subset of training data for tuning |
| 15 | +- Simplifying your model during search |
| 16 | + |
| 17 | +**Large search space**: More combinations require more iterations. |
| 18 | +Consider reducing parameter granularity or using smarter optimizers |
| 19 | +like Bayesian optimization. |
| 20 | + |
| 21 | +**Too many iterations**: Start with fewer iterations and increase |
| 22 | +if needed. |
| 23 | + |
| 24 | + |
| 25 | +Why does my score vary between runs? |
| 26 | +------------------------------------ |
| 27 | + |
| 28 | +Optimization algorithms are stochastic. To get reproducible results, |
| 29 | +set a random seed: |
| 30 | + |
| 31 | +.. code-block:: python |
| 32 | +
|
| 33 | + optimizer = HillClimbing( |
| 34 | + search_space=search_space, |
| 35 | + n_iter=100, |
| 36 | + experiment=objective, |
| 37 | + random_state=42, # Set seed for reproducibility |
| 38 | + ) |
| 39 | +
|
| 40 | +
|
| 41 | +My objective function returns NaN or raises exceptions |
| 42 | +------------------------------------------------------ |
| 43 | + |
| 44 | +Handle invalid configurations in your objective function: |
| 45 | + |
| 46 | +.. code-block:: python |
| 47 | +
|
| 48 | + def objective(params): |
| 49 | + try: |
| 50 | + score = evaluate_model(params) |
| 51 | + if np.isnan(score): |
| 52 | + return -np.inf # Return worst possible score |
| 53 | + return score |
| 54 | + except Exception: |
| 55 | + return -np.inf # Return worst possible score on error |
| 56 | +
|
| 57 | +
|
| 58 | +How do I see what parameters were tried? |
| 59 | +---------------------------------------- |
| 60 | + |
| 61 | +Access the search history after optimization: |
| 62 | + |
| 63 | +.. code-block:: python |
| 64 | +
|
| 65 | + best_params = optimizer.solve() |
| 66 | +
|
| 67 | + # Access results |
| 68 | + print(f"Best parameters: {optimizer.best_params_}") |
| 69 | + print(f"Best score: {optimizer.best_score_}") |
| 70 | +
|
| 71 | + # Full search history (if available) |
| 72 | + # Check optimizer attributes for search_data or similar |
0 commit comments