Skip to content

Instantly share code, notes, and snippets.

@kvorion
Created December 7, 2010 04:52
Show Gist options
  • Save kvorion/731471 to your computer and use it in GitHub Desktop.
Save kvorion/731471 to your computer and use it in GitHub Desktop.
the model class
from __future__ import division
import collections
import math
class Model:
def __init__(self, arffFile):
self.trainingFile = arffFile
self.features = {} #all feature names and their possible values (including the class label)
self.featureNameList = [] #this is to maintain the order of features as in the arff
self.featureCounts = collections.defaultdict(lambda: 1)#contains tuples of the form (label, feature_name, feature_value)
self.featureVectors = [] #contains all the values and the label as the last entry
self.labelCounts = collections.defaultdict(lambda: 0) #these will be smoothed later
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment