Stratification of the continuous y (target) variable in regression setting Is it wise to stratify the continuous y (target) variable when you split your training and testing data from the total sample in regression setting? Here is the approach in python to do implement stratify the continuous target:
In Python (with the same libraries loaded as in the prior code snippet):

# Create the bins.  My `y` variable has
# 506 observations, and I want 50 bins.

bins = np.linspace(0, 506, 50)

# Save your Y values in a new ndarray,
# broken down by the bins created above.

y_binned = np.digitize(y, bins)

# Pass y_binned to the stratify argument,
# and sklearn will handle the rest

X_train, X_test, y_train, y_test = train_test_split(df, y, test_size=0.3, stratify=y_binned)

There you have it: stratification of a continuous numerical target value. However, I am not confident with this approach although stratification of the binary response variable is very common in classification setting to tackle class imbalance issues. I appreciate your suggestions!

You are right, it's not common at all, but what you do makes sense though it may be sensitive to your binning strategy. So, it's also a good idea to plot your binned target variable. This stratification makes more sense when the target variable is so skewed such that sometimes some folds do not get enough samples from some regions of the target variable.
