Example #1
0
def testVvGlobCoup(f_args):
    thread_id, network, adjMatrix = f_args  # deconstruct the f_arguments
    start = time.perf_counter()  # for timing the algorithm

    output_line = (
        'Varying Variances Globally Coupled Bayesian Piece-Wise Linear Regression with moves on '
        + 'change-points and parent sets on Yeast Data.')
    print(output_line)
    logger.info(output_line)  # Print and write output

    baNet = Network([network], args.chain_length, args.burn_in, args.lag)
    baNet.infer_network('var_glob_coup_nh_dbn')

    true_inc = adjMatrix[
        0]  # For the moment we just get the adj matrix of the first cp
    flattened_true, flattened_scores = transformResults(
        true_inc, baNet.proposed_adj_matrix)

    finish = time.perf_counter()
    print('My thread id is: ', thread_id, ' and I took: ',
          round(finish - start, 2), ' to run.')
    file_name = 'sim_seg_glob_coup_dbn_' + str(
        thread_id) + '.pckl'  # set filename that is based on thread id

    return baNet, file_name, flattened_true, flattened_scores
Example #2
0
def test_h_dbn(f_args):
    thread_id, network, adjMatrix = f_args  # deconstruct the f_arguments
    start = time.perf_counter()  # for timing the algorithm

    output_line = ('Bayesian Linear Regression with moves on' +
                   'the parent set only. \n')
    print(output_line)
    logger.info(output_line)  # Print and write output

    change_points = [
    ]  # set the cps empty list because this is the homegeneous version
    baNet = Network([network], args.chain_length, args.burn_in, args.lag,
                    change_points)  # Create theh BN obj
    baNet.infer_network(
        'h_dbn')  # Do the fixed parents version of the DBN algo

    true_inc = adjMatrix[
        0]  # For the moment we just get the adj matrix of the first cp
    flattened_true, flattened_scores = transformResults(
        true_inc, baNet.proposed_adj_matrix)

    finish = time.perf_counter()
    print('My thread id is: ', thread_id, ' and I took: ',
          round(finish - start, 2), ' to run.')
    file_name = 'sim_h_dbn_' + str(
        thread_id) + '.pckl'  # set filename that is based on thread id

    return baNet, file_name, flattened_true, flattened_scores
def testGlobCoupPwBlrWithCpsParentMoves(data):
    output_line = (
        'Globally Coupled Bayesian Piece-Wise Linear Regression with moves on '
        + 'change-points and parent sets on mTOR Data.')
    print(output_line)
    logger.info(output_line)  # Print and write output

    baNet = Network(data, args.chain_length, args.burn_in, args.lag)
    baNet.infer_network('glob_coup_nh_dbn')

    # save the chain into the output folder
    save_chain('mTOR_glob_coup_dbn.pckl', baNet)
    return baNet.proposed_adj_matrix
Example #4
0
def testGlobCoupPwBlrWithCpsParentMoves(data, true_inc):
  output_line = (
    'Full Parents Credible Intervals Globally Coupled Bayesian Piece-Wise Linear Regression' +
    'with moves on change-points only Yeast Data.'
  )
  print(output_line) ; logger.info(output_line) # Print and write output

  baNet = Network(data, args.chain_length, args.burn_in, args.lag)
  baNet.infer_network('fp_glob_coup_nh_dbn')

  flattened_true, flattened_scores = transformResults(true_inc, baNet.proposed_adj_matrix)
  adjMatrixRoc(flattened_scores, flattened_true, args.verbose)

  # save the chain into the output folder
  save_chain('fp_glob_coup_dbn.pckl', baNet)
Example #5
0
def testVvGlobCoup(data, true_inc):
    output_line = (
        'Varying Variances Globally Coupled Bayesian Piece-Wise Linear Regression with moves on '
        + 'change-points and parent sets on Yeast Data.')
    print(output_line)
    logger.info(output_line)  # Print and write output

    baNet = Network(data, args.chain_length, args.burn_in, args.lag)
    baNet.infer_network('var_glob_coup_nh_dbn')

    flattened_true, flattened_scores = transformResults(
        true_inc, baNet.proposed_adj_matrix)
    adjMatrixRoc(flattened_scores, flattened_true, args.verbose)

    # save the chain into the output folder
    save_chain('vv_glob_coup_dbn.pckl', baNet)
Example #6
0
def testPwBlrWithParentMoves(data, true_inc):
    output_line = (
        'Bayesian Piece-Wise Linear Regression with moves on ' +
        'the parent set only with fixed changepoints for the Yeast Data. \n')
    print(output_line)
    logger.info(output_line)  # Print and write output
    if args.change_points == 0:
        args.change_points = []
    args.change_points.append(data.shape[0] +
                              1)  # append the len data + 1 so the algo works
    baNet = Network(data, args.chain_length, args.burn_in, args.lag,
                    args.change_points)  # Create theh BN obj
    baNet.infer_network(
        'fixed_nh_dbn')  # Do the fixed changepoints version of the DBN algo

    flattened_true, flattened_scores = transformResults(
        true_inc, baNet.proposed_adj_matrix)
    adjMatrixRoc(flattened_scores, flattened_true, args.verbose)
Example #7
0
def test_h_dbn(data, true_inc):
  output_line = (
    'Homogeneous Dinamic Bayesian Linear Regression with full parents ' +
    'for the Yeast data. \n'
  )
  print(output_line) ; logger.info(output_line) # Print and write output

  change_points = [] # set the cps empty list because this is the homegeneous version

  # Create/Call the Network objects/methods
  baNet = Network(data, args.chain_length, args.burn_in, args.lag, args.change_points) # Create theh BN obj
  baNet.infer_network('fp_h_dbn') # Do the fixed parents version of the DBN algo
  
  # trueAdjMatrix = adjMatrix[0] # For the moment we just get the adj matrix of the first cp
  flattened_true, flattened_scores = transformResults(true_inc, baNet.proposed_adj_matrix)
  adjMatrixRoc(flattened_scores, flattened_true, args.verbose)
  
  # save the chain into the output folder
  save_chain('fp_h_dbn.pckl', baNet)
def test_h_dbn(data):
    output_line = ('Bayesian Linear Regression with moves on ' +
                   'the parent set only for the mTOR data. \n')
    print(output_line)
    logger.info(output_line)  # Print and write output

    change_points = [
    ]  # set the cps empty list because this is the homegeneous version

    # Create/Call the Network objects/methods
    baNet = Network(data, args.chain_length, args.burn_in, args.lag,
                    args.change_points)  # Create theh BN obj
    baNet.infer_network(
        'h_dbn')  # Do the fixed parents version of the DBN algo

    # save the chain into the output folder
    save_chain('mTOR_h_dbn.pckl', baNet)

    return baNet.proposed_adj_matrix
def testPwBlrWithCpsParentMoves(data):
    output_line = ('Bayesian Piece-Wise Linear Regression with moves on ' +
                   'change-points and parent sets for the mTOR data.')
    print(output_line)
    logger.info(output_line)  # Print and write output
    if args.change_points == 0:
        args.change_points = []

    # to get the total length of the data over the segments
    # data_len = 0
    # for segment in data:
    #   data_len = data_len + segment.shape[0]

    # args.change_points.append(data_len + 1) # append the len data + 1 so the algo works
    baNet = Network(data, args.chain_length, args.burn_in, args.lag)
    baNet.infer_network('varying_nh_dbn')

    # save the chain into the output folder
    save_chain('mTOR_nh_dbn.pckl', baNet)

    return baNet.proposed_adj_matrix
Example #10
0
def testPwBlrWithCpsParentMoves(data, true_inc):
  # credible intervals computation with full parents
  output_line = (
    'Bayesian Piece-Wise Linear Regression with moves on ' +
    'change-points and full parent set for the Yeast data.'
  )
  print(output_line) ; logger.info(output_line) # Print and write output
  if args.change_points == 0:
    args.change_points = []
  
  # to get the total length of the data over the segments
  data_len = 0
  for segment in data:
    data_len = data_len + segment.shape[0]

  args.change_points.append(data_len + 1) # append the len data + 1 so the algo works
  baNet = Network(data, args.chain_length, args.burn_in, args.lag)
  baNet.infer_network('fp_varying_nh_dbn')

  flattened_true, flattened_scores = transformResults(true_inc, baNet.proposed_adj_matrix)
  adjMatrixRoc(flattened_scores, flattened_true, args.verbose)
  
  # save the chain into the output folder
  save_chain('fp_nh_dbn.pckl', baNet)