import argparse
import numpy as np
from causally.start.quick_start import run_casual
from causally.config.configurator import Config
from logging import getLogger
from causally.utils.output import save_result,save_uite_result
import pandas as pd
import pickle
from collections import defaultdict
# from causally.utils.utils import create_dataset,data_preparation

if __name__ == '__main__':

    parser = argparse.ArgumentParser()
    parser.add_argument('-m', '--model', type=str,default='Ours1',
                      help='The model for estimating casual effect')
    parser.add_argument('-d', '--dataset', type=str, default='Syn_10',
                      help='The dataset.')

    args, _ = parser.parse_known_args()

    config = Config(args = args)
    config['end_order'] = 10
    config['start_order'] = 1

    results = run_casual(config=config)    
    logger = getLogger()
    logger.info('\n{}'.format(results))

    info = '\n[{},{}]\n'.format(args.model,args.dataset)
    for key in results:
      mean = round(np.mean(results[key]),5)
      std = round(np.std(results[key],ddof=1),5)
      info += 'The {} metric: {}±{}\n'.format(key.upper(),mean,std)
    info += 'done!'
    logger.info('\n'+info)

