Turi Create  4.0
label_propagation.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #include <model_server/lib/toolkit_function_specification.hpp>
7 #ifndef TURI_UNITY_LABEL_PROPAGATION
8 #define TURI_UNITY_LABEL_PROPAGATION
9 
10 namespace turi {
11 namespace label_propagation {
12 
13 /**
14  * Obtains the registration for the Label Propagation Toolkit.
15  *
16  * Performs the following iterative label propagation computation:
17  * For class label k:
18  * \f[
19  * PR_i[k] = PR_i[k] \times self\_weight + \sum_{j\in\textrm{InNbrs}_i} PR_j[k] * W_{j,i}
20  * PR_i[:] = Normalize(Pr_i[:])
21  * \f]
22  *
23  * Reference:
24  * Zhu, Xiaojin, and Zoubin Ghahramani. Learning from labeled and unlabeled
25  * data with label propagation. Technical Report CMU-CALD-02-107, Carnegie
26  * Mellon University, 2002.
27  *
28  * <b> Toolkit Name: label propagation</b>
29  *
30  * Accepted Parameters:
31  * \li \b label_field (flexible_type: string). The vertex field for initial labels.
32  *
33  * \li \b threshold (flexible_type: float). The termination threshold in
34  * average L2 norm.
35  *
36  * \li \b self_weight (flexible_type: float). The weight for self edge.
37  *
38  * \li \b weight_field (flexible_type: string). The edge field for edge weight.
39  * If empty, then unit edge weight is used.
40  *
41  * \li \b undirected (flexible_type: int). If true, the label propagates
42  * from both source to target, and target to source.
43  *
44  * Returned Parameters:
45  *
46  * \li \b training_time (flexible_type: float). The training time of the
47  * algorithm in seconds excluding all other preprocessing stages.
48  *
49  * \li \b delta (flexible_type: float). The average of all last changes
50  * made to each vertex in l2 norm.
51  *
52  * \li \b __graph__ (unity_graph). The graph object with the fields "P_0"
53  * "P_1", ... "P_k" on each vertex, containing the probability
54  * of the class for each vertex.
55  */
56 std::vector<toolkit_function_specification> get_toolkit_function_registration();
57 
58 } // namespace pagerank
59 } // namespace turi
60 #endif