Skip to content

ml_TrainData_create

mlfunctionOpenCV 5.0.0
import { ml_TrainData_create } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSsamples, layout, responses, varIdx
FUNCTIONml_TrainData_create
RETURN TYPEml_TrainData | null
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Creates training data from in-memory arrays.

ml_TrainData_create(samples: Mat, layout: number, responses: Mat, varIdx: Mat, sampleIdx: Mat, sampleWeights: Mat, varType: Mat): ml_TrainData | null;
5 available overloads
ml_TrainData_create(samples: Mat, layout: number, responses: Mat): ml_TrainData | null;
ml_TrainData_create(samples: Mat, layout: number, responses: Mat, varIdx: Mat): ml_TrainData | null;
ml_TrainData_create(samples: Mat, layout: number, responses: Mat, varIdx: Mat, sampleIdx: Mat): ml_TrainData | null;
ml_TrainData_create(samples: Mat, layout: number, responses: Mat, varIdx: Mat, sampleIdx: Mat, sampleWeights: Mat): ml_TrainData | null;
ml_TrainData_create(samples: Mat, layout: number, responses: Mat, varIdx: Mat, sampleIdx: Mat, sampleWeights: Mat, varType: Mat): ml_TrainData | null;
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.

Returns

The ml_TrainData | null result.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.