Skip to content

Commit

Permalink
fix bug:
Browse files Browse the repository at this point in the history
cross-validation last fold missing some instances
  • Loading branch information
shijiashuai committed Nov 20, 2017
1 parent c59b502 commit ee7e28e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/thundersvm/model/svmmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ vector<float_type> SvmModel::cross_validation(DataSet dataset, SvmParam param, i
vector<int> class_idx = dataset.original_index(i);
auto idx_begin = class_idx.begin() + fold_test_count * k;
auto idx_end = idx_begin;
while (idx_end != class_idx.end() && idx_end - idx_begin < fold_test_count) idx_end++;
if (k == n_fold - 1) {
idx_end = class_idx.end();
} else {
while (idx_end != class_idx.end() && idx_end - idx_begin < fold_test_count) idx_end++;
}
for (int j: vector<int>(idx_begin, idx_end)) {
x_test.push_back(dataset.instances()[j]);
y_test.push_back(dataset.y()[j]);
Expand Down

0 comments on commit ee7e28e

Please sign in to comment.