40 void CHashedMultilabelModel::init(int32_t dim)
42 SG_ADD(&m_false_positive,
"false_positive",
"Misclassification cost for false positive",
44 SG_ADD(&m_false_negative,
"false_negative",
"Misclassification cost for false negative",
46 SG_ADD(&m_num_classes,
"num_classes",
"Number of (binary) class assignment per label",
49 SG_ADD(&m_seeds,
"seeds",
"Vector of seeds used for hashing",
77 m_false_positive = false_positive;
78 m_false_negative = false_negative;
84 "Seeds for all the classes not provided. \n");
91 SG_ERROR(
"compute_joint_feature(int32_t, CStructuredData*) is not "
92 "implemented for %s!\n",
get_name());
101 get_sparse_feature_vector(feat_idx);
110 for (int32_t i = 0; i < slabel_data.
vlen; i++)
112 int32_t label = slabel_data[i];
113 uint32_t seed = (uint32_t)m_seeds[label];
137 ASSERT(y1_slabel != NULL);
138 ASSERT(y2_slabel != NULL);
151 REQUIRE(y1.
vlen == y2.
vlen,
"Size of both the vectors should be same\n");
165 return y1 > y2 ? m_false_negative : y1 < y2 ? m_false_positive : 0;
182 int32_t feat_idx, uint32_t seed)
185 get_sparse_feature_vector(feat_idx);
194 h_vec.features[j].feat_index = (hash >> 1) % m_dim;
195 h_vec.features[j].entry =
199 h_vec.sort_features(
true);
211 REQUIRE(dense_vec[i] == d_true || dense_vec[i] == d_false,
212 "The values of dense vector should be either (%d) or (%d).\n",
215 if (dense_vec[i] == d_true)
226 if (dense_vec[i] == d_true)
237 int32_t feat_idx,
bool const training)
247 REQUIRE(m_num_classes > 0,
"The model needs to be trained before using"
248 "it for prediction.\n");
260 slabel, m_num_classes, 1, 0);
267 for (int32_t c = 0; c < m_num_classes; c++)
276 total_score += score;
294 ret->
score = total_score;
295 ret->
argmax = y_pred_label;
virtual const char * get_name() const
void sort_features(bool stable_pointer=false)
Base class of the labels used in Structured Output (SO) problems.
virtual void set_seeds(SGVector< uint32_t > seeds)
Class CMultilabelSOLabels used in the application of Structured Output (SO) learning to Multilabel Cl...
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 CStructuredLabels * structured_labels_factory(int32_t num_examples=0)
virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData *y)
static uint32_t MurmurHash3(uint8_t *data, int32_t len, uint32_t seed)
virtual void set_misclass_cost(float64_t false_positive, float64_t false_negative)
SGSparseVector< float64_t > get_sparse_joint_feature_vector(int32_t feat_idx, int32_t lab_idx)
static void range_fill_vector(T *vec, int32_t len, T start=0)
virtual ~CHashedMultilabelModel()
virtual int32_t get_dim() const
virtual float64_t delta_loss(CStructuredData *y1, CStructuredData *y2)
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...
SGSparseVectorEntry< T > * features
virtual SGSparseVector< float64_t > get_sparse_joint_feature_vector(int32_t feat_idx, CStructuredData *y)
T dense_dot(T alpha, T *vec, int32_t dim, T b)
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
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)
SGSparseVector< float64_t > psi_truth_sparse
virtual CStructuredData * get_label(int32_t j)
virtual int32_t get_num_classes() const
SGSparseVector< float64_t > psi_pred_sparse
static SGMatrix< T > create_identity_matrix(index_t size, T scale)
Base class of the components of StructuredLabels.
static CSparseMultilabel * obtain_from_generic(CStructuredData *base_data)
SGVector< int32_t > get_data() const
virtual CResultSet * argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training=true)