Getting an error in classification tree with sklearn, Dr Chan's course

Hello



I am taking Dr Chan's new course on Machine learning. I am trying to do a classification tree train/split with scikit learn, following along the example of the ACC stock. I am getting the following error. I think this is not due to me doing anythign wrong but rather something to do with the dataset being not optimal for this model. But I would appreciate it if you could guide me through what exactly is happening here, and what steps should I take to rectify this issue- 

 

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.

Thanks

Hi Abhinav,



Can you please check the number of instances in the y for the two classes. The error basically means that you have only one data point which belongs to a class and rest of them belonging to another class. The model needs to have a few more data points, preferably more than 20 for each class.

Thank you, i got it. I was looking at returns and thinking that Python would by itself put the negatives and positives in different classes, but I realized that I had to transform them into 1 and 0. Thanks for your help.