Possibilistic Fuzzy C-Means (PFCM)ο
A robust soft clustering algorithm combining fuzzy memberships and outlier-aware typicalities.
π Overviewο
The Possibilistic Fuzzy C-Means (PFCM) algorithm clusters data by assigning both:
Fuzzy memberships to model soft belonging across multiple clusters
Possibilistic typicalities to identify and suppress noisy or atypical points
This dual mechanism improves on standard FCM by being more robust to noise and avoiding cluster collapse, making it ideal for ambiguous data and real-world use.
βοΈ Class Definitionο
class soft_clustering.PFCM(
n_clusters: int,
m: float = 2.0,
eta: float = 2.0,
a: float = 1.0,
b: float = 1.0,
max_iter: int = 150,
tol: float = 1e-5,
random_state: Optional[int] = None
)
π Parametersο
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
β |
Number of clusters to form. |
|
|
|
Fuzzifier for membership values. |
|
|
|
Fuzzifier for typicality values. |
|
|
|
Weight for membership influence in centroid update. |
|
|
|
Weight for typicality influence in centroid update. |
|
|
|
Maximum number of iterations. |
|
|
|
Tolerance for convergence. |
|
|
|
Seed for reproducible centroid initialization. |
π Usage Exampleο
from soft_clustering import PFCM
# Create a simple dataset
data = [[1.0, 1.1], [0.9, 0.95], [5.1, 5.2], [5.0, 5.1], [9.0, 1.0]]
# Initialize and train the model
model = PFCM(n_clusters=3, random_state=0)
model.fit(data)
# Access results
print("Cluster centers:", model.cluster_centroids)
print("Memberships:", model.membership_matrix)
print("Typicalities:", model.typicality_matrix)
π οΈ Methodsο
fit(X)ο
Train the model on input data.
Parameters:ο
X(Union[np.ndarray, List[List[float]]]): Data matrix with shape(n_samples, n_features).
Returns:ο
self: Trained model instance.
predict_typicalities(X)ο
Compute typicalities for new data points.
Returns:ο
membership_matrix(np.ndarray, shape(s,n_samples)): Membership Matrix.
predict_typicalities(X)ο
Compute typicalities for new data points.
Returns:ο
typicality_matrix(np.ndarray, shape(c, n_samples)): Typicality matrix.
π Notesο
Suitable for small and medium datasets.
Typicalities highlight noise and are useful for filtering outliers.
Combines the best of fuzzy logic and possibilistic reasoning.
π Referenceο
Nikhil R. Pal, Kuhu Pal, James M. Keller, and James C. Bezdek (2005). A Possibilistic Fuzzy C-Means Clustering Algorithm, IEEE Transactions on Fuzzy Systems, DOI:10.1109/TFUZZ.2004.840845.