38 void CMultilabelCLRModel::init()
40 SG_ADD(&m_num_classes,
"num_classes",
"Number of (binary) class assignment per label",
50 return feats_dim * (num_classes + 1);
62 int32_t num_neg_labels = num_classes - num_pos_labels;
74 label_coeffs[num_classes] = num_neg_labels - num_pos_labels;
80 for (
index_t i = 0; i < num_classes + 1; i++)
84 for (
index_t j = 0; j < feats_dim; j++)
86 psi[i * feats_dim + j] = coeff * x[j];
111 REQUIRE(y1.
vlen == y2.
vlen,
"Size of both the vectors should be same\n");
125 return y1 != y2 ? 1 : 0;
135 REQUIRE(dense_vec[i] == d_true || dense_vec[i] == d_false,
136 "The values of dense vector should be either (%d) or (%d).\n",
139 if (dense_vec[i] == d_true)
150 if (dense_vec[i] == d_true)
174 REQUIRE(m_num_classes > 0,
"The model needs to be trained before using "
175 "it for prediction\n");
191 for (
index_t i = 0; i < y_true_data.vlen; i++)
193 plus_minus_one[y_true_data[i]] = 1;
200 plus_minus_one.
zero();
203 float64_t score = 0, calibrated_score = 0;
206 calibrated_score = dot_feats->
dense_dot(feat_idx, w.
vector + m_num_classes * feats_dim,
211 for (
index_t i = 0; i < m_num_classes; i++)
215 class_product[i] = score - calibrated_score;
222 for (
index_t i = 0; i < m_num_classes; i++)
224 score = class_product[i] - plus_minus_one[i];
SGVector< float64_t > psi_truth
virtual ~CMultilabelCLRModel()
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)
virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData *y)
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
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...
static float64_t dot(const bool *v1, const bool *v2, int32_t n)
Compute dot product between v1 and v2 (blas optimized)
Class CStructuredModel that represents the application specific model and contains most of the applic...
CStructuredLabels * m_labels
all of classes and functions are contained in the shogun namespace
virtual CStructuredLabels * structured_labels_factory(int32_t num_labels=0)
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)
SGVector< float64_t > get_computed_dot_feature_vector(int32_t num)
SGVector< float64_t > psi_pred
virtual CStructuredData * get_label(int32_t j)
virtual int32_t get_num_classes() const
static SGMatrix< T > create_identity_matrix(index_t size, T scale)
virtual CResultSet * argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training=true)
Base class of the components of StructuredLabels.
void set_const(T const_elem)
static CSparseMultilabel * obtain_from_generic(CStructuredData *base_data)
virtual float64_t delta_loss(CStructuredData *y1, CStructuredData *y2)
SGVector< int32_t > get_data() const
virtual int32_t get_dim() const