def fit(self, X, y): '''X and y are as in sklearn classifier.fit expected arguments Creates a decision tree ''' "*** YOUR CODE HERE AS NEEDED***" self.clf = self.makeTree(X, y, self.attribute_list, self.attrib_dict, self.default_value) mlUtil.raiseNotDefined()
def classify(self, x, attributes, default_value): ''' return the value for the given data the input will be: x - an object to classify - [v1, v2, ..., vn] attributes - the names of all the attributes ''' "*** YOUR CODE HERE ***" mlUtil.raiseNotDefined()
def __init__(self, attrib_d=None, attribs=None, default_v=None): ''' initialize classifier ''' if not attribs: attribs = [] if attrib_d: self.attrib_dict = attrib_d else: self.attrib_dict = {} self.attribute_list = attribs self.default_value = default_v "*** YOUR CODE HERE AS NEEDED ***" mlUtil.raiseNotDefined()
def predict(self, X): ''' Return a class label using the decision tree created by the fit method ''' "*** YOUR CODE HERE AS NEEDED***" #call recursive classify method on the learned tree for each x in X mlUtil.raiseNotDefined()
def makeTree(self, dataset, labels, attributes, attrib_dict, defaultValue): ''' Helper recursive function for creating a tree ''' "*** YOUR CODE HERE ***" mlUtil.raiseNotDefined()