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

Method predict

supervised_class/bayes.py:36–43  ·  view source on GitHub ↗
(self, X)

Source from the content-addressed store, hash-verified

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

Callers 1

scoreMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected