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

[CI] Fix pylint. #10296

Merged
merged 1 commit into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions python-package/xgboost/spark/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ def _validate_and_convert_feature_col_as_array_col(
(DoubleType, FloatType, LongType, IntegerType, ShortType),
):
raise ValueError(
"If feature column is array type, its elements must be number type."
"If feature column is array type, its elements must be number type, "
f"got {features_col_datatype.elementType}."
)
features_array_col = features_col.cast(ArrayType(FloatType())).alias(alias.data)
elif isinstance(features_col_datatype, VectorUDT):
Expand Down Expand Up @@ -1379,15 +1380,15 @@ def _transform(self, dataset: DataFrame) -> DataFrame:
# to avoid the `self` object to be pickled to remote.
xgb_sklearn_model = self._xgb_sklearn_model

has_base_margin = False
base_margin_col = None
if (
self.isDefined(self.base_margin_col)
and self.getOrDefault(self.base_margin_col) != ""
):
has_base_margin = True
base_margin_col = col(self.getOrDefault(self.base_margin_col)).alias(
alias.margin
)
has_base_margin = base_margin_col is not None

features_col, feature_col_names = self._get_feature_col(dataset)
enable_sparse_data_optim = self.getOrDefault(self.enable_sparse_data_optim)
Expand Down Expand Up @@ -1472,6 +1473,7 @@ def to_gpu_if_possible(data: ArrayLike) -> ArrayLike:
yield predict_func(model, X, base_margin)

if has_base_margin:
assert base_margin_col is not None
pred_col = predict_udf(struct(*features_col, base_margin_col))
else:
pred_col = predict_udf(struct(*features_col))
Expand Down
Loading