group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-s', '--synthetic', type=str, help='Create a synthetic dataset with the given parameters')
group.add_argument('-l', '--load-arff', type=str, help='Load dataset from arff file with the given name')
parser.add_argument('-d', '--percentage-data', type=float, required=True, help='The percentage of data used')
parser.add_argument('parameter', metavar='parameter', nargs='*', help='Parameters to the algorithm in the form <param_name>:<int|float>:<number>')

args = parser.parse_args()

classifier = name_to_classifier_object(args.algorithm)

if args.synthetic:
    dataset = create_dataset(eval(args.synthetic))
elif args.load_arff:
    dataset = load_dataset({'name': args.load_arff})

param_names = []
param_values = []

for param_str in args.parameter:
    name, type_, value_str = param_str.split(':')
    param_names.append(name)
    if type_ == 'int':
        param_values.append(int(value_str))
    elif type_ == 'float':
        param_values.append(float(value_str))

elapsed_time, avg_score = generate_datum(dataset, classifier, args.percentage_data, dict(zip(param_names, param_values)))

print('Time: {}'.format(elapsed_time))
print('Score: {}'.format(avg_score))
algorithms = [
    {'name': 'rnd_forest', 'parameters': {'n_estimators': 50}, 'time': [], 'score': []},
    {'name': 'log_reg', 'parameters': {}, 'time': [], 'score': []}
]

# Percentage of data values
data_range = exp_incl_float_range(0.1, 10, 1, 1.5)

def draw(ax, plt):
    ax.cla()
    ax.plot(data_range[:len(algorithms[0]['score'])], algorithms[0]['score'], 'r-')
    ax.plot(data_range[:len(algorithms[1]['score'])], algorithms[1]['score'], 'b-')
    ax.set_xlabel('% data')
    ax.set_ylabel('Score')
    plt.draw()

plt.ion()
fig, ax = plt.subplots(1,1)
for percentage_data in data_range:
    for algorithm_data in algorithms:
        print '{}; {}'.format(algorithm_data['name'], str(percentage_data))

        cl = name_to_classifier_object(algorithm_data['name'])
        time, score = generate_datum(dataset, cl, percentage_data, algorithm_data['parameters'])
        algorithm_data['time'].append(time)
        algorithm_data['score'].append(score)
        draw(ax, plt)

plt.show()
plt.savefig(FIG_DIR + 'fig_{}.pdf'.format(datetime.now().strftime('%Y-%m-%d_%H-%M-%S-%f')), format='pdf')