Git Product home page Git Product logo

tejasv58 / fuzzy-c-means-from-scratch Goto Github PK

View Code? Open in Web Editor NEW
15.0 1.0 12.0 236 KB

Simple implementation of Fuzzy C-means algorithm using python. It is used for soft clustering purpose. Visualizing the algorithm step by step with the cluster plots at each step and also the final clusters.

Jupyter Notebook 100.00%
machine-learning clustering-algorithm fuzzy-cmeans-clustering python fuzzy-cmeans soft-clustering unsupervised-learning

fuzzy-c-means-from-scratch's People

Contributors

tejasv58 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

fuzzy-c-means-from-scratch's Issues

I don't think you are calculating the distances for updating the weights incorrectly

Hi, just a friendly note but I think it should be:

def updateWeights(weight_arr, C):
        denom = np.zeros(n)
        for i in range(n_clusters):
            
            dist = (X.iloc[:,:].values - centers[i])**2
            dist = np.sum(dist, axis=1)
            dist = np.sqrt(dist)
            dist = np.power(dist, 2) # I think this line is missing
            denom  = denom + np.power(1/dist, 1/(m-1))
            
        for i in range(n_clusters):
            dist = (X.iloc[:,:].values - centers[i])**2
            dist = np.sum(dist, axis=1)
            dist = np.sqrt(dist) # Up to here is the euclidean distance but for the equation for update the weights now squares the dist
            dist = np.power(dist, 2) # I think this line is missing
            weight_arr[:,i] = np.divide(np.power(1/dist, 1/(m-1)), denom)

  return weight_arr

I can't see your cell which has the equation for the computing the new weights - I'm not sure what is needed to fix that, I've never created an equation in a notebook cell....

(1 / (dist)^2)^(1/ (m-1)) / SUM(1 / (dist)^2)^(1/ (m-1))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.