30 REQUIRE(predicted && ground_truth,
"CLabels objects passed to evaluate "
33 "The number of predicted and ground truth labels must "
36 "labels must be of type CStructuredLabels\n");
38 "labels must be of type CStructuredLabels\n");
43 REQUIRE(pred_labs->get_structured_data_type() ==
45 "labels must be composed of the same structured data\n");
47 switch (pred_labs->get_structured_data_type())
50 return evaluate_real(pred_labs, true_labs);
53 return evaluate_sequence(pred_labs, true_labs);
56 return evaluate_sparse_multilabel(pred_labs, true_labs);
59 SG_ERROR(
"Unknown structured data type for evaluation\n")
76 int32_t num_equal = 0;
78 for (int32_t i = 0 ; i < length ; ++i)
83 num_equal += truth->
value == pred->value;
89 return (1.0 * num_equal) / length;
98 int32_t num_equal = 0;
100 for (int32_t i = 0 ; i < length ; ++i)
108 REQUIRE(true_seq_data.size() == pred_seq_data.
size(),
"Corresponding ground "
109 "truth and predicted sequences must be equally long\n");
114 for (int32_t j = 0 ; j < true_seq_data.size() ; ++j)
116 num_equal += true_seq_data[j] == pred_seq_data[j];
119 accuracies[i] = (1.0 * num_equal) / true_seq_data.
size();
Base class of the labels used in Structured Output (SO) problems.
virtual ~CStructuredAccuracy()
virtual ELabelType get_label_type() const =0
virtual float64_t evaluate(CLabels *predicted, CLabels *ground_truth)
Class CMultilabelSOLabels used in the application of Structured Output (SO) learning to Multilabel Cl...
The class Labels models labels, i.e. class assignments of objects.
virtual int32_t get_num_labels() const =0
structured labels (e.g. sequences, trees) used in Structured Output problems
virtual float64_t evaluate(CLabels *predicted, CLabels *ground_truth)
static CRealNumber * obtain_from_generic(CStructuredData *base_data)
Class CSequence to be used in the application of Structured Output (SO) learning to Hidden Markov Sup...
static floatmax_t mean(SGVector< T > vec)
static SGMatrix< int32_t > get_confusion_matrix(CLabels *predicted, CLabels *ground_truth)
all of classes and functions are contained in the shogun namespace
virtual int32_t get_num_labels() const
Class CMultilabelAccuracy used to compute accuracy of multilabel classification.
SGVector< int32_t > get_data() const
virtual CStructuredData * get_label(int32_t idx)
static CSequence * obtain_from_generic(CStructuredData *base_data)
static CStructuredLabels * to_structured(CLabels *base_labels)
Class CRealNumber to be used in the application of Structured Output (SO) learning to multiclass clas...
EStructuredDataType get_structured_data_type()
Class Evaluation, a base class for other classes used to evaluate labels, e.g. accuracy of classifica...
virtual CMultilabelLabels * get_multilabel_labels()