Created
December 7, 2010 05:09
-
-
Save kvorion/731487 to your computer and use it in GitHub Desktop.
trainclassifier method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def TrainClassifier(self): | |
for fv in self.featureVectors: | |
self.labelCounts[fv[len(fv)-1]] += 1 #udpate count of the label | |
for counter in range(0, len(fv)-1): | |
self.featureCounts[(fv[len(fv)-1], self.featureNameList[counter], fv[counter])] += 1 | |
for label in self.labelCounts: #increase label counts (smoothing). remember that the last feature is actually the label | |
for feature in self.featureNameList[:len(self.featureNameList)-1]: | |
self.labelCounts[label] += len(self.features[feature]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment