plt ylabel("regression output"plt xlabel("input feature"plt plot( [: ] ' ' =' 'figure - linear regression using binned features and single global slope in this examplethe model learned an offset for each bintogether with slope the learned slope is downwardand shared across all the bins--there is single -axis featurewhich has single slope because the slope is shared across all binsit doesn' seem to be very helpful we would rather have separate slope for each binwe can achieve this by adding an interaction or product feature that indicates which bin data point is in and where it lies on the -axis this feature is product of the bin indicator and the original feature let' create this datasetin[ ]x_product np hstack([x_binnedx x_binned]print(x_product shapeout[ ]( the dataset now has featuresthe indicators for which bin data point is inand product of the original feature and the bin indicator you can think of the product interactions and polynomials