Skip to content

Commit 0fdd4c1

Browse files
committed
check_X_y added
1 parent 961ca48 commit 0fdd4c1

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
@@ -271,10 +271,12 @@ 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)
274+
X, y = check_X_y(X, y, accept_sparse=True)
275+
276276
if sample_weight is not None:
277277
sample_weight = np.asarray(sample_weight)
278+
if sample_weight.shape[0] != X.shape[0]:
279+
raise ValueError(f"sample_weight.shape == {sample_weight.shape} is incompatible with X.shape == {X.shape}")
278280
nonzero_mask = sample_weight != 0
279281
X = X[nonzero_mask]
280282
y = y[nonzero_mask]

0 commit comments

Comments
 (0)