필터 지우기
필터 지우기

how to divide the Dataset into xtrain xtest ytrain ytest

조회 수: 14 (최근 30일)
uma
uma 2022년 4월 25일
댓글: uma 2022년 5월 2일
i have a dataset 2310x25 table and i want to divide it into xtrain xtest ytain ytest.

채택된 답변

uma
uma 2022년 4월 28일
I have attached my two datasets. please help us how we can use it.
  댓글 수: 1
Chunru
Chunru 2022년 4월 28일
load cmc2.mat
t = readtable('cmc1.csv');
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
whos
Name Size Bytes Class Attributes ans 1x33 66 char cmc1 1473x10 121053 table cmdout 1x33 66 char data 1473x10 117840 double t 1473x10 122471 table
% head(t)
ns = size(data, 1); % number of samples
cv = cvpartition(ns, 'KFold', 10);
idxTrain = training(cv, 1);
idxTest = test(cv, 1);
traindata = data(idxTrain, :);
testdata = data(idxTest, :);
whos
Name Size Bytes Class Attributes ans 1x33 66 char cmc1 1473x10 121053 table cmdout 1x33 66 char cv 1x1 11978 cvpartition data 1473x10 117840 double idxTest 1473x1 1473 logical idxTrain 1473x1 1473 logical ns 1x1 8 double t 1473x10 122471 table testdata 147x10 11760 double traindata 1326x10 106080 double

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

추가 답변 (2개)

Chunru
Chunru 2022년 4월 25일
편집: Chunru 2022년 4월 25일
% doc cvpartition
data = randn(2310, 25);
%cv = cvpartition(2310, 'Holdout', 0.3);
%idxTrain = training(cv);
%idxTest = test(cv);
cv = cvpartition(2310, 'KFold', 10);
idxTrain = training(cv, 1);
idxTest = test(cv, 1);
traindata = data(idxTrain, :);
testdata = data(idxTest, :);
whos
Name Size Bytes Class Attributes cmdout 1x33 66 char cv 1x1 18674 cvpartition data 2310x25 462000 double idxTest 2310x1 2310 logical idxTrain 2310x1 2310 logical testdata 231x25 46200 double traindata 2079x25 415800 double
  댓글 수: 5
uma
uma 2022년 4월 28일
how to use .mat dataset file or csv file as you took data dimensions directly.
Chunru
Chunru 2022년 4월 28일
I don't have your data so that I have to assume the dimension.
You can always read in the data and find the dimension.

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


uma
uma 2022년 4월 28일
i'm getting the error "Dimensions of matrices being concatenated are not consistent".
  댓글 수: 4
uma
uma 2022년 4월 28일
any idea how to resolve the above error?
uma
uma 2022년 5월 2일
any idea how to resolve the above error?

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

카테고리

Help CenterFile Exchange에서 Modeling and Prediction에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by