How to load data Matrix for svm [closed]

asked 2016-10-02 05:09:02 -0500

damiya14 gravatar image

updated 2016-10-02 06:43:52 -0500

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?

CSV Files

Data in a CSV file

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-10 23:23:15.575824

Comments

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)

berak gravatar imageberak ( 2016-10-02 06:07:33 -0500 )edit

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?

damiya14 gravatar imagedamiya14 ( 2016-10-02 06:36:59 -0500 )edit

you mean in the csv file column A must contain the label?

damiya14 gravatar imagedamiya14 ( 2016-10-02 06:47:15 -0500 )edit

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

berak gravatar imageberak ( 2016-10-02 07:23:58 -0500 )edit

how many classes are there ? how do your labels(class-ids) and your csv files relate ?

berak gravatar imageberak ( 2016-10-02 07:28:21 -0500 )edit

there are 13 classes and one csv file contain features from an one image (eg: 01.csv => black car image 1)

damiya14 gravatar imagedamiya14 ( 2016-10-02 09:29:18 -0500 )edit