public class TrainData extends Object
Modifier and Type | Field and Description |
---|---|
protected long |
nativeObj |
Modifier | Constructor and Description |
---|---|
protected |
TrainData(long addr) |
Modifier and Type | Method and Description |
---|---|
static TrainData |
__fromPtr__(long addr) |
static TrainData |
create(Mat samples,
int layout,
Mat responses)
Creates training data from in-memory arrays.
|
static TrainData |
create(Mat samples,
int layout,
Mat responses,
Mat varIdx)
Creates training data from in-memory arrays.
|
static TrainData |
create(Mat samples,
int layout,
Mat responses,
Mat varIdx,
Mat sampleIdx)
Creates training data from in-memory arrays.
|
static TrainData |
create(Mat samples,
int layout,
Mat responses,
Mat varIdx,
Mat sampleIdx,
Mat sampleWeights)
Creates training data from in-memory arrays.
|
static TrainData |
create(Mat samples,
int layout,
Mat responses,
Mat varIdx,
Mat sampleIdx,
Mat sampleWeights,
Mat varType)
Creates training data from in-memory arrays.
|
protected void |
finalize() |
int |
getCatCount(int vi) |
Mat |
getCatMap() |
Mat |
getCatOfs() |
Mat |
getClassLabels()
Returns the vector of class labels
The function returns vector of unique labels occurred in the responses.
|
Mat |
getDefaultSubstValues() |
int |
getLayout() |
Mat |
getMissing() |
int |
getNAllVars() |
void |
getNames(List<String> names)
Returns vector of symbolic names captured in loadFromCSV()
|
long |
getNativeObjAddr() |
Mat |
getNormCatResponses() |
int |
getNSamples() |
int |
getNTestSamples() |
int |
getNTrainSamples() |
int |
getNVars() |
Mat |
getResponses() |
int |
getResponseType() |
void |
getSample(Mat varIdx,
int sidx,
float buf) |
Mat |
getSamples() |
Mat |
getSampleWeights() |
static Mat |
getSubMatrix(Mat matrix,
Mat idx,
int layout)
Extract from matrix rows/cols specified by passed indexes.
|
static Mat |
getSubVector(Mat vec,
Mat idx)
Extract from 1D vector elements specified by passed indexes.
|
Mat |
getTestNormCatResponses() |
Mat |
getTestResponses() |
Mat |
getTestSampleIdx() |
Mat |
getTestSamples()
Returns matrix of test samples
|
Mat |
getTestSampleWeights() |
Mat |
getTrainNormCatResponses()
Returns the vector of normalized categorical responses
The function returns vector of responses.
|
Mat |
getTrainResponses()
Returns the vector of responses
The function returns ordered or the original categorical responses.
|
Mat |
getTrainSampleIdx() |
Mat |
getTrainSamples()
Returns matrix of train samples
transposed.
|
Mat |
getTrainSamples(int layout)
Returns matrix of train samples
|
Mat |
getTrainSamples(int layout,
boolean compressSamples)
Returns matrix of train samples
|
Mat |
getTrainSamples(int layout,
boolean compressSamples,
boolean compressVars)
Returns matrix of train samples
|
Mat |
getTrainSampleWeights() |
void |
getValues(int vi,
Mat sidx,
float values) |
Mat |
getVarIdx() |
Mat |
getVarSymbolFlags() |
Mat |
getVarType() |
void |
setTrainTestSplit(int count)
Splits the training data into the training and test parts
SEE: TrainData::setTrainTestSplitRatio
|
void |
setTrainTestSplit(int count,
boolean shuffle)
Splits the training data into the training and test parts
SEE: TrainData::setTrainTestSplitRatio
|
void |
setTrainTestSplitRatio(double ratio)
Splits the training data into the training and test parts
The function selects a subset of specified relative size and then returns it as the training
set.
|
void |
setTrainTestSplitRatio(double ratio,
boolean shuffle)
Splits the training data into the training and test parts
The function selects a subset of specified relative size and then returns it as the training
set.
|
void |
shuffleTrainTest() |
public long getNativeObjAddr()
public static TrainData __fromPtr__(long addr)
public Mat getCatMap()
public Mat getCatOfs()
public Mat getClassLabels()
public Mat getDefaultSubstValues()
public Mat getMissing()
public Mat getNormCatResponses()
public Mat getResponses()
public Mat getSampleWeights()
public Mat getSamples()
public static Mat getSubMatrix(Mat matrix, Mat idx, int layout)
matrix
- input matrix (supported types: CV_32S, CV_32F, CV_64F)idx
- 1D index vectorlayout
- specifies to extract rows (cv::ml::ROW_SAMPLES) or to extract columns (cv::ml::COL_SAMPLES)public static Mat getSubVector(Mat vec, Mat idx)
vec
- input vector (supported types: CV_32S, CV_32F, CV_64F)idx
- 1D index vectorpublic Mat getTestNormCatResponses()
public Mat getTestResponses()
public Mat getTestSampleIdx()
public Mat getTestSampleWeights()
public Mat getTestSamples()
public Mat getTrainNormCatResponses()
0
to `<number of
classes>-1`. The actual label value can be retrieved then from the class label vector, see
TrainData::getClassLabels.public Mat getTrainResponses()
public Mat getTrainSampleIdx()
public Mat getTrainSampleWeights()
public Mat getTrainSamples(int layout, boolean compressSamples, boolean compressVars)
layout
- The requested layout. If it's different from the initial one, the matrix is
transposed. See ml::SampleTypes.compressSamples
- if true, the function returns only the training samples (specified by
sampleIdx)compressVars
- if true, the function returns the shorter training samples, containing only
the active variables.
In current implementation the function tries to avoid physical data copying and returns the
matrix stored inside TrainData (unless the transposition or compression is needed).public Mat getTrainSamples(int layout, boolean compressSamples)
layout
- The requested layout. If it's different from the initial one, the matrix is
transposed. See ml::SampleTypes.compressSamples
- if true, the function returns only the training samples (specified by
sampleIdx)
the active variables.
In current implementation the function tries to avoid physical data copying and returns the
matrix stored inside TrainData (unless the transposition or compression is needed).public Mat getTrainSamples(int layout)
layout
- The requested layout. If it's different from the initial one, the matrix is
transposed. See ml::SampleTypes.
sampleIdx)
the active variables.
In current implementation the function tries to avoid physical data copying and returns the
matrix stored inside TrainData (unless the transposition or compression is needed).public Mat getTrainSamples()
public Mat getVarIdx()
public Mat getVarSymbolFlags()
public Mat getVarType()
public static TrainData create(Mat samples, int layout, Mat responses, Mat varIdx, Mat sampleIdx, Mat sampleWeights, Mat varType)
samples
- matrix of samples. It should have CV_32F type.layout
- see ml::SampleTypes.responses
- matrix of responses. If the responses are scalar, they should be stored as a
single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
former case the responses are considered as ordered by default; in the latter case - as
categorical)varIdx
- vector specifying which variables to use for training. It can be an integer vector
(CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
active variables.sampleIdx
- vector specifying which samples to use for training. It can be an integer
vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
of training samples.sampleWeights
- optional vector with weights for each sample. It should have CV_32F type.varType
- optional vector of type CV_8U and size `<number_of_variables_in_samples> +
<number_of_variables_in_responses>`, containing types of each input and output variable. See
ml::VariableTypes.public static TrainData create(Mat samples, int layout, Mat responses, Mat varIdx, Mat sampleIdx, Mat sampleWeights)
samples
- matrix of samples. It should have CV_32F type.layout
- see ml::SampleTypes.responses
- matrix of responses. If the responses are scalar, they should be stored as a
single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
former case the responses are considered as ordered by default; in the latter case - as
categorical)varIdx
- vector specifying which variables to use for training. It can be an integer vector
(CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
active variables.sampleIdx
- vector specifying which samples to use for training. It can be an integer
vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
of training samples.sampleWeights
- optional vector with weights for each sample. It should have CV_32F type.
<number_of_variables_in_responses>`, containing types of each input and output variable. See
ml::VariableTypes.public static TrainData create(Mat samples, int layout, Mat responses, Mat varIdx, Mat sampleIdx)
samples
- matrix of samples. It should have CV_32F type.layout
- see ml::SampleTypes.responses
- matrix of responses. If the responses are scalar, they should be stored as a
single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
former case the responses are considered as ordered by default; in the latter case - as
categorical)varIdx
- vector specifying which variables to use for training. It can be an integer vector
(CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
active variables.sampleIdx
- vector specifying which samples to use for training. It can be an integer
vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
of training samples.
<number_of_variables_in_responses>`, containing types of each input and output variable. See
ml::VariableTypes.public static TrainData create(Mat samples, int layout, Mat responses, Mat varIdx)
samples
- matrix of samples. It should have CV_32F type.layout
- see ml::SampleTypes.responses
- matrix of responses. If the responses are scalar, they should be stored as a
single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
former case the responses are considered as ordered by default; in the latter case - as
categorical)varIdx
- vector specifying which variables to use for training. It can be an integer vector
(CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
active variables.
vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
of training samples.
<number_of_variables_in_responses>`, containing types of each input and output variable. See
ml::VariableTypes.public static TrainData create(Mat samples, int layout, Mat responses)
samples
- matrix of samples. It should have CV_32F type.layout
- see ml::SampleTypes.responses
- matrix of responses. If the responses are scalar, they should be stored as a
single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
former case the responses are considered as ordered by default; in the latter case - as
categorical)
(CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
active variables.
vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
of training samples.
<number_of_variables_in_responses>`, containing types of each input and output variable. See
ml::VariableTypes.public int getCatCount(int vi)
public int getLayout()
public int getNAllVars()
public int getNSamples()
public int getNTestSamples()
public int getNTrainSamples()
public int getNVars()
public int getResponseType()
public void getNames(List<String> names)
names
- automatically generatedpublic void getSample(Mat varIdx, int sidx, float buf)
public void getValues(int vi, Mat sidx, float values)
public void setTrainTestSplit(int count, boolean shuffle)
count
- automatically generatedshuffle
- automatically generatedpublic void setTrainTestSplit(int count)
count
- automatically generatedpublic void setTrainTestSplitRatio(double ratio, boolean shuffle)
ratio
- automatically generatedshuffle
- automatically generatedpublic void setTrainTestSplitRatio(double ratio)
ratio
- automatically generatedpublic void shuffleTrainTest()
Generated on Wed Oct 9 2019 23:24:43 UTC / OpenCV 4.1.2