how to run feature selection in a 3D matrix

2 vues (au cours des 30 derniers jours)
Hugo
Hugo le 22 Fév 2022
Réponse apportée : Ronit le 23 Août 2024
Hi,
I have a 3D matrix in MATLAB. I would like to run the function fscmrmr(), in which the column 32 is my reference variable. How can call the function fscmrmr()?. I currently have the following code:
for i=1:1:48
[idx1(i),scores1(i,:,:)] = fscmrmr(Matrix(i,:,:),Matrix(i,:,32));
end
Any suggestions would be really appreciated.
Best regards,

Réponses (1)

Ronit
Ronit le 23 Août 2024
Hello Hugo,
To perform feature selection using the fscmrmr() function on a 3D matrix in MATLAB, you need to ensure that the dimensions of the matrices you pass to the function are appropriate. The fscmrmr() function is typically used for 2D matrices, where rows represent observations and columns represent features.
In this case, we have a 3D matrix Matrix with dimensions (M, N, 48) and want to use column 32 as the reference variable for feature selection.
% Assuming Matrix is of size (M, N, 48)
numSlices = size(Matrix, 3);
M = size(Matrix, 1);
N = size(Matrix, 2);
idx1 = cell(numSlices, 1);
scores1 = cell(numSlices, 1);
for i = 1:numSlices
% Extract the i-th slice
slice = squeeze(Matrix(:, :, i));
% Ensure that the reference variable is a column vector
referenceVar = slice(:, 32);
% Run feature selection
[idx1{i}, scores1{i}] = fscmrmr(slice, referenceVar);
end
  • Squeeze the Slice to convert the 3D slice into a 2D matrix for each iteration.
  • This code will iterate over each slice of the 3D matrix, perform feature selection using fscmrmr(), and store the results in idx1 and scores1.
Please go through these documentation links for better understanding:
  1. fscmrmr() - https://www.mathworks.com/help/stats/fscmrmr.html
  2. squeeze() - https://www.mathworks.com/help/matlab/ref/squeeze.html
Regards!

Catégories

En savoir plus sur Downloads dans Help Center et File Exchange

Tags

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by