예제 #1
0
    def test_build_cuisines(self):
        a = recipe(0, 'sweet', ['apple', 'cat', 'sky'])  
        b = recipe(450, 'this', ['boy', 'sky', 'empty']) 
        c, i = build_cuisines([a, b])
        self.assertEqual(c.keys(), ['this', 'sweet'])
        self.assertEqual(set(i), set(['apple', 'cat', 'sky', 'boy', 'empty']))

        self.assertNotEqual(i, ['apple', 'cat', 'sky', 'boy', 'sky', 'empty'])
예제 #2
0
from reader import init_data, build_cuisines, recipe
from predictor import slow_predictor, predictor
from visualizer import setup_graph, display
import time, csv

# Sets up the training and testing lists
start_time = time.time()
training_set = init_data("train.json", "train")
testing_set = init_data("test.json", "test")
print("Reading Input in --- %s seconds ---" % (time.time() - start_time))

start_time = time.time()
c, i = build_cuisines(training_set)
print("Building cuisine and ingredient lists in --- %s seconds ---" % (time.time() - start_time))

start_time = time.time()
solution = slow_predictor(testing_set, c)
# solution = predictor(tesing_set, training_set, i)
print("Predicting cuisines for the test set in --- %s seconds ---" % (time.time() - start_time))

with open("submission.csv", "w") as fp:
    a = csv.writer(fp, delimiter=",")
    a.writerows(solution)

start_time = time.time()
data_lst = []
for i, k in c.items():
    ntrace = setup_graph(k, i)
    data_lst.append(ntrace)

display(data_lst)