Add new skl model attribute for number of features (#5780)
This commit is contained in:
@@ -499,6 +499,8 @@ class XGBModel(XGBModelBase):
|
||||
|
||||
[xgb.callback.reset_learning_rate(custom_rates)]
|
||||
"""
|
||||
self.n_features_in_ = X.shape[1]
|
||||
|
||||
train_dmatrix = DMatrix(data=X, label=y, weight=sample_weight,
|
||||
base_margin=base_margin,
|
||||
missing=self.missing,
|
||||
@@ -812,7 +814,10 @@ class XGBClassifier(XGBModel, XGBClassifierBase):
|
||||
# different ways of reshaping
|
||||
raise ValueError(
|
||||
'Please reshape the input data X into 2-dimensional matrix.')
|
||||
|
||||
self._features_count = X.shape[1]
|
||||
self.n_features_in_ = self._features_count
|
||||
|
||||
train_dmatrix = DMatrix(X, label=training_labels, weight=sample_weight,
|
||||
base_margin=base_margin,
|
||||
missing=self.missing, nthread=self.n_jobs)
|
||||
@@ -1195,6 +1200,8 @@ class XGBRanker(XGBModel):
|
||||
ret.set_group(group)
|
||||
return ret
|
||||
|
||||
self.n_features_in_ = X.shape[1]
|
||||
|
||||
train_dmatrix = DMatrix(data=X, label=y, weight=sample_weight,
|
||||
base_margin=base_margin,
|
||||
missing=self.missing, nthread=self.n_jobs)
|
||||
|
||||
Reference in New Issue
Block a user