How can I split a continuous target into a train/test set such that the mean and standard deviation are the same?
이전 댓글 표시
I'm trying to do an 80-20 split on my target so that the distributions are the same. I've tried using cvpartition but I don't believe it can handle a continuous target. Suggestions to use N don't result in a split that maintains the distribution of my target
target = randn(100, 1);
cv = cvpartition(100, 'Holdout', 0.2);
train_idx = training(cv);
test_idx = test(cv);
figure;
hold on;
H_TRAIN = histogram(target(train_idx));
H_TEST = histogram(target(test_idx));
legend([H_TRAIN; H_TEST], {'Train', 'Test'});
hold off;
[h,p,ks2stat] = kstest2(target(train_idx), target(test_idx))

Running a two-sample KS-test returns that the null hypothesis that both samples came from the same continuous distribution can't be rejected, but is this the way to know for certain that my target is split correctly?
답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Hypothesis Tests에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
