Coder Social home page Coder Social logo

Count images in a cluster about pix-plot HOT 4 CLOSED

yaledhlab avatar yaledhlab commented on May 12, 2024
Count images in a cluster

from pix-plot.

Comments (4)

duhaime avatar duhaime commented on May 12, 2024

Thanks for your note @Kesavadas , that's a good question!

The easiest way to find the number of images in each cluster is to make the following changes to utils/process_images.py.

First, change line 16 to: from collections import defaultdict, Counter

Then, inside the function get_centroids, right after the line that says
X = np.array(self.image_vectors)
add the following:

# find the number of observations in each cluster
cluster_indices = model.fit_predict(X)
print(Counter(cluster_indices))

That will print out a counter object that maps each cluster index to the number of observations in that cluster. E.g. here's the output for a 20 cluster model with ~1000 images:

Counter({14: 261, 16: 247, 4: 211, 8: 200, 2: 190, 0: 160, 9: 144, 12: 133, 11: 90, 6: 79, 7: 76, 15: 68, 13: 65, 18: 64, 17: 59, 3: 56, 10: 46, 19: 32, 1: 30, 5: 19})

That output says that cluster index 14 has 261 observations, cluster index 16 has 247 observations, and so forth.

If any of this is unclear or if you have trouble making those changes, please feel free to follow up!

from pix-plot.

duhaime avatar duhaime commented on May 12, 2024

@Kesavadas is it alright to close this issue? If so I'd be grateful if you could!

from pix-plot.

Kesavadas avatar Kesavadas commented on May 12, 2024

Sorry for the delay ... I couldn't test it yet
I will close it now
If I encounter any issues I will get back to you
Thanks for your help

from pix-plot.

duhaime avatar duhaime commented on May 12, 2024

No worries @Kesavadas, thanks for following up!

from pix-plot.

Related Issues (20)

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.