How can i write code on matlab to find the last value in each row contains the target label for that row, and the remaining values are the features. Split the data into 10 approximately equally-sized "folds". ?

 채택된 답변

Image Analyst
Image Analyst 2020년 12월 13일

0 개 추천

Try this:
m = randi(9, 30000, 3); % Sample data.
lastColumn = m(:, end);
targetValue = 5; % Whatever...
% Find where the last column matches our target value.
matches = lastColumn == targetValue;
fprintf('Found %d matches of %d (out of %d) in the last column.\n', ...
sum(matches), size(m, 1), targetValue);
% Extract the matching rows up until but not including the last column.
m2 = m(matches, 1:end-1);
[rows2, columns2] = size(m2)
% Get starting and ending rows to split this up into 10 submatrices.
rStart = round(linspace(1, rows2-rows2/10, 10))
rEnd = [rStart(2:end)-1, rows2]

추가 답변 (0개)

카테고리

태그

질문:

2020년 12월 13일

답변:

2020년 12월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by