Skip to content

Instantly share code, notes, and snippets.

@kvorion
Created December 7, 2010 05:06

Revisions

  1. kvorion created this gist Dec 7, 2010.
    10 changes: 10 additions & 0 deletions naivebayes-getvalues.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    def GetValues(self):
    file = open(self.trainingFile, 'r')
    for line in file:
    if line[0] != '@': #start of actual data
    self.featureVectors.append(line.strip().lower().split(','))
    else: #feature definitions
    if line.strip().lower().find('@data') == -1 and (not line.lower().startswith('@relation')):
    self.featureNameList.append(line.strip().split()[1])
    self.features[self.featureNameList[len(self.featureNameList) - 1]] = line[line.find('{')+1: line.find('}')].strip().split(',')
    file.close()