Merge pull request #6103 from mshabunin:add-get-samples

This commit is contained in:
Maksim Shabunin 2016-02-15 13:11:28 +00:00
commit 1aeff45631
2 changed files with 10 additions and 0 deletions

View File

@ -224,6 +224,9 @@ public:
CV_WRAP virtual void setTrainTestSplitRatio(double ratio, bool shuffle=true) = 0;
CV_WRAP virtual void shuffleTrainTest() = 0;
/** @brief Returns matrix of test samples */
CV_WRAP Mat getTestSamples() const;
CV_WRAP static Mat getSubVector(const Mat& vec, const Mat& idx);
/** @brief Reads the dataset from a .csv file and returns the ready-to-use training data.

View File

@ -50,6 +50,13 @@ static const int VAR_MISSED = VAR_ORDERED;
TrainData::~TrainData() {}
Mat TrainData::getTestSamples() const
{
Mat idx = getTestSampleIdx();
Mat samples = getSamples();
return idx.empty() ? Mat() : getSubVector(samples, idx);
}
Mat TrainData::getSubVector(const Mat& vec, const Mat& idx)
{
if( idx.empty() )