Skip to content

Commit

Permalink
Add log metric (#1125)
Browse files Browse the repository at this point in the history
* Add original metric to mlflow logging

* Update metric
  • Loading branch information
thinkall authored Jul 13, 2023
1 parent ac7c413 commit 8ac9a39
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions flaml/automl/automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,7 @@ def is_to_reverse_metric(metric, task):
else:
error_metric = "customized metric"
logger.info(f"Minimizing error metric: {error_metric}")
self._state.error_metric = error_metric

is_spark_dataframe = isinstance(X_train, psDataFrame) or isinstance(dataframe, psDataFrame)
estimator_list = task.default_estimator_list(estimator_list, is_spark_dataframe)
Expand Down Expand Up @@ -2159,6 +2160,14 @@ def _log_trial(self, search_state, estimator):
mlflow.log_metric("best_validation_loss", search_state.best_loss)
mlflow.log_param("best_config", search_state.best_config)
mlflow.log_param("best_learner", self._best_estimator)
mlflow.log_metric(
self._state.metric if isinstance(self._state.metric, str) else self._state.error_metric,
1 - search_state.val_loss
if self._state.error_metric.startswith("1-")
else -search_state.val_loss
if self._state.error_metric.startswith("-")
else search_state.val_loss,
)

def _search_sequential(self):
try:
Expand Down

0 comments on commit 8ac9a39

Please sign in to comment.