13 #ifndef _LIBLINEARMTL_H___ 14 #define _LIBLINEARMTL_H___ 16 #include <shogun/lib/config.h> 49 std::map<index_t, float64_t>::const_iterator it =
data[i_row].find(i_col);
51 if (it !=
data[i_row].end())
72 data.push_back(std::map<index_t, float64_t>());
85 std::vector< std::map<index_t, float64_t> >
data;
162 virtual const char*
get_name()
const {
return "LibLinearMTL"; }
167 return max_iterations;
173 max_iterations=max_iter;
186 SG_ERROR(
"Please assign labels first!\n")
188 int32_t num_labels=m_labels->get_num_labels();
190 if (num_labels!=linear_term.
vlen)
192 SG_ERROR(
"Number of labels (%d) does not match number" 193 " of entries (%d) in linear term \n", num_labels,
197 m_linear_term = linear_term;
203 task_indicator_lhs = ti;
209 task_indicator_rhs = ti;
215 task_similarity_matrix.set_from_sparse(tsm);
221 graph_laplacian = lap;
243 for(int32_t k=0; k<w_size*num_tasks; k++)
248 for (int32_t s=0; s<num_tasks; s++)
251 for (int32_t t=0; t<num_tasks; t++)
253 float64_t sim_ts = task_similarity_matrix(s,t);
254 for(int32_t i=0; i<w_size; i++)
256 W.
matrix[t*w_size + i] += sim_ts * v_s[i];
307 void solve_l2r_l1l2_svc(
308 const liblinear_problem *prob,
double eps,
double Cp,
double Cn);
358 #endif //_LIBLINEARMTL_H___ void set_bias_enabled(bool enable_bias)
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.
const float64_t operator()(index_t i_row, index_t i_col) const
int32_t get_max_iterations()
mapped sparse matrix for representing graph relations of tasks
std::vector< std::map< index_t, float64_t > > data
void set_linear_term(SGVector< float64_t > linear_term)
virtual const char * get_name() const
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)
void set_from_sparse(const SGSparseMatrix< float64_t > &sgm)
void set_epsilon(float64_t eps)
SGVector< float64_t > alphas
SGSparseVectorEntry< T > * features