networkx.algorithms.node_classification.lgc.local_and_global_consistency¶
-
local_and_global_consistency
(G, alpha=0.99, max_iter=30, label_name='label')[source]¶ Node classification by Local and Global Consistency
- Parameters
G (NetworkX Graph)
alpha (float) – Clamping factor
max_iter (int) – Maximum number of iterations allowed
label_name (string) – Name of target labels to predict
- Raises
- Returns
predicted – Array of predicted labels
- Return type
array, shape = [n_samples]
Examples
>>> from networkx.algorithms import node_classification >>> G = nx.path_graph(4) >>> G.nodes[0]['label'] = 'A' >>> G.nodes[3]['label'] = 'B' >>> G.nodes(data=True) NodeDataView({0: {'label': 'A'}, 1: {}, 2: {}, 3: {'label': 'B'}}) >>> G.edges() EdgeView([(0, 1), (1, 2), (2, 3)]) >>> predicted = node_classification.local_and_global_consistency(G) >>> predicted ['A', 'A', 'B', 'B']
References
Zhou, D., Bousquet, O., Lal, T. N., Weston, J., & Schölkopf, B. (2004). Learning with local and global consistency. Advances in neural information processing systems, 16(16), 321-328.