|
|
|
@ -50,13 +50,6 @@ 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() ) |
|
|
|
@ -119,6 +112,7 @@ Mat TrainData::getSubVector(const Mat& vec, const Mat& idx) |
|
|
|
|
return subvec; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TrainDataImpl CV_FINAL : public TrainData |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
@ -155,6 +149,12 @@ public: |
|
|
|
|
return layout == ROW_SAMPLE ? samples.cols : samples.rows; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Mat getTestSamples() const CV_OVERRIDE |
|
|
|
|
{ |
|
|
|
|
Mat idx = getTestSampleIdx(); |
|
|
|
|
return idx.empty() ? Mat() : getSubVector(samples, idx); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Mat getSamples() const CV_OVERRIDE { return samples; } |
|
|
|
|
Mat getResponses() const CV_OVERRIDE { return responses; } |
|
|
|
|
Mat getMissing() const CV_OVERRIDE { return missing; } |
|
|
|
@ -987,22 +987,11 @@ public: |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FILE* file; |
|
|
|
|
int layout; |
|
|
|
|
Mat samples, missing, varType, varIdx, varSymbolFlags, responses, missingSubst; |
|
|
|
|
Mat sampleIdx, trainSampleIdx, testSampleIdx; |
|
|
|
|
Mat sampleWeights, catMap, catOfs; |
|
|
|
|
Mat normCatResponses, classLabels, classCounters; |
|
|
|
|
MapType nameMap; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
void TrainData::getNames(std::vector<String>& names) const |
|
|
|
|
{ |
|
|
|
|
const TrainDataImpl* impl = dynamic_cast<const TrainDataImpl*>(this); |
|
|
|
|
CV_Assert(impl != 0); |
|
|
|
|
size_t n = impl->nameMap.size(); |
|
|
|
|
TrainDataImpl::MapType::const_iterator it = impl->nameMap.begin(), |
|
|
|
|
it_end = impl->nameMap.end(); |
|
|
|
|
void getNames(std::vector<String>& names) const CV_OVERRIDE |
|
|
|
|
{ |
|
|
|
|
size_t n = nameMap.size(); |
|
|
|
|
TrainDataImpl::MapType::const_iterator it = nameMap.begin(), |
|
|
|
|
it_end = nameMap.end(); |
|
|
|
|
names.resize(n+1); |
|
|
|
|
names[0] = "?"; |
|
|
|
|
for( ; it != it_end; ++it ) |
|
|
|
@ -1012,14 +1001,22 @@ void TrainData::getNames(std::vector<String>& names) const |
|
|
|
|
CV_Assert( label > 0 && label <= (int)n ); |
|
|
|
|
names[label] = s; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Mat getVarSymbolFlags() const CV_OVERRIDE |
|
|
|
|
{ |
|
|
|
|
return varSymbolFlags; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FILE* file; |
|
|
|
|
int layout; |
|
|
|
|
Mat samples, missing, varType, varIdx, varSymbolFlags, responses, missingSubst; |
|
|
|
|
Mat sampleIdx, trainSampleIdx, testSampleIdx; |
|
|
|
|
Mat sampleWeights, catMap, catOfs; |
|
|
|
|
Mat normCatResponses, classLabels, classCounters; |
|
|
|
|
MapType nameMap; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Mat TrainData::getVarSymbolFlags() const |
|
|
|
|
{ |
|
|
|
|
const TrainDataImpl* impl = dynamic_cast<const TrainDataImpl*>(this); |
|
|
|
|
CV_Assert(impl != 0); |
|
|
|
|
return impl->varSymbolFlags; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Ptr<TrainData> TrainData::loadFromCSV(const String& filename, |
|
|
|
|
int headerLines, |
|
|
|
|