13 using namespace shogun;
36 void CMultilabelModel::init()
38 SG_ADD(&m_false_positive,
"false_positive",
"Misclassification cost for false positive",
40 SG_ADD(&m_false_negative,
"false_negative",
"Misclassification cost for false negative",
42 SG_ADD(&m_num_classes,
"num_classes",
"Number of (binary) class assignment per label",
54 return feats_dim * num_classes;
59 m_false_positive = false_positive;
60 m_false_negative = false_negative;
70 get_computed_dot_feature_vector(feat_idx);
104 REQUIRE(y1.
vlen == y2.
vlen,
"Size of both the vectors should be same\n");
118 return y1 > y2 ? m_false_negative : y1 < y2 ? m_false_positive : 0;
128 REQUIRE(dense_vec[i] == d_true || dense_vec[i] == d_false,
129 "The values of dense vector should be either (%d) or (%d).\n",
132 if (dense_vec[i] == d_true)
143 if (dense_vec[i] == d_true)
167 REQUIRE(m_num_classes > 0,
"The model needs to be trained before using "
168 "it for prediction\n");
178 for (int32_t c = 0; c < m_num_classes; c++)
180 score = dot_feats->
dense_dot(feat_idx, w.
vector + c * feats_dim, feats_dim);
185 total_score += score;
200 ret->
score = total_score;
SGVector< float64_t > psi_truth
static float64_t dot(const bool *v1, const bool *v2, int32_t n)
compute dot product between v1 and v2 (blas optimized)
Base class of the labels used in Structured Output (SO) problems.
Class CMultilabelSOLabels used in the application of Structured Output (SO) learning to Multilabel Cl...
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)=0
virtual void init_primal_opt(float64_t regularization, SGMatrix< float64_t > &A, SGVector< float64_t > a, SGMatrix< float64_t > B, SGVector< float64_t > &b, SGVector< float64_t > &lb, SGVector< float64_t > &ub, SGMatrix< float64_t > &C)
SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, int32_t lab_idx)
Features that support dot products among other operations.
virtual int32_t get_dim_feature_space() const =0
virtual float64_t delta_loss(CStructuredData *y1, CStructuredData *y2)
virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData *y)
static SGMatrix< T > create_identity_matrix(index_t size, T scale)
virtual int32_t get_dim() const
float64_t delta_loss(int32_t ytrue_idx, CStructuredData *ypred)
Class CSparseMultilabel to be used in the application of Structured Output (SO) learning to Multilabe...
Class CStructuredModel that represents the application specific model and contains most of the applic...
CStructuredLabels * m_labels
The class Features is the base class of all feature objects.
static SGVector< float64_t > to_dense(CStructuredData *label, int32_t dense_dim, float64_t d_true, float64_t d_false)
virtual void set_misclass_cost(float64_t false_positive, float64_t false_negative)
SGVector< float64_t > psi_pred
virtual ~CMultilabelModel()
virtual int32_t get_num_classes() const
Base class of the components of StructuredLabels.
virtual CResultSet * argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training=true)
static CSparseMultilabel * obtain_from_generic(CStructuredData *base_data)
SGVector< int32_t > get_data() const
virtual CStructuredLabels * structured_labels_factory(int32_t num_labels=0)