FuzzyCMeans

class geoanalytics.clustering.FuzzyCMeans.FuzzyCMeans(dataframe)[source]

Bases: object

About this algorithm

Description:

Fuzzy C-Means (FCM) is a soft clustering technique where each data point is assigned a membership score to all clusters, allowing partial membership instead of a hard assignment to a single cluster.

Parameters:
  • dataframe (pd.DataFrame) – * where:

  • The first two columns are coordinates.

  • The rest of the columns contain the features used for clustering.*

Attributes:
  • df (pd.DataFrame) – A copy of your original data, with the first two columns renamed to `’x’` and `’y’` to make things easy and clear during clustering

Execution methods

Calling from a Python program

       from geoanalytics.clustering import FuzzyCMeans

       import pandas as pd

       df = pd.read_csv("data.csv")

       obj = FuzzyCMeans(df)

       output = obj.clustering(n_clusters=3)

       labels = output[0]

       fcm.centers = output[1]

       obj.save('FuzzyCMeansLabels.csv')


**Credits**

The complete program was written by M. Charan Teja under the supervision of Professor Rage Uday Kiran.
getMemoryRSS()[source]

Prints the memory usage (RSS) of the process in kilobytes.

getMemoryUSS()[source]

Prints the memory usage (USS) of the process in kilobytes.

getRuntime()[source]

Prints the total runtime of the clustering algorithm.

run(n_clusters=4)[source]

Performs fuzzy clustering on data.

-It excludes the ‘x’ and ‘y’ columns during clustering, and uses the remaining columns. -After clustering, it adds the cluster label (based on the highest membership score) back to the original coordinates

Parameters:

n_clusters – Number of clusters to form (default is 3).

Returns:

A tuple containing: - A DataFrame with ‘x’, ‘y’, and cluster labels for each data point (based on maximum membership). - A NumPy array with coordinates of the cluster centers.

save(outputFileLabels='FuzzyCMeansLabels.csv', outputFileCenters='FuzzyCMeansCenters.csv')[source]