Пример #1
0
	def process_gd_algo(self, res_file):
		start = time.clock()
		train, train_index = self._get_train()
		test, test_index = self._get_test()

		gd = GDAlgorithm()
		res = gd.process(train, test, test_index)

		with open(res_file, "w") as f:
			for r in res:
				f.write('{} {} {}\n'.format(r[0], r[1], r[2]))

		end = time.clock()
		print "[log] process Matrix Decompose algorithm done, time spent %0.2f seconds." % (end - start)
Пример #2
0
    def process_gd_algo(self, res_file):
        start = time.clock()
        train, train_index = self._get_train()
        test, test_index = self._get_test()

        gd = GDAlgorithm()
        res = gd.process(train, test, test_index)

        with open(res_file, "w") as f:
            for r in res:
                f.write('{} {} {}\n'.format(r[0], r[1], r[2]))

        end = time.clock()
        print "[log] process Matrix Decompose algorithm done, time spent %0.2f seconds." % (
            end - start)
Пример #3
0
	def compare_kr(self, res_file):
		train, train_index = self._get_train()
		test, test_index = self._get_test()

		res_list = []
		ks = [10, 20, 30, 40, 50, 60, 70]
		rs = [0.001, 0.01, 0.025, 0.05, 0.075, 0.10]
		for k in ks:
			r = 0.01
			gd = GDAlgorithm(k=k, lamb=r, compare=True)
			res = gd.process(train, test, test_index)
			res_list.append((k, res[len(res)-1][2]))

		for r in rs:
			k = 50
			gd = GDAlgorithm(k=k, lamb=r, compare=True)
			res = gd.process(train, test, test_index)
			res_list.append((r, res[len(res)-1][2]))

		with open(res_file, "w") as f:
			for r in res_list:
				f.write('{} {}\n'.format(r[0], r[1]))
Пример #4
0
    def compare_kr(self, res_file):
        train, train_index = self._get_train()
        test, test_index = self._get_test()

        res_list = []
        ks = [10, 20, 30, 40, 50, 60, 70]
        rs = [0.001, 0.01, 0.025, 0.05, 0.075, 0.10]
        for k in ks:
            r = 0.01
            gd = GDAlgorithm(k=k, lamb=r, compare=True)
            res = gd.process(train, test, test_index)
            res_list.append((k, res[len(res) - 1][2]))

        for r in rs:
            k = 50
            gd = GDAlgorithm(k=k, lamb=r, compare=True)
            res = gd.process(train, test, test_index)
            res_list.append((r, res[len(res) - 1][2]))

        with open(res_file, "w") as f:
            for r in res_list:
                f.write('{} {}\n'.format(r[0], r[1]))