Exemplo n.º 1
0
	def evaluate(self):
		# split contains list of lists i.e, list of [train, test]
		split = self.split_data(self.points)

		open("output/accuracy_%s_%s.csv" % (self.name, self.method), 'w').close()

		for train, test in split:
			dtree = decision_tree(self.all_data, self.features, self.categories, self.method, len(train))
			Decision_tree = dtree.build_decision_tree(train)
			self.get_accuracy(Decision_tree, test)
Exemplo n.º 2
0
    def evaluate(self):
        # split contains list of lists i.e, list of [train, test]
        split = self.split_data(self.points)

        open("output/accuracy_%s_%s.csv" % (self.name, self.method),
             'w').close()

        for train, test in split:
            dtree = decision_tree(self.all_data, self.features,
                                  self.categories, self.method, len(train))
            Decision_tree = dtree.build_decision_tree(train)
            self.get_accuracy(Decision_tree, test)
Exemplo n.º 3
0
def evaluate(path, name, method, k):
    Data, points_index, points, features, categories = get_data(
        path, name, method)
    split = split_data(points, k)

    open("output/accuracy_%s_%s.csv" % (name, method), 'w').close()
    # split contains list of lists i.e, list of [train, test]
    accuracy = []

    for train, test in split:
        dtree = decision_tree(Data, features, categories, method, len(train))
        Decision_tree = dtree.build_decision_tree(train)
        get_accuracy(Decision_tree, Data, test, features, name, method)
Exemplo n.º 4
0
    def evaluate(self):
        # split contains list of lists i.e, list of [train, test]
        split = self.split_data(self.points)

        open(
            "output/accuracy_%s_%s_%s.csv" %
            (self.name, self.method, self.beam_size), 'w').close()

        for train, test in split:

            # Generate initial set of trees
            dtree = decision_tree(self.all_data,
                                  self.features, self.categories, self.method,
                                  len(train), self.beam_size)

            trees, keep_going = dtree.initialize_trees(train)
            trees, prev_acc = self.keep_best_m(trees, train)

            acc_sum = [sum(prev_acc)]

            # Iterate till we can not improve further
            while keep_going:
                tmp_trees = []
                keep_going = False
                for tree in trees:
                    new_trees, going = dtree.extend(tree)
                    tmp_trees += new_trees
                    keep_going = keep_going or going
                trees, curr_acc = self.keep_best_m(tmp_trees, train)
                acc_sum.append(sum(curr_acc))
                if len(acc_sum) > 2:
                    if acc_sum[-1] - acc_sum[-3] <= 0:
                        keep_going = False
                i = 0
                while i < len(curr_acc) and curr_acc[i] == 1:
                    i += 1
                if i == len(curr_acc):
                    keep_going = False
            # trees has forest of trees

            # As we have final set of trees, checking accuracy and generating results.
            self.get_accuracy(trees, test)