Optimizer
framework3.base.base_optimizer
¶
__all__ = ['BaseOptimizer']
module-attribute
¶
BaseOptimizer
¶
Bases: BaseFilter
Base class for optimizer components in the framework.
This abstract class extends BaseFilter and defines the interface for optimizer operations. It provides a structure for implementing optimization strategies for pipelines.
Key Features
- Abstract methods for starting optimization process and optimizing pipelines
- Support for verbose output control
Usage
To create a new optimizer type, inherit from this class and implement the required methods. For example:
class MyCustomOptimizer(BaseOptimizer):
def __init__(self, optimization_params):
super().__init__()
self.optimization_params = optimization_params
def start(self, x: XYData, y: Optional[XYData], X_: Optional[XYData]) -> Optional[XYData]:
# Implement optimization start logic
pass
def optimize(self, pipeline: BaseFilter) -> None:
# Implement pipeline optimization logic
pass
Attributes:
Name | Type | Description |
---|---|---|
pipeline |
BaseFilter
|
The pipeline to be optimized. |
Methods:
Name | Description |
---|---|
start |
XYData, y: Optional[XYData], X_: Optional[XYData]) -> Optional[XYData]: Abstract method to start the optimization process. |
optimize |
BaseFilter) -> None: Abstract method to optimize the given pipeline. |
verbose |
bool) -> None: Sets the verbosity level for the optimizer and its pipeline. |
Note
This is an abstract base class. Concrete implementations should override the start and optimize methods to provide specific optimization functionality.
Source code in framework3/base/base_optimizer.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
optimize(pipeline)
abstractmethod
¶
Optimize the given pipeline.
This abstract method should be implemented by subclasses to define the specific logic for optimizing a pipeline.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline
|
BaseFilter
|
The pipeline to be optimized. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the subclass does not implement this method. |
Example
Source code in framework3/base/base_optimizer.py
start(x, y, X_)
abstractmethod
¶
Start the optimization process.
This abstract method should be implemented by subclasses to define the specific logic for initiating the optimization process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
XYData
|
The primary input data. |
required |
y
|
Optional[XYData]
|
Optional target data. |
required |
X_
|
Optional[XYData]
|
Optional additional input data. |
required |
Returns:
Type | Description |
---|---|
Optional[XYData]
|
Optional[XYData]: The processed data, if any. |
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the subclass does not implement this method. |
Example
Source code in framework3/base/base_optimizer.py
verbose(value)
¶
Set the verbosity of the optimizer and its pipeline.
This method controls the verbosity of both the optimizer itself and its associated pipeline.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
If True, enables verbose output; if False, disables it. |
required |
Returns:
Type | Description |
---|---|
None
|
None |