Skip to content

Commit

Permalink
print metric for cross-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
zeyiwen committed Jun 14, 2018
1 parent 22651ce commit f747325
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/thundersvm/model/svmmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ vector<float_type> SvmModel::cross_validation(DataSet dataset, SvmParam param, i
vector<float_type> y_predict_all(dataset.n_instances());

for (int k = 0; k < n_fold; ++k) {
LOG(INFO) << n_fold << " fold cross-validation(" << k + 1 << "/" << n_fold << ")";
LOG(INFO) << n_fold << " fold cross-validation (" << k + 1 << "/" << n_fold << ")";
DataSet::node2d x_train, x_test;
vector<float_type> y_train, y_test;
vector<int> test_idx;
Expand Down
34 changes: 18 additions & 16 deletions src/thundersvm/thundersvm-train.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,27 @@ int main(int argc, char **argv) {
}

//perform svm testing
/*std::shared_ptr<Metric> metric;
switch (parser.param_cmd.svm_type) {
case SvmParam::C_SVC:
case SvmParam::NU_SVC: {
metric.reset(new Accuracy());
break;
}
case SvmParam::EPSILON_SVR:
case SvmParam::NU_SVR: {
metric.reset(new MSE());
break;
if(parser.do_cross_validation) {
std::shared_ptr<Metric> metric;
switch (parser.param_cmd.svm_type) {
case SvmParam::C_SVC:
case SvmParam::NU_SVC: {
metric.reset(new Accuracy());
break;
}
case SvmParam::EPSILON_SVR:
case SvmParam::NU_SVR: {
metric.reset(new MSE());
break;
}
case SvmParam::ONE_CLASS: {
}
}
case SvmParam::ONE_CLASS: {
if (metric) {
std::cout << metric->name() << " = " << metric->score(predict_y, train_dataset.y()) << std::endl;
}
}
if (metric) {
std::cout << metric->name() << " = " << metric->score(predict_y, train_dataset.y()) << std::endl;
}
*/

}
catch (std::bad_alloc &) {
LOG(FATAL) << "out of memory, you may try \"-m memory size\" to constrain memory usage";
Expand Down

0 comments on commit f747325

Please sign in to comment.