I have N samples of training data and M samples of test data, how i combine it together to make it MxN samples.

조회 수: 1 (최근 30일)
testdata 40X1 cell
traindat 80X1 cell
train_label 80X1 double
I have N samples of training data and M samples of test data, how i combine it together to make it MxN samples. The rows, here, represent each sample and the columns the different types of features detected from a sample. also i want to add an extra column at LAST of the data (preferably): This column should represent the desired labels for the data.
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2020년 3월 8일
편집: Ameer Hamza 2020년 3월 8일
Can you give a simple example of what you are trying to do? For example, give us 3 training samples and 3 test samples and show us how do you want them converted to 3x3=9 samples.
Also describe what data is stored in these cell arrays.
Balaji M. Sontakke
Balaji M. Sontakke 2020년 3월 8일
I want to give input to classificationLearner in matlab, I refer fishertable = readtable('fisheriris.csv'); where size of fishertable is M X N i.e. 150 X 5, Petal and sepal length and width are predictors, and species is the response.
Just i want to do classification using classificationLearner, my samples are in cell arrays testdata having the size 40 X 3 and traindata having the size 80 X 3 also trainlabel and testlabel are seperately created.
can i create predictors and species like fisheriris.csv with my data(here am attaching mat files of those test and train data).

댓글을 달려면 로그인하십시오.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 3월 8일
Following code shows how to convert the cell array from your code to the table as generated by fishertable = readtable('fisheriris.csv')
load('db3.mat');
testdata = cell2mat(reduced_testdata')';
testdata_table = array2table(testdata, ...
'VariableNames', ...
{'SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth'});
sample_labels = repmat("abcd", 40, 1); % creating random data to fill last column
% you should use your testlabels
testdata_table = addvars(testdata_table, sample_labels, ...
'NewVariableNames', 'Species');
  댓글 수: 5
Ameer Hamza
Ameer Hamza 2020년 3월 8일
This should work in MATLAB R2016b. The code join two tables (testdata table entries above and traindata entries below). data_tables has dimension of 120x5.
load('db3.mat');
testdata = cell2mat(reduced_testdata')';
testdata_table = array2table(testdata, ...
'VariableNames', ...
{'SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth'});
sample_labels = repmat("abcd", 40, 1); % creating random data to fill last column
% you should use your testlabels
testdata_table.Species = sample_labels;
load('db4.mat');
traindata = cell2mat(reduced_traindata')';
traindata_table = array2table(traindata, ...
'VariableNames', ...
{'SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth'});
sample_labels = repmat("abcd", 80, 1); % creating random data to fill last column
% you should use your testlabels
traindata_table.Species = sample_labels;
data_tables = [testdata_table; traindata_table];

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by