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
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 | |
__init__(**kwargs)
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
get_configuration_space(cs=None, pre_prefix='', parent_param=None, parent_value=None)
staticmethod
Get the configuration space for the predictor.
Parameters
cs : ConfigurationSpace or None, default=None The configuration space to add the parameters to. If None, a new configuration space will be created. pre_prefix : str, default="" Prefix for all hyperparameters. parent_param : Hyperparameter or None, default=None Parent hyperparameter for conditions. parent_value : Any or None, default=None Value of the parent hyperparameter for conditions.
Returns
ConfigurationSpace The configuration space for the predictor.
Raises
RuntimeError If ConfigSpace is not installed. NotImplementedError If the method is not implemented for the predictor.
Source code in asf/predictors/abstract_predictor.py
get_from_configuration(configuration, pre_prefix='', **kwargs)
staticmethod
Get a predictor instance from a configuration.
Parameters
configuration : dict[str, Any] The configuration to create the predictor from. pre_prefix : str, default="" Prefix used in the configuration. **kwargs : Any Additional arguments.
Returns
AbstractPredictor The predictor instance.
Raises
RuntimeError If ConfigSpace is not installed. NotImplementedError If the method is not implemented for the predictor.
Source code in asf/predictors/abstract_predictor.py
load(file_path)
abstractmethod
classmethod
Load the model from a file.
Parameters
file_path : str Path to the file from which the model will be loaded.
Returns
AbstractPredictor The loaded model.
Source code in asf/predictors/abstract_predictor.py
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, ConfigurableMixin
Implementation of Random Forest as an Empirical Performance Model (EPM).
This model follows the approach described in the paper: "Algorithm runtime prediction: Methods & evaluation" by Hutter, Xu, Hoos, and Leyton-Brown (2014).
Parameters
n_estimators : int, default=100 The number of trees in the forest. log : bool, default=False Whether to apply logarithmic transformation to the tree values. return_var : bool, default=False Whether to compute variance across trees. criterion : str, default="squared_error" The function to measure the quality of a split. splitter : str, default="random" The strategy used to choose the split at each node. max_depth : int or None, default=None The maximum depth of the tree. min_samples_split : int, default=2 The minimum number of samples required to split an internal node. min_samples_leaf : int, default=1 The minimum number of samples required to be at a leaf node. min_weight_fraction_leaf : float, default=0.0 The minimum weighted fraction of the sum total of weights required to be at a leaf node. max_features : float, default=1.0 The number of features to consider when looking for the best split. max_leaf_nodes : int or None, default=None Grow trees with max_leaf_nodes in best-first fashion. min_impurity_decrease : float, default=0.0 A node will be split if this split induces a decrease of the impurity. bootstrap : bool, default=False Whether bootstrap samples are used when building trees. oob_score : bool, default=False Whether to use out-of-bag samples to estimate the generalization score. n_jobs : int or None, default=None The number of jobs to run in parallel. random_state : int or None, default=None Controls the randomness of the estimator. verbose : int, default=0 Controls the verbosity when fitting and predicting. warm_start : bool, default=False When set to True, reuse the solution of the previous call to fit. ccp_alpha : float, default=0.0 Complexity parameter used for Minimal Cost-Complexity Pruning. max_samples : int, float or None, default=None The number of samples to draw from X to train each base estimator. monotonic_cst : np.ndarray or None, default=None Constraints for monotonicity of features.
Source code in asf/predictors/epm_random_forest.py
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 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 | |
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 or None, default=None Sample weights. Currently not supported.
Raises
AssertionError If sample weights are provided.
Source code in asf/predictors/epm_random_forest.py
load(file_path)
classmethod
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, **kwargs)
Predict using the model.
Parameters
X : np.ndarray Data to predict on of shape (n_samples, n_features).
Returns
np.ndarray or tuple[np.ndarray, np.ndarray] Predicted means, or a tuple of (means, variances) if return_var is True.
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.
LinearClassifierWrapper
Bases: ConfigurableMixin, 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
__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
LinearRegressorWrapper
Bases: ConfigurableMixin, 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
__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
MLPClassifierWrapper
Bases: ConfigurableMixin, SklearnWrapper
A wrapper for the MLPClassifier from scikit-learn.
Source code in asf/predictors/mlp.py
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 | |
__init__(init_params=None)
Initialize the MLPClassifierWrapper.
Parameters
init_params : dict[str, Any] or None, default=None 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 or None, default=None Sample weights. Not supported for MLPClassifier. **kwargs : Any Additional arguments for the fit method.
Raises
AssertionError If sample_weight is provided.
Source code in asf/predictors/mlp.py
MLPRegressorWrapper
Bases: ConfigurableMixin, SklearnWrapper
A wrapper for the MLPRegressor from scikit-learn.
Source code in asf/predictors/mlp.py
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 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 | |
__init__(init_params=None)
Initialize the MLPRegressorWrapper.
Parameters
init_params : dict[str, Any] or None, default=None 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 or None, default=None Sample weights. Not supported for MLPRegressor. **kwargs : Any Additional arguments for the fit method.
Raises
AssertionError If sample_weight is provided.
Source code in asf/predictors/mlp.py
RandomForestClassifierWrapper
Bases: ConfigurableMixin, SklearnWrapper
A wrapper for the RandomForestClassifier from scikit-learn.
Source code in asf/predictors/random_forest.py
__init__(init_params=None)
Initialize the RandomForestClassifierWrapper.
Parameters
init_params : dict[str, Any] or None, default=None A dictionary of initialization parameters for the RandomForestClassifier.
Source code in asf/predictors/random_forest.py
RandomForestRegressorWrapper
Bases: ConfigurableMixin, SklearnWrapper
A wrapper for the RandomForestRegressor from scikit-learn.
Source code in asf/predictors/random_forest.py
__init__(init_params=None)
Initialize the RandomForestRegressorWrapper.
Parameters
init_params : dict[str, Any] or None, default=None A dictionary of initialization parameters for the RandomForestRegressor.
Source code in asf/predictors/random_forest.py
RandomSurvivalForestWrapper
Bases: ConfigurableMixin, AbstractPredictor
Lightweight wrapper around sksurv's RandomSurvivalForest model.
Source code in asf/predictors/survival.py
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__(init_params=None)
Initialize the RandomSurvivalForestWrapper.
Parameters
init_params : dict[str, Any] or None, default=None Initial parameters for the RandomSurvivalForest model.
Raises
ImportError If sksurv is not installed.
Source code in asf/predictors/survival.py
fit(X, Y, **kwargs)
Fit the model to the data.
Parameters
X : Any Training data. y : Any Target values. **kwargs : Any Additional arguments for the fit method.
Source code in asf/predictors/survival.py
load(file_path)
classmethod
predict(X, **kwargs)
Predict using the model.
Parameters
X : Any Data to predict on. **kwargs : Any Additional arguments for the predict method.
Returns
Any Predicted values.
Source code in asf/predictors/survival.py
predict_survival_function(X, **kwargs)
RankingMLP
Bases: ConfigurableMixin, AbstractPredictor
A ranking-based predictor using a Multi-Layer Percetron (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
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 | |
RegressionMLP
Bases: AbstractPredictor, ConfigurableMixin
A regression-based predictor using a Multi-Layer Perceptron (MLP).
Source code in asf/predictors/regression_mlp.py
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 | |
fit(X, Y, **kwargs)
Fit the model to the data.
Parameters
X : pd.DataFrame The features for each instance. Y : pd.DataFrame The performance of each algorithm on each instance. sample_weight : np.ndarray or None, default=None Sample weights. Currently not supported. **kwargs : Any Additional arguments.
Returns
RegressionMLP The fitted model.
Raises
AssertionError If sample_weight is provided.
Source code in asf/predictors/regression_mlp.py
load(file_path)
classmethod
predict(X, **kwargs)
Predict using the model.
Parameters
X : pd.DataFrame The features to predict on. **kwargs : Any Additional arguments.
Returns
np.ndarray The predicted values.
Source code in asf/predictors/regression_mlp.py
RidgeRegressorWrapper
Bases: ConfigurableMixin, SklearnWrapper
Wrapper around scikit-learn's Ridge regressor for ASF predictors.
Source code in asf/predictors/linear_model.py
SVMClassifierWrapper
Bases: ConfigurableMixin, 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
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 | |
__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, **kwargs)
classmethod
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
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 | |
SVMRegressorWrapper
Bases: ConfigurableMixin, 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
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 330 331 332 | |
__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, **kwargs)
classmethod
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
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 | |
SklearnWrapper
Bases: AbstractPredictor
A generic wrapper for scikit-learn models.
This class allows scikit-learn models to be used with the ASF framework.
Parameters
model_class : type[BaseEstimator] A scikit-learn model class. init_params : dict[str, Any], optional Initialization parameters for the scikit-learn model (default is {}).
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 or None, default=None
Sample weights of shape (n_samples,).
**kwargs : Any
Additional keyword arguments for the scikit-learn model's fit method.
Source code in asf/predictors/sklearn_wrapper.py
load(file_path)
classmethod
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: ConfigurableMixin, SklearnWrapper
Wrapper for the XGBoost classifier to integrate with the ASF framework.
Source code in asf/predictors/xgboost.py
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 | |
__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
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: ConfigurableMixin, SklearnWrapper
Wrapper for the XGBoost regressor to integrate with the ASF framework.
Source code in asf/predictors/xgboost.py
__init__(init_params=None)
Initialize the XGBoostRegressorWrapper.
Parameters
init_params : dict, optional Initialization parameters for the XGBoost regressor.