I have trained a machine learning binary classifier on a 100x85 array in sklearn. I would like to be able to vary 2 of the features in the array, say column 0 and column 1, and generate contour or surface graph, showing how the predicted probability of falling in one category varies across the surface.
It seems reasonable to me that I would use something like the following:
X = 100 x 85 array of data used for training set clf = Trained 2-class classifier
x = np.array(X)
y = np.array(X)
x[:,0] = np.linspace(0, 100, 100)
y[:,1] = np.linspace(0, 100, 100)
xx, yy = meshgrid(x,y)
The next step would be to use
clf.predict_proba(<input arrays>)
followed by plotting, but using meshgrid results in two 8500x8500 matrices that can't be used in my classifier.
How do I get the necessary 100x85 vector at each point in the grid to use pred_proba with my classifier?
Thanks for any help you can provide.
As @wflynny says above, you need to give
np.meshgrid
two 1D arrays. We can useX.shape
to create yourx
andy
arrays, like this: