27 REQUIRE(predicted && ground_truth,
"CLabels objects passed to evaluate " 30 "The number of predicted and ground truth labels must " 33 "labels must be of type CStructuredLabels\n");
35 "labels must be of type CStructuredLabels\n");
40 REQUIRE(pred_labs->get_structured_data_type() ==
42 "labels must be composed of the same structured data\n");
44 switch ( pred_labs->get_structured_data_type() )
47 return evaluate_real(pred_labs, true_labs);
49 return evaluate_sequence(pred_labs, true_labs);
51 SG_ERROR(
"Unknown structured data type for evaluation\n")
68 int32_t num_equal = 0;
70 for ( int32_t i = 0 ; i < length ; ++i )
75 num_equal += truth->
value == pred->value;
81 return (1.0*num_equal) / length;
90 int32_t num_equal = 0;
92 for ( int32_t i = 0 ; i < length ; ++i )
100 REQUIRE(true_seq_data.size() == pred_seq_data.
size(),
"Corresponding ground " 101 "truth and predicted sequences must be equally long\n");
105 for ( int32_t j = 0 ; j < true_seq_data.size() ; ++j )
106 num_equal += true_seq_data[j] == pred_seq_data[j];
108 accuracies[i] = (1.0*num_equal) / true_seq_data.
size();
114 return accuracies.
mean();
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)
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
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 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
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...