Predictors
AbstractPredictor
Bases: ABC
Abstract base class for all predictors.
Methods
fit(X, Y, kwargs) Fit the model to the data. predict(X, kwargs) Predict using the model. save(file_path) Save the model to a file. load(file_path) Load the model from a file. get_configuration_space(cs) Get the configuration space for the predictor. get_from_configuration(configuration) Get a predictor instance from a configuration.
Source code in asf/predictors/abstract_predictor.py
__init__()
fit(X, Y, **kwargs)
abstractmethod
Fit the model to the data.
Parameters
X : Any Training data. Y : Any Target values. kwargs : Any Additional arguments for fitting the model.
Source code in asf/predictors/abstract_predictor.py
load(file_path)
abstractmethod
Load the model from a file.
Parameters
file_path : str Path to the file from which the model will be loaded.
predict(X, **kwargs)
abstractmethod
Predict using the model.
Parameters
X : Any Data to predict on. kwargs : Any Additional arguments for prediction.
Returns
Any Predicted values.
Source code in asf/predictors/abstract_predictor.py
save(file_path)
abstractmethod
Save the model to a file.
Parameters
file_path : str Path to the file where the model will be saved.
EPMRandomForest
Bases: ForestRegressor
, AbstractPredictor
Implementation of random forest as described in the paper "Algorithm runtime prediction: Methods & evaluation" by Hutter, Xu, Hoos, and Leyton-Brown (2014).
This class extends ForestRegressor
and AbstractPredictor
to provide
a random forest implementation with additional functionality for runtime prediction.
Parameters
n_estimators : int, optional The number of trees in the forest. Default is 100. log : bool, optional Whether to apply logarithmic transformation to the tree values. Default is False. cross_trees_variance : bool, optional Whether to compute variance across trees. Default is False. criterion : str, optional The function to measure the quality of a split. Default is "squared_error". splitter : str, optional The strategy used to choose the split at each node. Default is "random". max_depth : int, optional The maximum depth of the tree. Default is None. min_samples_split : int, optional The minimum number of samples required to split an internal node. Default is 2. min_samples_leaf : int, optional The minimum number of samples required to be at a leaf node. Default is 1. min_weight_fraction_leaf : float, optional The minimum weighted fraction of the sum total of weights required to be at a leaf node. Default is 0.0. max_features : float, optional The number of features to consider when looking for the best split. Default is 1.0. max_leaf_nodes : int, optional Grow trees with max_leaf_nodes in best-first fashion. Default is None. min_impurity_decrease : float, optional A node will be split if this split induces a decrease of the impurity greater than or equal to this value. Default is 0.0. bootstrap : bool, optional Whether bootstrap samples are used when building trees. Default is False. oob_score : bool, optional Whether to use out-of-bag samples to estimate the generalization score. Default is False. n_jobs : int, optional The number of jobs to run in parallel. Default is None. random_state : int, optional Controls the randomness of the estimator. Default is None. verbose : int, optional Controls the verbosity when fitting and predicting. Default is 0. warm_start : bool, optional When set to True, reuse the solution of the previous call to fit and add more estimators to the ensemble. Default is False. ccp_alpha : float, optional Complexity parameter used for Minimal Cost-Complexity Pruning. Default is 0.0. max_samples : int or float, optional If bootstrap is True, the number of samples to draw from X to train each base estimator. Default is None. monotonic_cst : array-like, optional Constraints for monotonicity of features. Default is None.
Source code in asf/predictors/epm_random_forest.py
7 8 9 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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
fit(X, y, sample_weight=None)
Fit the model to the data.
Parameters
X : np.ndarray Training data of shape (n_samples, n_features). y : np.ndarray Target values of shape (n_samples,). sample_weight : np.ndarray, optional Sample weights. Default is None.
Raises
AssertionError If sample weights are provided, as they are not supported.
Source code in asf/predictors/epm_random_forest.py
load(file_path)
Load the model from a file.
Parameters
file_path : str Path to the file from which the model will be loaded.
Returns
EPMRandomForest The loaded model.
Source code in asf/predictors/epm_random_forest.py
predict(X)
Predict using the model.
Parameters
X : np.ndarray Data to predict on of shape (n_samples, n_features).
Returns
tuple[np.ndarray, np.ndarray] A tuple containing: - Predicted means of shape (n_samples, 1). - Predicted variances of shape (n_samples, 1).
Source code in asf/predictors/epm_random_forest.py
save(file_path)
Save the model to a file.
Parameters
file_path : str Path to the file where the model will be saved.
Source code in asf/predictors/epm_random_forest.py
LinearClassifierWrapper
Bases: SklearnWrapper
A wrapper for the SGDClassifier from scikit-learn, providing additional functionality for configuration space generation and parameter extraction.
Source code in asf/predictors/linear_model.py
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 |
|
__init__(init_params=None)
Initialize the LinearClassifierWrapper.
Parameters
init_params : dict, optional A dictionary of initialization parameters for the SGDClassifier.
Source code in asf/predictors/linear_model.py
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Get the configuration space for the Linear Classifier.
Parameters
cs : ConfigurationSpace, optional The configuration space to add the parameters to. If None, a new ConfigurationSpace will be created.
Returns
ConfigurationSpace The configuration space with the Linear Classifier parameters.
Source code in asf/predictors/linear_model.py
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Create a partial function to initialize LinearClassifierWrapper with parameters from a configuration.
Parameters
configuration : dict A dictionary containing the configuration parameters. additional_params : dict, optional Additional parameters to include in the initialization.
Returns
partial A partial function to initialize LinearClassifierWrapper.
Source code in asf/predictors/linear_model.py
LinearRegressorWrapper
Bases: SklearnWrapper
A wrapper for the SGDRegressor from scikit-learn, providing additional functionality for configuration space generation and parameter extraction.
Source code in asf/predictors/linear_model.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
__init__(init_params=None)
Initialize the LinearRegressorWrapper.
Parameters
init_params : dict, optional A dictionary of initialization parameters for the SGDRegressor.
Source code in asf/predictors/linear_model.py
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Get the configuration space for the Linear Regressor.
Parameters
cs : ConfigurationSpace, optional The configuration space to add the parameters to. If None, a new ConfigurationSpace will be created.
Returns
ConfigurationSpace The configuration space with the Linear Regressor parameters.
Source code in asf/predictors/linear_model.py
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Create a partial function to initialize LinearRegressorWrapper with parameters from a configuration.
Parameters
configuration : dict A dictionary containing the configuration parameters. additional_params : dict, optional Additional parameters to include in the initialization.
Returns
partial A partial function to initialize LinearRegressorWrapper.
Source code in asf/predictors/linear_model.py
MLPClassifierWrapper
Bases: SklearnWrapper
A wrapper for the MLPClassifier from scikit-learn, providing additional functionality for configuration space and parameter handling.
Source code in asf/predictors/mlp.py
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
__init__(init_params=None)
Initialize the MLPClassifierWrapper.
Parameters
init_params : dict, optional Initial parameters for the MLPClassifier.
Source code in asf/predictors/mlp.py
fit(X, Y, sample_weight=None, **kwargs)
Fit the model to the data.
Parameters
X : array-like Training data. Y : array-like Target values. sample_weight : array-like, optional Sample weights. Not supported for MLPClassifier. kwargs : dict Additional arguments for the fit method.
Source code in asf/predictors/mlp.py
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Get the configuration space for the MLP Classifier.
Parameters
cs : ConfigurationSpace, optional The configuration space to add the parameters to. If None, a new ConfigurationSpace will be created.
Returns
ConfigurationSpace The configuration space with the MLP Classifier parameters.
Source code in asf/predictors/mlp.py
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Create an MLPClassifierWrapper instance from a configuration.
Parameters
configuration : ConfigurationSpace The configuration containing the parameters. additional_params : dict, optional Additional parameters to override the default configuration.
Returns
partial A partial function to create an MLPClassifierWrapper instance.
Source code in asf/predictors/mlp.py
MLPRegressorWrapper
Bases: SklearnWrapper
A wrapper for the MLPRegressor from scikit-learn, providing additional functionality for configuration space and parameter handling.
Source code in asf/predictors/mlp.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
__init__(init_params=None)
Initialize the MLPRegressorWrapper.
Parameters
init_params : dict, optional Initial parameters for the MLPRegressor.
Source code in asf/predictors/mlp.py
fit(X, Y, sample_weight=None, **kwargs)
Fit the model to the data.
Parameters
X : array-like Training data. Y : array-like Target values. sample_weight : array-like, optional Sample weights. Not supported for MLPRegressor. kwargs : dict Additional arguments for the fit method.
Source code in asf/predictors/mlp.py
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Get the configuration space for the MLP Regressor.
Parameters
cs : ConfigurationSpace, optional The configuration space to add the parameters to. If None, a new ConfigurationSpace will be created.
Returns
ConfigurationSpace The configuration space with the MLP Regressor parameters.
Source code in asf/predictors/mlp.py
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Create an MLPRegressorWrapper instance from a configuration.
Parameters
configuration : ConfigurationSpace The configuration containing the parameters. additional_params : dict, optional Additional parameters to override the default configuration.
Returns
partial A partial function to create an MLPRegressorWrapper instance.
Source code in asf/predictors/mlp.py
RandomForestClassifierWrapper
Bases: SklearnWrapper
A wrapper for the RandomForestClassifier from scikit-learn, providing additional functionality for configuration space management.
Source code in asf/predictors/random_forest.py
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
__init__(init_params={})
Initialize the RandomForestClassifierWrapper.
Parameters
init_params : dict, optional A dictionary of initialization parameters for the RandomForestClassifier.
Source code in asf/predictors/random_forest.py
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Get the configuration space for the Random Forest Classifier.
Parameters
cs : ConfigurationSpace, optional The configuration space to add the parameters to. If None, a new ConfigurationSpace will be created.
Returns
ConfigurationSpace The configuration space with the Random Forest Classifier parameters.
Source code in asf/predictors/random_forest.py
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Create a RandomForestClassifierWrapper instance from a configuration.
Parameters
configuration : dict A dictionary containing the configuration parameters. additional_params : dict, optional Additional parameters to override or extend the configuration.
Returns
partial A partial function to create a RandomForestClassifierWrapper instance.
Source code in asf/predictors/random_forest.py
RandomForestRegressorWrapper
Bases: SklearnWrapper
A wrapper for the RandomForestRegressor from scikit-learn, providing additional functionality for configuration space management.
Source code in asf/predictors/random_forest.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
__init__(init_params={})
Initialize the RandomForestRegressorWrapper.
Parameters
init_params : dict, optional A dictionary of initialization parameters for the RandomForestRegressor.
Source code in asf/predictors/random_forest.py
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Get the configuration space for the Random Forest Regressor.
Parameters
cs : ConfigurationSpace, optional The configuration space to add the parameters to. If None, a new ConfigurationSpace will be created.
Returns
ConfigurationSpace The configuration space with the Random Forest Regressor parameters.
Source code in asf/predictors/random_forest.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Create a RandomForestRegressorWrapper instance from a configuration.
Parameters
configuration : dict A dictionary containing the configuration parameters. additional_params : dict, optional Additional parameters to override or extend the configuration.
Returns
partial A partial function to create a RandomForestRegressorWrapper instance.
Source code in asf/predictors/random_forest.py
RankingMLP
Bases: AbstractPredictor
A ranking-based predictor using a Multi-Layer Perceptron (MLP).
This class implements a ranking model that uses an MLP to predict the performance of algorithms based on input features.
Source code in asf/predictors/ranking_mlp.py
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
__init__(model=None, input_size=None, loss=bpr_loss, optimizer=torch.optim.Adam, batch_size=128, epochs=500, seed=42, device='cpu', compile=True, **kwargs)
Initializes the RankingMLP with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Module | None
|
The pre-defined PyTorch model to use. If None, a new MLP is created. |
None
|
input_size
|
int | None
|
The input size for the MLP. Required if |
None
|
loss
|
Callable
|
The loss function to use. Defaults to |
bpr_loss
|
optimizer
|
Callable[..., Optimizer]
|
The optimizer class to use. Defaults to |
Adam
|
batch_size
|
int
|
The batch size for training. Defaults to 128. |
128
|
epochs
|
int
|
The number of training epochs. Defaults to 500. |
500
|
seed
|
int
|
The random seed for reproducibility. Defaults to 42. |
42
|
device
|
str
|
The device to use for training (e.g., "cpu" or "cuda"). Defaults to "cpu". |
'cpu'
|
compile
|
bool
|
Whether to compile the model using |
True
|
**kwargs
|
Additional arguments for the parent class. |
{}
|
Source code in asf/predictors/ranking_mlp.py
fit(features, performance, algorithm_features)
Fits the model to the given feature and performance data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features
|
DataFrame
|
DataFrame containing the feature data. |
required |
performance
|
DataFrame
|
DataFrame containing the performance data. |
required |
algorithm_features
|
DataFrame
|
DataFrame containing algorithm-specific features. |
required |
Returns:
Name | Type | Description |
---|---|---|
RankingMLP |
RankingMLP
|
The fitted model. |
Source code in asf/predictors/ranking_mlp.py
load(file_path)
Loads the model from the specified file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
The path to load the model from. |
required |
predict(features)
Predicts the performance of algorithms for the given features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features
|
DataFrame
|
DataFrame containing the feature data. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame containing the predicted performance data. |
Source code in asf/predictors/ranking_mlp.py
save(file_path)
Saves the model to the specified file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
The path to save the model. |
required |
RegressionMLP
Bases: AbstractPredictor
Source code in asf/predictors/regression_mlp.py
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
__init__(model=None, loss=torch.nn.MSELoss(), optimizer=torch.optim.Adam, batch_size=128, epochs=2000, seed=42, device='cpu', compile=True, **kwargs)
Initializes the RegressionMLP with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Module | None
|
The PyTorch model to be used. If None, a new MLP model will be created. |
None
|
input_size
|
int | None
|
The size of the input features. Required if |
required |
loss
|
_Loss | None
|
The loss function to be used. Defaults to Mean Squared Error Loss. |
MSELoss()
|
optimizer
|
type[Optimizer] | None
|
The optimizer class to be used. Defaults to Adam. |
Adam
|
batch_size
|
int
|
The batch size for training. Defaults to 128. |
128
|
epochs
|
int
|
The number of epochs for training. Defaults to 2000. |
2000
|
seed
|
int
|
The random seed for reproducibility. Defaults to 42. |
42
|
device
|
str
|
The device to run the model on ('cpu' or 'cuda'). Defaults to 'cpu'. |
'cpu'
|
compile
|
bool
|
Whether to compile the model using |
True
|
**kwargs
|
Additional keyword arguments passed to the parent class. |
{}
|
Source code in asf/predictors/regression_mlp.py
fit(features, performance, sample_weight=None)
Fits the model to the given feature and performance data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features
|
DataFrame
|
DataFrame containing the feature data. |
required |
performance
|
DataFrame
|
DataFrame containing the performance data. |
required |
Returns:
Name | Type | Description |
---|---|---|
RegressionMLP |
RegressionMLP
|
The fitted model instance. |
Source code in asf/predictors/regression_mlp.py
load(file_path)
Loads the model from the specified file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
The path to load the model from. |
required |
predict(features)
Predicts the performance of algorithms for the given features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features
|
DataFrame
|
DataFrame containing the feature data. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame containing the predicted performance data. |
Source code in asf/predictors/regression_mlp.py
save(file_path)
Saves the model to the specified file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
The path to save the model. |
required |
SVMClassifierWrapper
Bases: SklearnWrapper
A wrapper for the Scikit-learn SVC (Support Vector Classifier) model. Provides methods to define a configuration space and create an instance of the classifier from a configuration.
Attributes
PREFIX : str Prefix used for parameter names in the configuration space.
Source code in asf/predictors/svm.py
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
__init__(init_params={})
Initialize the SVMClassifierWrapper.
Parameters
init_params : dict, optional Dictionary of parameters to initialize the SVC model.
Source code in asf/predictors/svm.py
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Define the configuration space for the SVM classifier.
Returns
ConfigurationSpace The configuration space containing hyperparameters for the SVM classifier.
Source code in asf/predictors/svm.py
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Create an SVMClassifierWrapper instance from a configuration.
Parameters
configuration : dict Dictionary containing the configuration parameters. additional_params : dict, optional Additional parameters to include in the model initialization.
Returns
partial A partial function to create an SVMClassifierWrapper instance.
Source code in asf/predictors/svm.py
SVMRegressorWrapper
Bases: SklearnWrapper
A wrapper for the Scikit-learn SVR (Support Vector Regressor) model. Provides methods to define a configuration space and create an instance of the regressor from a configuration.
Attributes
PREFIX : str Prefix used for parameter names in the configuration space.
Source code in asf/predictors/svm.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
|
__init__(init_params={})
Initialize the SVMRegressorWrapper.
Parameters
init_params : dict, optional Dictionary of parameters to initialize the SVR model.
Source code in asf/predictors/svm.py
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Define the configuration space for the SVM regressor.
Parameters
cs : ConfigurationSpace, optional The configuration space to add the parameters to. If None, a new ConfigurationSpace will be created.
Returns
ConfigurationSpace The configuration space containing hyperparameters for the SVM regressor.
Source code in asf/predictors/svm.py
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Create an SVMRegressorWrapper instance from a configuration.
Parameters
configuration : dict Dictionary containing the configuration parameters. additional_params : dict, optional Additional parameters to include in the model initialization.
Returns
partial A partial function to create an SVMRegressorWrapper instance.
Source code in asf/predictors/svm.py
SklearnWrapper
Bases: AbstractPredictor
A generic wrapper for scikit-learn models.
This class allows scikit-learn models to be used with the ASF framework.
Methods
fit(X, Y, sample_weight=None, kwargs) Fit the model to the data. predict(X, kwargs) Predict using the model. save(file_path) Save the model to a file. load(file_path) Load the model from a file.
Source code in asf/predictors/sklearn_wrapper.py
7 8 9 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 |
|
__init__(model_class, init_params={})
Initialize the wrapper with a scikit-learn model.
Parameters
model_class : ClassifierMixin A scikit-learn model class. init_params : dict, optional Initialization parameters for the scikit-learn model (default is an empty dictionary).
Source code in asf/predictors/sklearn_wrapper.py
fit(X, Y, sample_weight=None, **kwargs)
Fit the model to the data.
Parameters
X : np.ndarray
Training data of shape (n_samples, n_features).
Y : np.ndarray
Target values of shape (n_samples,).
sample_weight : np.ndarray, optional
Sample weights of shape (n_samples,) (default is None).
**kwargs : Any
Additional keyword arguments for the scikit-learn model's fit
method.
Source code in asf/predictors/sklearn_wrapper.py
load(file_path)
Load the model from a file.
Parameters
file_path : str Path to the file from which the model will be loaded.
Returns
SklearnWrapper The loaded model.
Source code in asf/predictors/sklearn_wrapper.py
predict(X, **kwargs)
Predict using the model.
Parameters
X : np.ndarray
Data to predict on of shape (n_samples, n_features).
**kwargs : Any
Additional keyword arguments for the scikit-learn model's predict
method.
Returns
np.ndarray Predicted values of shape (n_samples,).
Source code in asf/predictors/sklearn_wrapper.py
save(file_path)
Save the model to a file.
Parameters
file_path : str Path to the file where the model will be saved.
XGBoostClassifierWrapper
Bases: SklearnWrapper
Wrapper for the XGBoost classifier to integrate with the ASF framework.
Source code in asf/predictors/xgboost.py
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
__init__(init_params=None)
Initialize the XGBoostClassifierWrapper.
Parameters
init_params : dict, optional Initialization parameters for the XGBoost classifier.
Source code in asf/predictors/xgboost.py
fit(X, Y, sample_weight=None, **kwargs)
Fit the model to the data.
Parameters
X : np.ndarray
Training data of shape (n_samples, n_features).
Y : np.ndarray
Target values of shape (n_samples,).
sample_weight : np.ndarray, optional
Sample weights of shape (n_samples,) (default is None).
**kwargs : Any
Additional keyword arguments for the scikit-learn model's fit
method.
Source code in asf/predictors/xgboost.py
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Get the configuration space for the XGBoost classifier.
Parameters
cs : ConfigurationSpace, optional The configuration space to add the parameters to. If None, a new ConfigurationSpace will be created.
Returns
ConfigurationSpace The configuration space with the XGBoost parameters.
Source code in asf/predictors/xgboost.py
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Create an XGBoostClassifierWrapper from a configuration.
Parameters
configuration : dict The configuration dictionary. additional_params : dict, optional Additional parameters to include in the configuration.
Returns
Callable[..., XGBoostClassifierWrapper] A callable that initializes the wrapper with the given configuration.
Source code in asf/predictors/xgboost.py
predict(X, **kwargs)
Predict using the model.
Parameters
X : np.ndarray
Data to predict on of shape (n_samples, n_features).
**kwargs : Any
Additional keyword arguments for the scikit-learn model's predict
method.
Returns
np.ndarray Predicted values of shape (n_samples,).
Source code in asf/predictors/xgboost.py
XGBoostRegressorWrapper
Bases: SklearnWrapper
Wrapper for the XGBoost regressor to integrate with the ASF framework.
Source code in asf/predictors/xgboost.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
__init__(init_params=None)
Initialize the XGBoostRegressorWrapper.
Parameters
init_params : dict, optional Initialization parameters for the XGBoost regressor.
Source code in asf/predictors/xgboost.py
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Get the configuration space for the XGBoost regressor.
Parameters
cs : ConfigurationSpace, optional The configuration space to add the parameters to. If None, a new ConfigurationSpace will be created.
Returns
ConfigurationSpace The configuration space with the XGBoost parameters.
Source code in asf/predictors/xgboost.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
|
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Create an XGBoostRegressorWrapper from a configuration.
Parameters
configuration : dict The configuration dictionary. additional_params : dict, optional Additional parameters to include in the configuration.
Returns
Callable[..., XGBoostRegressorWrapper] A callable that initializes the wrapper with the given configuration.