Ejemplo n.º 1
0
def main(argv):
    goal, mode = '', ''
    nn_name, rf_name = [], []
    number = 10

    try:
        opts, args = getopt.getopt(
            argv, "s:r:n:m:e:",
            ["size=", "randomforest=", "neuralnetwork=", "mode=", "elements="])
    except getopt.GetoptError:
        print(
            'Error. Command line structure: Main.py -s <size> -r <random forest model> -n <neural network model>'
            '-m <[Learn, Compare]>, -e <number of elements to compare>]')
        sys.exit(2)

    for opt, arg in opts:
        if opt in ('-s', '-size'):
            goal = generate_goal(int(arg))
        elif opt == '-r':
            rf_name = arg.split(',')
        elif opt == '-n':
            nn_name = arg.split(',')
        elif opt in ('-m', '--mode'):
            mode = arg.lower()
        elif opt in ('-e', '-elements'):
            number = int(arg)

    if goal == '':
        goal = generate_goal(4)

    if not rf_name and not nn_name:
        print(
            "Error. Please give the name for random forest model (rf <name>) or neural network model (nn <name>)"
        )
        sys.exit(0)

    if mode in ('l', 'learn'):
        learn(nn_name, rf_name, goal)
    elif mode in ('c', 'compare'):
        compare(number, nn_name, rf_name, goal)
    else:
        print("Error. Mode can be L (Learn), or C (Compare)")
        sys.exit(0)
Ejemplo n.º 2
0
 def test_generate_goal_6(self):
     test_goal = generate_goal(6)
     self.assertEqual(test_goal, self.goal_6)
Ejemplo n.º 3
0
 def test_generate_goal_4(self):
     test_goal = generate_goal(4)
     self.assertEqual(test_goal, self.goal_4)
Ejemplo n.º 4
0
 def test_generate_goal_5(self):
     test_goal = generate_goal(5)
     self.assertEqual(test_goal, self.goal_5)
Ejemplo n.º 5
0
 def test_generate_goal_3(self):
     test_goal = generate_goal(3)
     self.assertEqual(test_goal, self.goal_3)