Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename _get_args_for_metrics to _get_X_y_and_sample_weight #5106

Merged
merged 5 commits into from Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions mlflow/sklearn/__init__.py
Expand Up @@ -1196,8 +1196,8 @@ def _autolog(
_MIN_SKLEARN_VERSION,
_TRAINING_PREFIX,
_is_supported_version,
_get_X_y_and_sample_weight,
_gen_xgboost_sklearn_estimators_to_patch,
_get_args_for_metrics,
_log_estimator_content,
_all_estimators,
_get_estimator_info_tags,
Expand Down Expand Up @@ -1233,7 +1233,7 @@ def fit_mlflow_xgboost(original, self, *args, **kwargs):
# are done in `train()` in `mlflow.xgboost.autolog()`
fit_output = original(self, *args, **kwargs)
# log models after training
X = _get_args_for_metrics(self.fit, args, kwargs)[0]
X = _get_X_y_and_sample_weight(self.fit, args, kwargs)[0]
if log_models:
input_example, signature = resolve_input_example_and_signature(
lambda: X[:INPUT_EXAMPLE_SAMPLE_ROWS],
Expand Down Expand Up @@ -1322,7 +1322,7 @@ def infer_model_signature(input_example):

return infer_signature(input_example, estimator.predict(input_example))

(X, y_true, sample_weight) = _get_args_for_metrics(estimator.fit, args, kwargs)
(X, y_true, sample_weight) = _get_X_y_and_sample_weight(estimator.fit, args, kwargs)

# log common metrics and artifacts for estimators (classifier, regressor)
logged_metrics = _log_estimator_content(
Expand Down
4 changes: 2 additions & 2 deletions mlflow/sklearn/utils.py
Expand Up @@ -58,9 +58,9 @@ def _get_estimator_info_tags(estimator):
}


def _get_args_for_metrics(fit_func, fit_args, fit_kwargs):
def _get_X_y_and_sample_weight(fit_func, fit_args, fit_kwargs):
"""
Get arguments to pass to metric computations in the following steps.
Get a tuple of (X, y, sample_weight) in the following steps.

1. Extract X and y from fit_args and fit_kwargs.
2. If the sample_weight argument exists in fit_func,
Expand Down