// $Id: CrossValidationSampler.cc 1392 2008-07-28 19:35:30Z peter $ /* Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson Copyright (C) 2008 Peter Johansson This file is part of the yat library, http://dev.thep.lu.se/yat The yat library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The yat library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "CrossValidationSampler.h" #include "Target.h" #include "yat/random/random.h" #include #include #include #include namespace theplu { namespace yat { namespace classifier { CrossValidationSampler::CrossValidationSampler(const Target& target, const size_t N, const size_t k) : Sampler(target, N), k_(k) { assert(target.size()>1); build(target, N, k); } CrossValidationSampler::~CrossValidationSampler() { } void CrossValidationSampler::build(const Target& target, size_t N, size_t k) { std::vector > v; for (size_t i=0; i my_begin; my_begin.reserve(target.nof_classes()); my_begin.push_back(0); for (size_t i=1; i my_begin.size()-1) my_begin.push_back(i); my_begin.push_back(target.size()); for (size_t i=0; i training_index; std::vector validation_index; for (size_t j=0; j