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

Error message on K means clustering #794

Open
Selphie14100 opened this issue Mar 20, 2025 · 1 comment
Open

Error message on K means clustering #794

Selphie14100 opened this issue Mar 20, 2025 · 1 comment

Comments

@Selphie14100
Copy link

Error for 55_NearestNeighbors

The least populated class in y has only 1 member, which is too few. The minimum number of groups for any class cannot be less than 2.
Traceback (most recent call last):
File "C:\Users\User\anaconda3\lib\site-packages\supervised\base_automl.py", line 1095, in _fit
trained = self.train_model(params)
File "C:\Users\User\anaconda3\lib\site-packages\supervised\base_automl.py", line 380, in train_model
mf.train(results_path, model_subpath)
File "C:\Users\User\anaconda3\lib\site-packages\supervised\model_framework.py", line 233, in train
learner.fit(
File "C:\Users\User\anaconda3\lib\site-packages\supervised\algorithms\knn.py", line 50, in fit
X1, _, y1, _ = train_test_split(
File "C:\Users\User\anaconda3\lib\site-packages\sklearn\model_selection_split.py", line 2583, in train_test_split
train, test = next(cv.split(X=arrays[0], y=stratify))
File "C:\Users\User\anaconda3\lib\site-packages\sklearn\model_selection_split.py", line 1689, in split
for train, test in self._iter_indices(X, y, groups):
File "C:\Users\User\anaconda3\lib\site-packages\sklearn\model_selection_split.py", line 2078, in _iter_indices
raise ValueError(
ValueError: The least populated class in y has only 1 member, which is too few. The minimum number of groups for any class cannot be less than 2.

@pplonski
Copy link
Contributor

Hi @Selphie14100

Thanks for creating the issue. Is your dataset imbalanced? Looks like there was a split, with only one class in training data that's why a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants