Skip to content

Commit 961ca48

Browse files
committed
chcek array added
1 parent d8cb8b0 commit 961ca48

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/linearboost/linear_boost.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
RobustScaler,
3636
StandardScaler,
3737
)
38-
from sklearn.utils import compute_sample_weight
38+
from sklearn.utils import compute_sample_weight, check_array
3939
from sklearn.utils._param_validation import Interval, StrOptions
4040
from sklearn.utils.multiclass import check_classification_targets, type_of_target
4141
from sklearn.utils.validation import check_is_fitted
@@ -271,12 +271,14 @@ def _check_X_y(self, X, y) -> tuple[np.ndarray, np.ndarray]:
271271
def fit(self, X, y, sample_weight=None) -> Self:
272272
if self.algorithm not in {"SAMME", "SAMME.R"}:
273273
raise ValueError("algorithm must be 'SAMME' or 'SAMME.R'")
274+
X = check_array(X, accept_sparse=True)
275+
y = np.asarray(y)
274276
if sample_weight is not None:
277+
sample_weight = np.asarray(sample_weight)
275278
nonzero_mask = sample_weight != 0
276279
X = X[nonzero_mask]
277280
y = y[nonzero_mask]
278281
sample_weight = sample_weight[nonzero_mask]
279-
280282
X, y = self._check_X_y(X, y)
281283
self.classes_ = np.unique(y)
282284
self.n_classes_ = self.classes_.shape[0]

0 commit comments

Comments
 (0)