Example #1
0
def gen_training_data(train_graph, node_feature, filename):
    print('=========Generating training data=========', file=sys.stderr)

    # sample negative samples
    neg_edge_num = train_graph.number_of_edges()
    neg_edges = sample_negative_edges(train_graph, neg_edge_num)
    train_pairs = train_graph.edges()
    train_pairs.extend(neg_edges)
    random.shuffle(train_pairs)
    train_labels = gen_label_mapping(train_graph.edges(), 1)
    train_labels.update(gen_label_mapping(neg_edges, -1))

    # extract topplogical features
    pair_feature = feature_extraction(train_graph, train_pairs, node_feature)

    # if you want to output dummy variable, comment the next line
    node_feature = None

    outfile = open(filename, 'w')
    cf.convert_to_svm_format(train_pairs,
                             node_feature,
                             pair_feature,
                             outfile,
                             testing_ans=train_labels)
    outfile.close()
Example #2
0
def gen_testing_data(all_graph, test_pairs, test_labels, 
        lender_feature, loan_feature, filename):
    
    # extract topological features
    pair_feature = feature_extraction(all_graph, test_pairs)

    outfile = open(filename, 'w')
    cf.convert_to_svm_format(test_pairs, lender_feature, loan_feature, 
            pair_feature, outfile, testing_ans = test_labels)
    outfile.close()
def gen_testing_data(all_graph, test_pairs, test_labels, 
        node_feature, filename):
    print('=========Generating testing data=========', file=sys.stderr)

    # extract topological features
    pair_feature = feature_extraction(all_graph, test_pairs, node_feature)
    
    # if you want to output dummy variable, comment the next line
    node_feature = None

    outfile = open(filename, 'w')
    cf.convert_to_svm_format(test_pairs, node_feature,  
            pair_feature, outfile, testing_ans = test_labels)
    outfile.close()
def gen_testing_data(all_graph, test_pairs, test_labels, 
        node_feature, filename):
    print('=========Generating testing data=========', file=sys.stderr)

    # extract topological features
    pair_feature = feature_extraction(all_graph, test_pairs, node_feature)
    
    # if you want to output dummy variable, comment the next line
    node_feature = None

    outfile = open(filename, 'w')
    cf.convert_to_svm_format(test_pairs, node_feature,  
            pair_feature, outfile, testing_ans = test_labels)
    outfile.close()
Example #5
0
def gen_training_data(train_graph, lender_feature, loan_feature, filename):    
    # sample negative samples
    neg_edge_num = train_graph.number_of_edges()
    neg_edges = sample_negative_edges(train_graph, neg_edge_num)
    train_pairs = train_graph.edges()
    train_pairs.extend(neg_edges)
    train_labels = gen_label_mapping(train_graph.edges(), 1)
    train_labels.update(gen_label_mapping(neg_edges, 0))

    # extract topplogical features
    pair_feature = feature_extraction(train_graph, train_pairs)
    
    outfile = open(filename, 'w')
    cf.convert_to_svm_format(train_pairs, lender_feature, loan_feature, 
            pair_feature, outfile, testing_ans = train_labels)
    outfile.close()
def gen_training_data(train_graph, node_feature, filename):    
    print('=========Generating training data=========', file=sys.stderr)

    # sample negative samples
    neg_edge_num = train_graph.number_of_edges()
    neg_edges = sample_negative_edges(train_graph, neg_edge_num)
    train_pairs = train_graph.edges()
    train_pairs.extend(neg_edges)
    random.shuffle(train_pairs)
    train_labels = gen_label_mapping(train_graph.edges(), 1)
    train_labels.update(gen_label_mapping(neg_edges, -1))

    # extract topplogical features
    pair_feature = feature_extraction(train_graph, train_pairs, node_feature)
    
    # if you want to output dummy variable, comment the next line
    node_feature = None

    outfile = open(filename, 'w')
    cf.convert_to_svm_format(train_pairs, node_feature, 
            pair_feature, outfile, testing_ans = train_labels)
    outfile.close()