当前位置: 首页>>代码示例>>Python>>正文


Python Column.value方法代码示例

本文整理汇总了Python中Column.value方法的典型用法代码示例。如果您正苦于以下问题:Python Column.value方法的具体用法?Python Column.value怎么用?Python Column.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Column的用法示例。


在下文中一共展示了Column.value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_common_categories_col

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_common_categories_col(converted_column, pairs):
    if converted_column.type != 'categorical':
        return None

    c = Column(1, 'numerical')
    value = dict()

    for pair in pairs:
        n1 = pair[0]
        n2 = pair[1]
        if n1 in converted_column.value:
            f1 = converted_column.value[n1] # a set of integers
        else:
            f1 = set()
        if n2 in converted_column.value:
            f2 = converted_column.value[n2] # a set of integers
        else:
            f2 = set()
        
        # TODO Task 6: find the number of common categories, and normalize it
        # Assume f1,f2 are the set of categories of node1 and node2 respectively
        # we want to calculate |f1 intersect f2| / |f1 union f2|
        # (if f1 union f2 is empty set, then the value is 0.0)
        
    c.value = value
    return c
开发者ID:barry800414,项目名称:sna_lecture,代码行数:28,代码来源:extract_feature.py

示例2: get_hitting_time

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_hitting_time(graph, pairs, trials, max_step):
    c = Column(1, 'numerical')
    value = dict()

    pairs_set = set(pairs)
    hitting_time = dict()
    for n in graph.nodes():
        hitting_time[n] = defaultdict(float)
    
    # calculating hitting time
    for n1 in graph.nodes():
        print(n1)
        # run random walks for given starting node
        expected_steps = random_walk(graph, n1, trials, max_step)
        for n2 in expected_steps.keys():
            if (n1,n2) in pairs_set or (n2,n1) in pairs_set:
                hitting_time[n1][n2] = expected_steps[n2]
    
    for pair in pairs:
        n1 = pair[0]
        n2 = pair[1]
        if n2 in hitting_time[n1] and n1 in hitting_time[n2]:
            if hitting_time[n1][n2] == 0.0:
                hitting_time[n1][n2] = NO_PATH_LENGTH
            if hitting_time[n2][n1] == 0.0:
                hitting_time[n2][n1] = NO_PATH_LENGTH
            value[pair] = hitting_time[n1][n2] + hitting_time[n2][n1]
    c.value = value
    return c
开发者ID:barry800414,项目名称:sna_lecture,代码行数:31,代码来源:extract_feature.py

示例3: get_hitting_time

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_hitting_time(graph, edges, max_length):
    c = Column(1, 'numerical')
    value = dict()
    for edge in edges:
        value[edge] = __expected_steps(graph, edge, max_length)
    c.value = value
    return c
开发者ID:barry800414,项目名称:tutorial,代码行数:9,代码来源:extract_feature.py

示例4: get_all_node_degree

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_all_node_degree(graph):
    c = Column(1, 'numerical')
    value = dict()
    for v in graph.nodes():
        value[v] = graph.degree(v)
    c.value = value
    return c
开发者ID:barry800414,项目名称:tutorial,代码行数:9,代码来源:extract_feature.py

示例5: read_feature_column_major

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def read_feature_column_major(filename, column_type):
    with open(filename, 'r') as f:
        line = f.readline().strip()
        entry = line.split(',')
        column_name = entry[1:]
        column_num = len(column_name)
        assert len(column_type) == column_num
        
        # generate the list of Columns for later usage
        columns = list()
        for t in column_type:
            c = Column(1, t)
            c.value = dict()
            columns.append(c)
        
        # read in rows 
        for line in f:
            entry = (line.strip()).split(',')
            assert len(entry) == (column_num + 1)
            row_id = int(entry[0])
            for i, column in enumerate(columns):
                value = entry[i+1].strip()
                if len(value) == 0 or value == 'None':
                    continue
                if column.type == 'categorical':
                    column.value[row_id] = value
                elif column.type == 'numerical':
                    column.value[row_id] = float(value)
        
    return (columns, column_name)
开发者ID:barry800414,项目名称:tutorial,代码行数:32,代码来源:file_io.py

示例6: get_common_categories_col

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_common_categories_col(converted_column, pairs):
    if converted_column.type != 'categorical':
        return None

    c = Column(1, 'numerical')
    value = dict()

    for pair in pairs:
        n1 = pair[0]
        n2 = pair[1]
        
        if n1 in converted_column.value:
            f1 = converted_column.value[n1] # a set of integers
        else:
            f1 = set()
        if n2 in converted_column.value:
            f2 = converted_column.value[n2] # a set of integers
        else:
            f2 = set()

        union = f1 | f2
        intersect = f1 & f2
        if len(union) != 0 and len(intersect) != 0:
            value[pair] = float(len(intersect)) / len(union)
        else:
            pass  #value[pair] = 0.0
    c.value = value
    return c
开发者ID:barry800414,项目名称:sna_lecture,代码行数:30,代码来源:extract_feature.py

示例7: get_edge_embeddedness

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_edge_embeddedness(graph, pairs):
    c = Column(1, 'numerical')
    value = dict()
    for pair in pairs:
        value[pair] = len(list(nx.common_neighbors(graph, pair[0], pair[1])))
    c.value = value
    return c
开发者ID:barry800414,项目名称:tutorial,代码行数:9,代码来源:extract_feature.py

示例8: get_preferential_score

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_preferential_score(graph, pairs):
    c = Column(1, 'numerical')
    value = dict()
    for pair in pairs:
        nei_x = graph.neighbors(pair[0])
        nei_y = graph.neighbors(pair[1])
        value[pair] = (len(nei_x) + 1) * (len(nei_y) + 1)
    c.value = value
    return c
开发者ID:barry800414,项目名称:sna_lecture,代码行数:11,代码来源:extract_feature.py

示例9: get_shortest_path_length

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_shortest_path_length(graph, pairs):
    c = Column(1, 'numerical')
    value = dict()
    for pair in pairs:
        try:
            value[pair] = nx.shortest_path_length(graph, pair[0], pair[1])
        except:
            pass
    c.value = value
    return c
开发者ID:barry800414,项目名称:tutorial,代码行数:12,代码来源:extract_feature.py

示例10: get_jaccards_coefficient

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_jaccards_coefficient(graph, pairs):
    c = Column(1, 'numerical')
    value = dict()
    for pair in pairs:
        nei_x = set(graph.neighbors(pair[0]))
        nei_y = set(graph.neighbors(pair[1]))
        # TODO Task_3: EDIT HERE, caculate jaccards_coefficient
        # for pair[0] and pair[1]
        # value[pair] = ooxx
    c.value = value
    return c
开发者ID:barry800414,项目名称:tutorial,代码行数:13,代码来源:extract_feature.py

示例11: get_adamic_adar_score

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_adamic_adar_score(graph, pairs):
    c = Column(1, 'numerical')
    value = dict()
    for pair in pairs:
        common_nei = nx.common_neighbors(graph, pair[0], pair[1])
        score = 0.0
        for n in common_nei:
            score += 1.0 / math.log(len(graph.neighbors(n)) + 1)
        value[pair] = score
    c.value = value
    return c
开发者ID:barry800414,项目名称:tutorial,代码行数:13,代码来源:extract_feature.py

示例12: get_cc_score

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_cc_score(graph, pairs):
    c = Column(1, 'numerical')
    value = dict()
    # TODO Task_5: Calculate clustering coefficient score for all pairs
    # cc = nx.ooooxxxx(graph)
    # for pair in pairs:
    #   n1 = pair[0]
    #   n2 = pair[1]
    #   value[pair] = xxxxxx
    value[pairs[0]] = 1   # delete this line
    c.value = value
    return c
开发者ID:barry800414,项目名称:sna_lecture,代码行数:14,代码来源:extract_feature.py

示例13: get_cc_score

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_cc_score(graph, pairs):
    c = Column(1, 'numerical')
    value = dict()

    # calculate clustering coefficient scores for all nodes
    cc = nx.clustering(graph)
    for pair in pairs:
        x = pair[0]
        y = pair[1]
        value[pair] = cc[x] + cc[y]
    c.value = value
    return c
开发者ID:barry800414,项目名称:sna_lecture,代码行数:14,代码来源:extract_feature.py

示例14: get_shortest_path_length

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_shortest_path_length(graph, pairs):
    c = Column(1, 'numerical')
    value = dict()
    for pair in pairs:
        n1 = pair[0]
        n2 = pair[1]
        try:
            value[pair] = nx.shortest_path_length(graph, n1, n2)
        except:
            value[pair] = NO_PATH_LENGTH
    c.value = value
    return c
开发者ID:barry800414,项目名称:sna_lecture,代码行数:14,代码来源:extract_feature.py

示例15: get_shortest_path_length

# 需要导入模块: import Column [as 别名]
# 或者: from Column import value [as 别名]
def get_shortest_path_length(graph, pairs):
    c = Column(1, 'numerical')
    value = dict()
    for pair in pairs:
        try:
            # TODO Task_1: EDIT HERE, please find shortest 
            # path from pair[0] to pair[1]
            # value[pair] = ooxx
        except:
            pass
    c.value = value
    return c
开发者ID:barry800414,项目名称:tutorial,代码行数:14,代码来源:extract_feature.py


注:本文中的Column.value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。