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

Method predict

supervised_class/nb.py:34–41  ·  view source on GitHub ↗
(self, X)

Source from the content-addressed store, hash-verified

32 return np.mean(P == Y)
33
34 def predict(self, X):
35 N, D = X.shape
36 K = len(self.gaussians)
37 P = np.zeros((N, K))
38 for c, g in iteritems(self.gaussians):
39 mean, var = g['mean'], g['var']
40 P[:,c] = mvn.logpdf(X, mean=mean, cov=var) + np.log(self.priors[c])
41 return np.argmax(P, axis=1)
42
43
44if __name__ == '__main__':

Callers 1

scoreMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected