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". ?

 Respuesta aceptada

Image Analyst
Image Analyst el 13 de Dic. de 2020

0 votos

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]

Más respuestas (0)

Etiquetas

Preguntada:

el 13 de Dic. de 2020

Respondida:

el 13 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by