13 #ifndef _LIBLINEARMTL_H___ 14 #define _LIBLINEARMTL_H___ 48 std::map<index_t, float64_t>::const_iterator it =
data[i_row].find(i_col);
50 if (it !=
data[i_row].end())
71 data.push_back(std::map<index_t, float64_t>());
84 std::vector< std::map<index_t, float64_t> >
data;
161 virtual const char*
get_name()
const {
return "LibLinearMTL"; }
166 return max_iterations;
172 max_iterations=max_iter;
185 SG_ERROR(
"Please assign labels first!\n")
187 int32_t num_labels=m_labels->get_num_labels();
189 if (num_labels!=linear_term.
vlen)
191 SG_ERROR(
"Number of labels (%d) does not match number" 192 " of entries (%d) in linear term \n", num_labels,
196 m_linear_term = linear_term;
202 task_indicator_lhs = ti;
208 task_indicator_rhs = ti;
214 task_similarity_matrix.set_from_sparse(tsm);
220 graph_laplacian = lap;
242 for(int32_t k=0; k<w_size*num_tasks; k++)
247 for (int32_t s=0; s<num_tasks; s++)
250 for (int32_t t=0; t<num_tasks; t++)
252 float64_t sim_ts = task_similarity_matrix(s,t);
253 for(int32_t i=0; i<w_size; i++)
255 W.
matrix[t*w_size + i] += sim_ts * v_s[i];
306 void solve_l2r_l1l2_svc(
307 const liblinear_problem *prob,
double eps,
double Cp,
double Cn);
357 #endif //_LIBLINEARMTL_H___ void set_bias_enabled(bool enable_bias)
const float64_t operator()(index_t i_row, index_t i_col) const
void set_task_indicator_lhs(SGVector< int32_t > ti)
void set_C(float64_t c_neg, float64_t c_pos)
class to implement LibLinear
void set_task_similarity_matrix(SGSparseMatrix< float64_t > tsm)
SGMatrix< float64_t > get_V()
The class Labels models labels, i.e. class assignments of objects.
virtual EMachineType get_classifier_type()
SGSparseVector< T > * sparse_matrix
array of sparse vectors of size num_vectors
index_t num_vectors
total number of vectors
SGVector< float64_t > get_alphas()
Features that support dot products among other operations.
int32_t get_max_iterations()
mapped sparse matrix for representing graph relations of tasks
static const float64_t epsilon
std::vector< std::map< index_t, float64_t > > data
void set_linear_term(SGVector< float64_t > linear_term)
SGVector< float64_t > m_linear_term
void set_graph_laplacian(SGMatrix< float64_t > lap)
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
void set_task_indicator_rhs(SGVector< int32_t > ti)
SGVector< int32_t > task_indicator_rhs
all of classes and functions are contained in the shogun namespace
SGMatrix< float64_t > get_W()
The class Features is the base class of all feature objects.
SGVector< int32_t > task_indicator_lhs
MappedSparseMatrix task_similarity_matrix
void set_num_tasks(int32_t nt)
SGMatrix< float64_t > graph_laplacian
void set_max_iterations(int32_t max_iter=1000)
virtual const char * get_name() const
void set_from_sparse(const SGSparseMatrix< float64_t > &sgm)
void set_epsilon(float64_t eps)
SGVector< float64_t > alphas
SGSparseVectorEntry< T > * features