splitting data in to test train data when there is unbalance of data
Try to do oversampling as you have less amount of data points. Or else you can use neural network preferably MLP, That works fine with unbalanced data.
i have an unbalanced data set which has two categorical values. one has around 500 values of a particular class and other is only one single datapoint with another class.Now i would like to split this data into test train with 80-20 ratio. but since this is unbalanced , i would like to have the second class to be present in both the test and train data.
I tried using the test-train-split from sklearn, but it does not give the second class data to be present in both of them. I even tried the stratified shuffle split, but that was also not giving data as i thought.
Is there any way we can split the data from a data frame forcing both the test and train datasets to have the single datapoint?. I am new to python so having difficulty figuring it out.
the data looks like:
a  b  c  d  label
1  0  0  1   1
1  1  1  0   1 
..........
........
1  0  0   1  0.
the label has only 1 and 0 but the 0 is only one single observation but the rest of the 500 data points are having label as 1