This error occurs when the value of 'n_samples' is set to 0 and both 'test_size' and 'train_size' are not specified or set to their default values. In this case, the resulting train set will be empty as there are no samples to split between the train and test sets.

To fix this error, you can either increase the value of 'n_samples' or adjust the values of 'test_size' and 'train_size'. If you want to split your data into a train and test set, you need to have enough samples to allocate to both sets.

For example, if you have only one sample in your data, you cannot split it into a train and test set with a 'test_size' of 0.1 as there will not be enough samples for both sets. In this case, you can either use the entire sample as the train or test set or collect more samples to split between the sets.

Alternatively, you can adjust the values of 'test_size' and 'train_size' to ensure that there are enough samples for both sets. For example, if you have 10 samples in your data, you can set 'test_size'=0.2 and 'train_size'=0.8 to allocate 2 samples to the test set and 8 samples to the train set.

ValueError: Empty Train Set in Python Machine Learning

原文地址: https://www.cveoy.top/t/topic/ov7v 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录