I have a large matrix with values ranging from -255 to 255. How do I use matalb to perform a svm analysis on the matrix to perform a linear classification between the negative and positive values?

Antworten (1)

Walter Roberson
Walter Roberson am 28 Jul. 2023

0 Stimmen

ND = ndims(YourMatrix);
IDXs = cell(1,ND);
[IDXs{:}] = ind2sub(size(YourMatrix), (1:numel(YourMatrix)).');
Data_for_SVM = horzcat(IDXs{:}, YourMatrix(:));
Now you can pass Data_for_SVM to an appropriate SVM-related routine.
What the above function is doing is creating a matrix in which each row corresponds to the indices of a single element of the array, followed by the content of the element. Like
1 1 A(1,1)
2 1 A(2,1)
3 1 A(3,1)
1 2 A(1,2)
2 2 A(2,2)
3 2 A(3,2)
This gives the SVM functions information about the position and value of each entry in the matrix.
The code was deliberately written to not depend upon the matrix being 2D, since you did not specify a dimension of the matrix.
It is not at all clear to me what klnds of responses you were hoping to get? A hyperplane that "optimally" divides the negative and positive values??

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022b

Tags

Gefragt:

am 27 Jul. 2023

Beantwortet:

am 28 Jul. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by