Asking the code for range_features

Dear experts,

I cannot understnad the reason for -1 and +1 in the code of the range_features in both lecture and execrise as below:

range_features = {
    feature_name: (data[feature_name].min() - 1, data[feature_name].max() + 1)

Could you guild me on this? Thank you.

Hi YuChi,
the range_features are used in the plot_decision_function to create a plot grid.

# create a grid to evaluate all possible samples
plot_step = 0.02
xx, yy = np.meshgrid(
    np.arange(*range_features[feature_names[0]], plot_step),
    np.arange(*range_features[feature_names[1]], plot_step),
)

Just change the value from +/- 1 to +/- 3 and look what happens, it only widens the view into the dataset.

1 Like

Hi @ThomasLoock
Is there any reason why must -1 and +1 for range_features, after getting the min and max of the x variables?

just to have a larger range for visualization purpose

1 Like