Overview
TheMatrixTable component displays membership matrices in a tabular format, showing the degree of membership for each data point across all clusters. This provides a numerical view of the fuzzy clustering results.
Props
A 2D array representing the membership matrix where
matrix[i][j] is the membership degree of point j in cluster i. Values range from 0 to 1, and for each point, the sum of memberships across all clusters equals 1.The title displayed above the table, typically “Membership Matrix” or a descriptive label for the matrix type.
Usage
Table Structure
Column Generation
The component dynamically generates columns based on the number of points:- First Column:
C(Centroid index) - fixed to remain visible during horizontal scrolling - Subsequent Columns:
P0,P1,P2, … (Point indices) - one column per data point
Row Generation
Each row represents a cluster’s membership values across all points:- Rows are indexed by centroid/cluster number
- Membership values are formatted to 4 decimal places for readability
- Spread operator unpacks the membership values into table columns
Matrix Interpretation
Reading the Table
| C | P0 | P1 | P2 | P3 |
|---|---|---|---|---|
| 0 | 0.9234 | 0.0821 | 0.8765 | 0.1234 |
| 1 | 0.0766 | 0.9179 | 0.1235 | 0.8766 |
- Point 0 (P0) has 92.34% membership in Cluster 0
- Point 1 (P1) has 91.79% membership in Cluster 1
- Point 2 (P2) has 87.65% membership in Cluster 0
- Point 3 (P3) has 87.66% membership in Cluster 1
Fuzzy Clustering Properties
For each column (point), the sum of all membership values equals 1:Table Configuration
The component uses Ant Design’sTable with specific configurations:
Table Features
Renders a custom title as an H3 heading with semibold styling
Enables scrolling:
- Horizontal (
x: true) - for tables with many points - Vertical (
y: 300) - limits height to 300px
Disabled (
false) to show all clusters at onceSet to
'auto' to automatically size columns based on contentCustom class
'matrix' for additional stylingUse Cases
Membership Matrix Display
The primary use case is displaying the fuzzy c-means membership matrix after clustering:Distance Matrix Display
Can also be used to display distance matrices or other 2D numerical data:Responsive Behavior
- Fixed First Column: The centroid index column remains visible when scrolling horizontally
- Horizontal Scroll: Automatically enabled for tables with many points
- Vertical Scroll: Limited to 300px height to prevent excessive vertical space usage
- Auto Layout: Columns size automatically to fit content
Data Formatting
All numerical values are formatted to 4 decimal places:Empty State
When the matrix is empty (matrix.length === 0):
- Only the centroid column header is displayed
- No data rows are rendered
- The table structure remains intact
Source Code
View the full implementation in the repository:src/components/MatrixTable.tsx