With n_samples=0, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.
时间: 2024-06-07 18:07:38 浏览: 252
This error occurs because when `n_samples=0` and `test_size=0.2`, the number of samples in the test set will be 0, which means the number of samples in the training set will be equal to the total number of samples in the dataset. If `train_size=None` (which is the default), it will try to set the training set size to the remaining samples after the test set has been extracted, but since there are no remaining samples, the training set will be empty.
To resolve this issue, you need to adjust either `n_samples` or `test_size` to ensure that there are enough samples in both the training and test sets. You may also want to set `train_size` to a specific value to ensure that the training set is not empty. For example, you could set `n_samples=100`, `test_size=0.2`, and `train_size=0.8` to split the dataset into 80% training and 20% test sets with a total of 100 samples.
阅读全文