Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit afe5004

Browse files
committedSep 2, 2024
feature matrix
1 parent a6dfa99 commit afe5004

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed
 

‎feature_matrix.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
featureMatrix = {
3+
{1.0, 0.5, 0.2},
4+
{0.3, 0.8, 0.6},
5+
{0.7, 0.1, 0.4}
6+
};
7+
8+
MatrixPlot[featureMatrix]
9+
10+
MatrixPlot[featureMatrix, ColorFunction -> "Rainbow", Frame -> False, Mesh -> True]
11+
12+
(* bug *)
13+
MatrixPlot[
14+
featureMatrix,
15+
FrameTicks -> {{"Row 1", "Row 2", "Row 3"}, {"Feature 1", "Feature 2", "Feature 3"}},
16+
ColorFunction -> "Rainbow"
17+
]

‎feature_matrix.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
4+
# Define the feature matrix
5+
feature_matrix = np.array([
6+
[1.0, 0.5, 0.2],
7+
[0.3, 0.8, 0.6],
8+
[0.7, 0.1, 0.4]
9+
])
10+
11+
# Create a plot
12+
plt.imshow(feature_matrix, cmap='rainbow', aspect='auto')
13+
14+
# Add color bar
15+
plt.colorbar()
16+
17+
18+
# Set tick positions and labels
19+
plt.xticks(ticks=np.arange(feature_matrix.shape[1]), labels=["Feature 1", "Feature 2", "Feature 3"])
20+
21+
plt.yticks(ticks=np.arange(feature_matrix.shape[0]), labels=["Row 1", "Row 2", "Row 3"])
22+
23+
# Add labels
24+
plt.xlabel('Features')
25+
plt.ylabel('Rows')
26+
27+
# Show the plot
28+
plt.show() # close plt can next run

‎feature_matrix_mma.png

365 KB
Loading

‎feature_matrix_py.png

403 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.