def main():
  if sys.argv[1] == 'daily':
    print('Using daily data...')
    path_to_dataset = '../data/household_power_consumption_daily.csv'
    model, y_test, predictions = run(path_to_dataset, 10, 50, 1.0)
  elif sys.argv[1] == 'monthly':
    print('Using monthly data...')
    path_to_dataset = '../data/household_power_consumption_monthly.csv'
    model, y_test, predictions = run(path_to_dataset, 30, 5, 1.0)
  elif sys.argv[1] == 'hourly':
    print('Using hourly data...')
    path_to_dataset = '../data/household_power_consumption_hourly.csv'
    model, y_test, predictions = run(path_to_dataset, 30, 50, 1.0)
  else:
    print('Using minute data...')
    path_to_dataset = '../data/household_power_consumption.csv'
    model, y_test, predictions = run(path_to_dataset)

  # save for later use
  model.save_weights('../output/lstm.h5', overwrite=True)
  # model.load_weights('../output/lstm.h5')

  graph_utils.plot('lstm', predictions, y_test)

  print('RMSE: %.4f'% metrics.rmse(predictions, y_test))
  print('MAPE: %.4f'% metrics.mape(predictions, y_test))
Beispiel #2
0
def create_graph(force):
    run_cmd = cere_configure.cere_config["run_cmd"]
    build_cmd = cere_configure.cere_config["build_cmd"]
    clean_cmd = cere_configure.cere_config["clean_cmd"]
    logger.info('Start call graph creation')

    #Build again the application to be sure we give the right binary to pprof
    try:
        logger.debug(
            subprocess.check_output(
                "{0} && {1} CERE_MODE=\"original --instrument --instrument-app\""
                .format(clean_cmd, build_cmd),
                stderr=subprocess.STDOUT,
                shell=True))
    except subprocess.CalledProcessError as err:
        logger.error(str(err))
        logger.error(err.output)
        return False

    binary = which(run_cmd)
    if not binary:
        logger.critical(
            "Cannot find the binary. Please provide binary name through cere configure --binary."
        )
        return False

    profile_file = "{0}/app.prof".format(var.CERE_PROFILE_PATH)
    if not os.path.isfile(profile_file):
        logger.critical("No profiling file. Please run cere profile.")
        return False

    #regular expression to parse the gperf tool output
    regex_list = [
        r'(N.*)\s\[label\=\"(.*?)\\n([0-9]*)\s\((.*)\%\)\\rof\s(.*)\s\((.*)\%\)\\r',
        r'(N.*)\s\[label\=\"(.*)\\n([0-9]*)\s\((.*)\%\)\\r',
        r'(N.*)\s\-\>\s(N.*)\s\[label\=([0-9]*)\,',
        r'Legend\s\[.*Total samples:\s([0-9]*).*\]'
    ]

    cmd = subprocess.Popen("{0} -dot {1} {2}".format(var.PPROF, binary,
                                                     profile_file),
                           shell=True,
                           stdout=subprocess.PIPE)

    digraph = nx.DiGraph()
    digraph.graph['coverage'] = 0
    digraph.graph['selector'] = None
    samples, digraph = parse_gPerfTool(digraph, cmd, regex_list)
    plot(digraph, "debug")
    digraph = remove_cycles(digraph, samples)
    if not fix_self_coverage(digraph, samples):
        return False
    if not delete_useless_nodes(digraph):
        return False

    plot(digraph)
    save_graph(digraph)

    logger.info('Call graph creation successful')
    return True
def main():
  # minute
  y_test, predictions = run()
  # hourly
  # y_test, predictions = run(50, 1.0)
  # daily
  # y_test, predictions = run(50, 1.0)

  graph_utils.plot('linear', predictions, y_test)

  print('RMSE: %.4f'% metrics.rmse(predictions, y_test))

  print('MAPE: %.4f'% metrics.mape(predictions, y_test))
Beispiel #4
0
def create_graph(force):
    run_cmd = cere_configure.cere_config["run_cmd"]
    build_cmd = cere_configure.cere_config["build_cmd"]
    clean_cmd = cere_configure.cere_config["clean_cmd"]
    logger.info('Start call graph creation')

    #Build again the application to be sure we give the right binary to pprof
    try:
        logger.debug(subprocess.check_output("{0} && {1} CERE_MODE=\"original --instrument --instrument-app\"".format(clean_cmd, build_cmd), stderr=subprocess.STDOUT, shell=True))
    except subprocess.CalledProcessError as err:
        logger.error(str(err))
        logger.error(err.output)
        return False

    binary = which(run_cmd)
    if not binary:
        logger.critical("Cannot find the binary. Please provide binary name through cere configure --binary")
        return False

    profile_file = "{0}/app.prof".format(var.CERE_PROFILE_PATH)
    if not os.path.isfile(profile_file):
        logger.critical("No profiling file. Please run cere profile")
        return False

    #regular expression to parse the gperf tool output
    regex_list = [r'(N.*)\s\[label\=\"(.*?)\\n([0-9]*)\s\((.*)\%\)\\rof\s(.*)\s\((.*)\%\)\\r',
                  r'(N.*)\s\[label\=\"(.*)\\n([0-9]*)\s\((.*)\%\)\\r',
                  r'(N.*)\s\-\>\s(N.*)\s\[label\=([0-9]*)\,',
                  r'Legend\s\[.*Total samples:\s([0-9]*).*\]']

    cmd = subprocess.Popen("{0} -dot {1} {2}".format(var.PPROF, binary, profile_file), shell=True, stdout=subprocess.PIPE)

    digraph = nx.DiGraph()
    digraph.graph['coverage'] = 0
    digraph.graph['selector'] = None
    samples, digraph = parse_gPerfTool(digraph, cmd, regex_list)
    plot(digraph, "debug")
    digraph = remove_cycles(digraph, samples)
    if not fix_self_coverage(digraph, samples):
        return False
    if not delete_useless_nodes(digraph):
        return False

    plot(digraph)
    save_graph(digraph)

    logger.info('Call graph creation successefull')
    return True
def main():
  # minute
  model, y_test, predictions = run()
  # hourly
  # model, y_test, predictions = run(30, 50, 1.0)
  # daily
  # model, y_test, predictions = run(100, 50, 1.0)

  # save for later use
  model.save_weights('../output/lstm.h5', overwrite=True)
  # model.load_weights('../output/lstm.h5')

  graph_utils.plot('lstm', predictions, y_test)

  print('RMSE: %.4f'% metrics.rmse(predictions, y_test))
  print('MAPE: %.4f'% metrics.mape(predictions, y_test))
def main():
  if sys.argv[1] == 'daily':
    print('Using daily data...')
    path_to_dataset = '../data/household_power_consumption_daily.csv'
    y_test, predictions = run(path_to_dataset, 50, 1.0)
  elif sys.argv[1] == 'monthly':
    print('Using monthly data...')
    path_to_dataset = '../data/household_power_consumption_monthly.csv'
    y_test, predictions = run(path_to_dataset, 5, 1.0)
  elif sys.argv[1] == 'hourly':
    print('Using hourly data...')
    path_to_dataset = '../data/household_power_consumption_hourly.csv'
    y_test, predictions = run(path_to_dataset, 50, 1.0)
  else:
    print('Using minute data...')
    path_to_dataset = '../data/household_power_consumption.csv'
    y_test, predictions = run(path_to_dataset)

  graph_utils.plot('linear', predictions, y_test)

  print('RMSE: %.4f'% metrics.rmse(predictions, y_test))

  print('MAPE: %.4f'% metrics.mape(predictions, y_test))
Beispiel #7
0
    digraph.node[7]['_self_coverage'] = 9.
    digraph.node[7]['_coverage'] = 9.

    #add edges
    digraph.add_edge(1, 3, weight = 30.)
    digraph.add_edge(1, 4, weight = 20.)
    digraph.add_edge(2, 3, weight = 35.)
    digraph.add_edge(3, 4, weight = 1.)
    digraph.add_edge(4, 5, weight = 1.)
    digraph.add_edge(5, 3, weight = 1.)
    digraph.add_edge(5, 6, weight = 4.)
    digraph.add_edge(5, 7, weight = 4.)
    digraph.add_edge(3, 6, weight = 22.)
    digraph.add_edge(4, 7, weight = 5.)

    plot(digraph, "debug")
    digraph = remove_cycles(digraph, samples)

    cycles = list(nx.simple_cycles(digraph))
    #If there is still a cycle we have a problem
    if len(cycles) != 0:
        print("Cycles are still present")
        plot(digraph, "final_fail")
        exit(1)
    if not fix_self_coverage(digraph, samples):
        print("Updating coverage failed")
        plot(digraph, "final_fail")
        exit(1)
    #If updating coverages failed to generate good coverage
    if digraph.node[3]["_self_coverage"] != 50 or digraph.node[3]["_coverage"] != 85:
        print("Error in removing cycle")
Beispiel #8
0
    digraph.node[7]["_self_coverage"] = 9.0
    digraph.node[7]["_coverage"] = 9.0

    # add edges
    digraph.add_edge(1, 3, weight=30.0)
    digraph.add_edge(1, 4, weight=20.0)
    digraph.add_edge(2, 3, weight=35.0)
    digraph.add_edge(3, 4, weight=1.0)
    digraph.add_edge(4, 5, weight=1.0)
    digraph.add_edge(5, 3, weight=1.0)
    digraph.add_edge(5, 6, weight=4.0)
    digraph.add_edge(5, 7, weight=4.0)
    digraph.add_edge(3, 6, weight=22.0)
    digraph.add_edge(4, 7, weight=5.0)

    plot(digraph, "debug")
    digraph = remove_cycles(digraph, samples)

    cycles = list(nx.simple_cycles(digraph))
    # If there is still a cycle we have a problem
    if len(cycles) != 0:
        print("Cycles are still present")
        plot(digraph, "final_fail")
        exit(1)
    if not fix_self_coverage(digraph, samples):
        print("Updating coverage failed")
        plot(digraph, "final_fail")
        exit(1)
    # If updating coverages failed to generate good coverage
    if digraph.node[3]["_self_coverage"] != 50 or digraph.node[3]["_coverage"] != 85:
        print("Error in removing cycle")