Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def predict(self, X):
- # This is just a place holder so that the code still runs.
- # Your code goes here.
- for row in range(0, len(X)):
- probTrue = long(1)
- probFalse = long(1)
- probE = 0
- for column in range(0, len(X[0])):
- if(X[row][column] == 1):
- probTrue *= np.log((float(self.attributeCountTrue[column]) + 1) / (float(self.resultTrueCount) + 2))
- probFalse *= np.log((float(self.attributeCountTrue[column]) + 1) / (float(self.resultFalseCount) + 2))
- if (X[row][column] == 0):
- probTrue *= np.log(float(self.attributeCountFalse[column]) + 0) / (float(self.resultTrueCount) + 2)
- probFalse *= np.log((float(self.attributeCountFalse[column]) + 0) / (float(self.resultFalseCount) + 2))
- #print "ProbTrue = ", probTrue
- probTrue *= (self.resultTrueCount/(np.log(self.resultTrueCount+self.resultFalseCount)))
- probFalse *= (self.resultFalseCount / (np.log(self.resultTrueCount + self.resultFalseCount)))
- probE = probTrue + probFalse
- #probTrue /= probE
- #probFalse /= probE
- print "ProbTrue = ", probTrue
- print "ProbFalse = ", probFalse
- #print "ProbTrue = ", probTrue
- #print "ProbFalse = ", probFalse
- print ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement