MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / confusion_matrix

Method confusion_matrix

bayesian_ml/1/nb.py:78–85  ·  view source on GitHub ↗
(self, X, Y)

Source from the content-addressed store, hash-verified

76 return np.mean(self.predict(X) == Y)
77
78 def confusion_matrix(self, X, Y):
79 P = self.predict(X)
80 M = np.zeros((2, 2))
81 M[0,0] = np.sum(P[Y == 0] == Y[Y == 0])
82 M[0,1] = np.sum(P[Y == 0] != Y[Y == 0])
83 M[1,0] = np.sum(P[Y == 1] != Y[Y == 1])
84 M[1,1] = np.sum(P[Y == 1] == Y[Y == 1])
85 return M
86
87 def get_3_misclassified(self, X, Y):
88 P = self.predict(X)

Callers 1

nb.pyFile · 0.45

Calls 1

predictMethod · 0.95

Tested by

no test coverage detected