3D Confusion Matrix
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to make a 3D confusion matrix. I made a 2D confusion matrix using the plotConfMat.m file from file exchange. My x,y and z axis have fixed values(i.e., 1,2,3,4,5).
if x==y | y==z | x==z
then
no_value;
%Ex: a(1,1,1) = no_value;
%a(1,1,2) = no_value;
else
value;
%Ex:a(1,2,3) = 2.22;
%a(2,3,4) = 3.27;
and so on.
Can anyone help me how to do a 3D confusion matrix? I have gone through confusionMatrix3d.m file from file exchange, but I do not want a bar chart.
0 comentarios
Respuestas (1)
Jaswanth
el 26 de Jul. de 2024
Hi Sansit,
To create a 3D confusion matrix in MATLAB, you can start by defining the matrix dimensions and initializing it with NaN values to represent no_value where (x = y) or (y = z) or (x = z).
Next, assign specific values to the elements where (x \neq y \neq z). Finally, visualize the matrix using scatter3 function (since you prefer not to use bar chart) to create a 3D scatter plot, which effectively displays the non-NaN values. This approach ensures that your matrix adheres to the specified conditions and provides a clear and accurate visualization.
Please refer to the following example code demonstrating the implementation discussed above:
% Define the dimensions
dims = 5;
% Initialize the 3D matrix with NaN (as no_value)
confMat3D = NaN(dims, dims, dims);
% Loop through each element and assign values
for x = 1:dims
for y = 1:dims
for z = 1:dims
if x ~= y && y ~= z && x ~= z
% Assign a specific value for demonstration purposes
confMat3D(x, y, z) = rand(); % Replace rand() with your actual value
end
end
end
end
% Visualize the 3D matrix using scatter3
[x_vals, y_vals, z_vals] = ind2sub(size(confMat3D), find(~isnan(confMat3D)));
values = confMat3D(~isnan(confMat3D));
figure;
scatter3(x_vals, y_vals, z_vals, 100, values, 'filled');
colorbar;
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
title('3D Confusion Matrix');
I hope the information provided above is helpful.
0 comentarios
Ver también
Categorías
Más información sobre Discrete Data Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!