11 #ifndef _MULTITASKKERNELTREENORMALIZER_H___
12 #define _MULTITASKKERNELTREENORMALIZER_H___
45 for (
size_t i = 0; i <
children.size(); i++)
54 std::set<CNode*> nodes_on_path = std::set<CNode*>();
56 while (node != NULL) {
57 nodes_on_path.insert(node);
69 std::vector<int32_t> task_ids;
70 std::deque<CNode*> grey_nodes;
71 grey_nodes.push_back(
this);
73 while(grey_nodes.size() > 0)
76 CNode *current_node = grey_nodes.front();
77 grey_nodes.pop_front();
79 for(int32_t i = 0; i!=int32_t(current_node->
children.size()); i++){
80 grey_nodes.push_back(current_node->
children[i]);
84 task_ids.push_back(current_node->
getNode_id());
158 name2id = std::map<std::string, int32_t>();
164 for (
size_t i = 0; i <
nodes.size(); i++)
176 return nodes[task_id];
184 nodes[0]->beta = beta;
194 if (child_name==
"")
SG_ERROR(
"child_name empty")
195 if (parent_name==
"")
SG_ERROR(
"parent_name empty")
200 child_node->
beta = beta;
202 nodes.push_back(child_node);
203 int32_t
id =
nodes.size()-1;
237 std::set<CNode*> intersection;
239 std::set_intersection(root_path_lhs.begin(), root_path_lhs.end(),
240 root_path_rhs.begin(), root_path_rhs.end(),
241 std::inserter(intersection, intersection.end()));
263 for (std::set<CNode*>::const_iterator p = intersection.begin(); p != intersection.end(); ++p) {
282 for (std::vector<int32_t>::const_iterator it=task_vector_lhs.begin(); it!=task_vector_lhs.end(); it++)
288 for (std::vector<int32_t>::const_iterator it=task_vector_lhs.begin(); it!=task_vector_lhs.end(); it++)
304 return (int32_t)(
nodes.size());
310 int32_t num_leaves = 0;
396 std::vector<std::string> task_rhs,
466 SG_ERROR(
"normalize_lhs not implemented")
476 SG_ERROR(
"normalize_rhs not implemented")
487 for (int32_t i = 0; i != (int32_t)(vec.size()); ++i)
503 for (int32_t i = 0; i != (int32_t)(vec.size()); ++i)
556 ASSERT(node_lhs < num_nodes && node_lhs >= 0)
557 ASSERT(node_rhs < num_nodes && node_rhs >= 0)
572 ASSERT(node_lhs < num_nodes && node_lhs >= 0)
573 ASSERT(node_rhs < num_nodes && node_rhs >= 0)
582 return "MultitaskKernelTreeNormalizer";
void add_child(CNode *node)
std::vector< int32_t > task_vector_lhs
void set_task_vector_rhs(std::vector< std::string > vec)
CTaxonomy is used to describe hierarchical structure between tasks.
std::map< std::string, int32_t > get_name2id()
int32_t get_id(std::string name)
virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)
void set_root_beta(float64_t beta)
virtual const char * get_name() const
std::map< std::string, int32_t > name2id
int32_t getNode_id() const
CMultitaskKernelTreeNormalizer(std::vector< std::string > task_lhs, std::vector< std::string > task_rhs, CTaxonomy tax)
virtual const char * get_name() const
std::map< int32_t, float64_t > task_histogram
A CNode is an element of a CTaxonomy, which is used to describe hierarchical structure between tasks...
void set_node_similarity(int32_t node_lhs, int32_t node_rhs, float64_t similarity)
void setNode_id(int32_t node_idx)
std::set< CNode * > get_path_root()
std::set< CNode * > intersect_root_path(CNode *node_lhs, CNode *node_rhs)
CMultitaskKernelTreeNormalizer()
float64_t get_beta(int32_t idx)
Class SGObject is the base class of all shogun objects.
void set_task_vector_lhs(std::vector< std::string > vec)
std::vector< CNode * > children
virtual float64_t normalize_lhs(float64_t value, int32_t idx_lhs)
int32_t get_id_by_name(std::string name)
float64_t get_node_weight(int32_t idx)
CNode * add_node(std::string parent_name, std::string child_name, float64_t beta)
The class Kernel Normalizer defines a function to post-process kernel values.
CMultitaskKernelTreeNormalizer * KernelNormalizerToMultitaskKernelTreeNormalizer(CKernelNormalizer *n)
virtual ~CMultitaskKernelTreeNormalizer()
float64_t compute_node_similarity(int32_t task_lhs, int32_t task_rhs)
void set_beta(int32_t idx, float64_t weight)
Base-class for parameterized Kernel Normalizers.
CNode * get_node(int32_t task_id)
void update_task_histogram(std::vector< int32_t > task_vector_lhs)
all of classes and functions are contained in the shogun namespace
void set_node_weight(int32_t idx, float64_t weight)
void set_task_vector(std::vector< std::string > vec)
std::vector< float64_t > dependency_matrix
virtual float64_t normalize(float64_t value, int32_t idx_lhs, int32_t idx_rhs)
float64_t get_node_similarity(int32_t node_lhs, int32_t node_rhs)
std::vector< int32_t > task_vector_rhs
virtual const char * get_name() const
std::vector< int32_t > get_task_ids_below()
std::vector< CNode * > nodes
The MultitaskKernel allows Multitask Learning via a modified kernel function based on taxonomy...