Skip to content

Commit d00b0d1

Browse files
committed
Modelvis
1 parent 54fec24 commit d00b0d1

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

modelvis.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,16 @@ def visClassifier2d(X, y, clf):
1717
plt.contourf(xx1, xx2, z, cmap='viridis', alpha = 0.3)
1818
plt.scatter(X[:,0], X[:,1], c = y, s = 50, cmap='bwr')
1919
plt.show()
20-
20+
21+
22+
def visClassifier2dProb(X, y, clf):
23+
s = 1.1
24+
x1_min, x1_max = X[:,0].min()*s, X[:,0].max()*s
25+
x2_min, x2_max = X[:,1].min()*s, X[:,1].max()*s
26+
xx1, xx2 = np.meshgrid(np.arange(x1_min, x1_max, (x1_max - x1_min)/100),
27+
np.arange(x2_min, x2_max, (x2_max - x2_min)/100))
28+
z = clf.predict_proba(np.c_[xx1.ravel(), xx2.ravel()])[:,0]
29+
z = z.reshape(xx1.shape)
30+
plt.contourf(xx1, xx2, z, cmap='viridis', alpha = 0.3)
31+
plt.scatter(X[:,0], X[:,1], c = y, s = 50, cmap='bwr')
32+
plt.show()

0 commit comments

Comments
 (0)