This function performs stratified sampling based on the provided target vector. The sampling is done proportionally to the distribution of values in the target vector.
stratified_sample(target_vec, n_sample)A vector of indices representing the sampled observations.
A vector representing the target variable used for stratification. The function will sample from each class (level) proportionally.
The total number of samples to draw.