22 CMultitaskLinearMachine::CMultitaskLinearMachine() :
26 register_parameters();
37 register_parameters();
45 void CMultitaskLinearMachine::register_parameters()
88 for (int32_t i=0; i<n_tasks; i++)
90 set<index_t> indices_set;
92 for (int32_t j=0; j<task_indices.
vlen; j++)
93 indices_set.insert(task_indices[j]);
98 SG_FREE(tasks_indices);
105 vector< vector<index_t> > cutted_task_indices;
106 for (int32_t i=0; i<n_tasks; i++)
107 cutted_task_indices.push_back(vector<index_t>());
108 for (int32_t i=0; i<indices.
vlen; i++)
110 for (int32_t j=0; j<n_tasks; j++)
114 cutted_task_indices[j].push_back(indices[i]);
120 for (int32_t i=0; i<n_tasks; i++)
123 for (int32_t j=0; j<(int)cutted_task_indices[i].size(); j++)
124 tasks[i][j] = cutted_task_indices[i][j];
143 for (int32_t i=0; i<indices.
vlen; i++)
145 for (int32_t j=0; j<n_tasks; j++)
169 SG_ERROR(
"Specified features are not of type CDotFeatures\n")
180 for (int32_t i=0; i<num; i++)
189 for (int32_t i=0; i<w_.
vlen; i++)
216 map<index_t,index_t> subset_inv_map = map<index_t,index_t>();
217 for (int32_t i=0; i<sstack->
get_size(); i++)
224 for (int32_t i=0; i<n_tasks; i++)
228 vector<index_t> cutted = vector<index_t>();
229 for (int32_t j=0; j<task.
vlen; j++)
231 if (subset_inv_map.count(task[j]))
232 cutted.push_back(subset_inv_map[task[j]]);
235 for (int32_t j=0; j<cutted_task.vlen; j++)
236 cutted_task[j] = cutted[j];
238 subset_tasks_indices[i] = cutted_task;
240 SG_FREE(tasks_indices);
242 return subset_tasks_indices;
virtual SGVector< float64_t > apply_get_outputs(CFeatures *data=NULL)
virtual void set_bias(float64_t b)
The class Labels models labels, i.e. class assignments of objects.
CTaskRelation * get_task_relation() const
virtual int32_t get_num_vectors() const =0
#define SG_NOTIMPLEMENTED
CMultitaskLinearMachine()
virtual SGVector< float64_t > get_w() const
class TaskGroup used to represent a group of tasks. Tasks in group do not overlap.
int32_t get_current_task() const
Features that support dot products among other operations.
virtual CBinaryLabels * apply_locked_binary(SGVector< index_t > indices)
class to add subset support to another class. A CSubsetStackStack instance should be added and wrappe...
virtual ~CMultitaskLinearMachine()
void set_task_relation(CTaskRelation *task_relation)
virtual CSubsetStack * get_subset_stack()
Class SGObject is the base class of all shogun objects.
virtual void set_w(const SGVector< float64_t > src_w)
vector< set< index_t > > m_tasks_indices
virtual bool train_locked(SGVector< index_t > indices)
CTaskRelation * m_task_relation
virtual void set_features(CDotFeatures *feat)
index_t subset_idx_conversion(index_t idx) const
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
virtual void post_lock(CLabels *labels, CFeatures *features_)
SGMatrix< float64_t > m_tasks_w
all of classes and functions are contained in the shogun namespace
void set_current_task(int32_t task)
The class Features is the base class of all feature objects.
Binary Labels for binary classification.
SGVector< float64_t > m_tasks_c
used to represent tasks in multitask learning
virtual bool train_machine(CFeatures *data=NULL)
bool has_property(EFeatureProperty p) const
virtual void set_labels(CLabels *lab)
virtual float64_t apply_one(int32_t i)
virtual bool train_locked_implementation(SGVector< index_t > *tasks)
virtual float64_t get_bias()
SGVector< index_t > * get_subset_tasks_indices()