forked from microsoft/MLOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init checkin to add LassoCV and RERF to optimizers (microsoft#263)
* init checkin to add LassoCV and RERF to optimizers * fixes to pylint catches + ... * addressing more random config failures * continued to clean up RERF hyperparam config space and restricted some values in unit tests for BayesianOptimier * fixes to pylint catches * cleaned up random model_config unit test failures in LassoCV and RERF models * force lassoCV cv parameter < num_samples * cleaned up comments, restricted sklearnRF max_samples range * correcting incorrect DEFAULT point in SKLearnRF model_config * cleaned up hypergrid adapters to solve failing random model_config optimizer tests * cleaned up pylint issues * fixed additional rerf random config failures and tried to accelerate tests * decreased num random config tested from 100 to prev 10 * fixes to allow gRPC random optimizer config unit tests to succeed * additional fixes to allow gRPC random optimizer config unit tests to succeed * reduced unit test duration by reducing train/test sizes in new optimizers * addressing review feedback Co-authored-by: Ed Thayer <edthaye@microsoft.com>
- Loading branch information
Showing
15 changed files
with
468 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
source/Mlos.Python/mlos/Optimizers/RegressionModels/MultiObjectiveLassoCrossValidated.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# | ||
import logging | ||
from mlos.Optimizers.RegressionModels.LassoCrossValidatedConfigStore import lasso_cross_validated_config_store | ||
from mlos.Optimizers.RegressionModels.LassoCrossValidatedRegressionModel import LassoCrossValidatedRegressionModel | ||
from mlos.Optimizers.RegressionModels.NaiveMultiObjectiveRegressionModel import NaiveMultiObjectiveRegressionModel | ||
from mlos.Spaces import Hypergrid, Point, SimpleHypergrid | ||
|
||
|
||
class MultiObjectiveLassoCrossValidated(NaiveMultiObjectiveRegressionModel): | ||
"""Maintains multiple LassoCrossValidatedRegressionModels each predicting a different objective. | ||
All single-objective models are configured according to model_config. | ||
""" | ||
def __init__( | ||
self, | ||
model_config: Point, | ||
input_space: Hypergrid, | ||
output_space: Hypergrid, | ||
logger: logging.Logger = None | ||
): | ||
NaiveMultiObjectiveRegressionModel.__init__( | ||
self, | ||
model_type=LassoCrossValidatedRegressionModel, | ||
model_config=model_config, | ||
input_space=input_space, | ||
output_space=output_space, | ||
logger=logger | ||
) | ||
|
||
|
||
# We just need to assert that the model config belongs in lasso_cross_validated_config_store.parameter_space. | ||
# A more elaborate solution might be needed down the road, but for now this simple solution should suffice. | ||
# | ||
assert model_config in lasso_cross_validated_config_store.parameter_space | ||
|
||
for output_dimension in output_space.dimensions: | ||
print(f'output_dimension.name: {output_dimension.name}') | ||
lasso_model = LassoCrossValidatedRegressionModel( | ||
model_config=model_config, | ||
input_space=input_space, | ||
output_space=SimpleHypergrid(name=f"{output_dimension.name}_objective", dimensions=[output_dimension]), | ||
logger=self.logger | ||
) | ||
self._regressors_by_objective_name[output_dimension.name] = lasso_model |
Oops, something went wrong.