Skip to content

Commit

Permalink
Rename methods to be Pareto set methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mfeurer committed May 30, 2022
1 parent d8a863c commit 0ba05e9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions autosklearn/automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1651,9 +1651,9 @@ def _load_best_individual_model(self):
)
return ensemble

def _load_pareto_front(self) -> Sequence[VotingClassifier | VotingRegressor]:
def _load_pareto_set(self) -> Sequence[VotingClassifier | VotingRegressor]:
if len(self._metrics) <= 1:
raise ValueError("Pareto front is only available for two or more metrics.")
raise ValueError("Pareto set is only available for two or more metrics.")

if self._ensemble_class is not None:
self.ensemble_ = self._backend.load_ensemble(self._seed)
Expand All @@ -1664,22 +1664,22 @@ def _load_pareto_front(self) -> Sequence[VotingClassifier | VotingRegressor]:
if not self.ensemble_:

raise ValueError(
"Pareto front can only be accessed if an ensemble is available."
"Pareto set can only be accessed if an ensemble is available."
)

if isinstance(self.ensemble_, AbstractMultiObjectiveEnsemble):
pareto_front = self.ensemble_.get_pareto_front()
pareto_set = self.ensemble_.get_pareto_set()
else:
self._logger.warning(
"Pareto front not available for single objective ensemble "
"method. The Pareto front will only include the single ensemble "
"Pareto set not available for single objective ensemble "
"method. The Pareto set will only include the single ensemble "
"constructed by %s",
type(self.ensemble_),
)
pareto_front = [self.ensemble_]
pareto_set = [self.ensemble_]

ensembles = []
for ensemble in pareto_front:
for ensemble in pareto_set:
identifiers = ensemble.get_selected_model_identifiers()
weights = {
identifier: weight
Expand Down
2 changes: 1 addition & 1 deletion autosklearn/ensembles/abstract_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,5 @@ def get_validation_performance(self) -> float:


class AbstractMultiObjectiveEnsemble(AbstractEnsemble):
def get_pareto_front(self) -> Sequence[AbstractEnsemble]:
def get_pareto_set(self) -> Sequence[AbstractEnsemble]:
pass
4 changes: 2 additions & 2 deletions autosklearn/estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,8 @@ def get_configuration_space(
else self.automl_.configuration_space
)

def get_pareto_front(self) -> Sequence[VotingClassifier | VotingRegressor]:
return self.automl_._load_pareto_front()
def get_pareto_set(self) -> Sequence[VotingClassifier | VotingRegressor]:
return self.automl_._load_pareto_set()


class AutoSklearnClassifier(AutoSklearnEstimator, ClassifierMixin):
Expand Down
8 changes: 4 additions & 4 deletions examples/40_advanced/example_multi_objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
in the `scikit-learn docs <https://scikit-learn.org/stable/auto_examples/model_selection/plot_precision_recall.html>`_.
Auto-sklearn uses `SMAC3's implementation of ParEGO <https://automl.github.io/SMAC3/main/details/multi_objective.html>`_.
Multi-objective ensembling and proper access to the full Pareto front will be added in the near
Multi-objective ensembling and proper access to the full Pareto set will be added in the near
future.
"""
from pprint import pprint
Expand Down Expand Up @@ -71,10 +71,10 @@
pprint(automl.cv_results_)

############################################################################
# Visualize the Pareto front
# Visualize the Pareto set
# ==========================
plot_values = []
pareto_front = automl.get_pareto_front()
pareto_front = automl.get_pareto_set()
for ensemble in pareto_front:
predictions = ensemble.predict(X_test)
precision = sklearn.metrics.precision_score(y_test, predictions)
Expand All @@ -86,5 +86,5 @@
ax.scatter(precision, recall, c="blue")
ax.set_xlabel("Precision")
ax.set_ylabel("Recall")
ax.set_title("Pareto front")
ax.set_title("Pareto set")
plt.show()
2 changes: 1 addition & 1 deletion test/test_automl/test_post_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test__load_pareto_front(automl: AutoML) -> None:
assert automl.predict_proba(X).shape == (1, 3)
assert automl.predict(X).shape == (1,)

pareto_front = automl._load_pareto_front()
pareto_front = automl._load_pareto_set()
assert len(pareto_front) == 1
for ensemble in pareto_front:
assert isinstance(ensemble, (VotingClassifier, VotingRegressor))
Expand Down

0 comments on commit 0ba05e9

Please sign in to comment.