15 using namespace shogun;
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 )
77 num_equal += truth->
value == pred->value;
83 return (1.0*num_equal) / length;
92 int32_t num_equal = 0;
94 for ( int32_t i = 0 ; i < length ; ++i )
104 REQUIRE(true_seq_data.size() == pred_seq_data.
size(),
"Corresponding ground "
105 "truth and predicted sequences must be equally long\n");
109 for ( int32_t j = 0 ; j < true_seq_data.size() ; ++j )
110 num_equal += true_seq_data[j] == pred_seq_data[j];
112 accuracies[i] = (1.0*num_equal) / true_seq_data.
size();
118 return accuracies.mean();