RPFKM Algorithm Documentationο
π Overviewο
The Robust Projected Fuzzy K-Means (RPFKM) is a fuzzy clustering algorithm designed for high-dimensional data with noise and outliers. It combines fuzzy clustering with dimensionality reduction and robustness mechanisms to improve clustering quality.
βοΈ Class Definitionο
Class Name: RPFKM
Implements the RPFKM algorithm with projection learning and robust optimization. Exposes a fit_predict method to run clustering on data.
class RPFKM(
c: int,
d: int,
gamma: float = 1.0,
beta: float = 0.5,
max_iter: int = 100
)
π Parametersο
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
β |
Number of clusters |
|
|
β |
Dimension of reduced subspace |
|
|
|
Fuzzy membership regularization |
|
|
|
Data reconstruction regularization |
|
|
|
Number of iterations |
π Usage Examplesο
import numpy as np
from rpfkm import RPFKM # Assuming RPFKM class is saved in rpfkm.py
def test_rpfkm_basic():
from sklearn.datasets import make_blobs
# Generate synthetic dataset
X, _ = make_blobs(n_samples=100, centers=3, n_features=10, random_state=42)
X = X.T # Transpose to shape (D, N)
# Initialize and run the RPFKM algorithm
model = RPFKM(c=3, d=5, gamma=0.1, beta=1.0, max_iter=10)
labels, U, W = model.fit_predict(X)
print("Cluster labels:", labels)
print("Membership matrix U shape:", U.shape)
print("Projection matrix W shape:", W.shape)
if __name__ == "__main__":
test_rpfkm_basic()
π οΈ Methodsο
fit_predict(X)ο
Cluster input data X using the RPFKM algorithm.
Parameters:
X(np.ndarray, shape(D, N)): Input data withDfeatures andNsamples.
Returns:
labels(np.ndarray): Cluster label per sample.U(np.ndarray): Fuzzy membership matrix(c, N).W(np.ndarray): Projection matrix(D, d).
π Implementation Notesο
Projection matrix
Wis learned via eigen decomposition of a scatter matrix difference.Membership matrix
Uis updated using softmax-like fuzzy assignment.Auxiliary weights
pincrease robustness against outliers.Initialization uses Dirichlet distribution for
Uand orthogonal random matrix forW.
π Referenceο
Improving Projected Fuzzy K-Means Clustering via Robust Learning.