How to load data Matrix for svm [closed]
i have extracted features data in .csv files. For each feature there are 5 .csv file and i have 13 features so there are around 50 files containing feature data. The data type is float/double.
// Set up training data
float labels[4] = {1.0, -1.0, -1.0, -1.0};
Mat labelsMat(4, 1, CV_32FC1, labels);
float trainingData[4][2] = { {501, 10}, {255, 10}, {501, 255}, {10, 501} };
Mat trainingDataMat(4, 2, CV_32FC1, trainingData);
In here training data is a 4x2 matrix. but my files have around 900x400 data and all the files are not the same. (eg: 900x420, 900x380, 900x450)
Now i want to load this data in to svm training data. How can i do this?
is it possible, to concatenate your data to a single csv file ? (with, say label as 1st row)
(cv::ml::TrainData has means to load that)
umm a single csv file contain 900x400 data so you mean combine all of those csv file to a single file which will be around 900xsomething. But then how can i label them?
you mean in the csv file column A must contain the label?
that's only the most easy proposal.
it must be column wise, but can there be more than one, (and not nessecarily at the front), -- see docs here , you have to give it a min and max offset, anything inbetween is considered a label.
for an svm, you will have to add a new column (at the end, or the front, maybe, up tp you) containin one class label for the resp. row
how many classes are there ? how do your labels(class-ids) and your csv files relate ?
there are 13 classes and one csv file contain features from an one image (eg: 01.csv => black car image 1)