Giter VIP home page Giter VIP logo

Comments (2)

tbonald avatar tbonald commented on July 17, 2024

Thanks for your feedback.

This is due to the fact that LouvainHierarchy returns a dendrogram with equal heights. When you do a straight cut on such a dendrogram, you may get a larger number of clusters than expected. I've updated the documentation in the develop branch.

Example

scikit-network version: 0.20.0
Python version: 3.8.3
Operating System: macOS 10.15

import numpy as np
from sknetwork.data import load_netset
from sknetwork.clustering import Louvain
from sknetwork.hierarchy import LouvainHierarchy, cut_straight


graph = load_netset("openflights")
adjacency = graph.adjacency

Clustering

louvain = Louvain()
labels = louvain.fit_transform(adjacency)
len(set(labels))

Output: 35

Hierarchical clustering

louvain_hierarchy = LouvainHierarchy()
dendrogram = louvain_hierarchy.fit_transform(adjacency)
labels = cut_straight(dendrogram, n_clusters=10)
len(set(labels))

Output: 35 (depth 1)

labels = cut_straight(dendrogram, n_clusters=35)
len(set(labels))

Output: 35 (depth 1)

labels = cut_straight(dendrogram, n_clusters=36)
len(set(labels))

Output: 152 (depth 2)

np.unique(dendrogram[:, 2], return_counts=True)

Output: (array([0., 1., 2., 3.]), array([2616, 329, 117, 34]))

from scikit-network.

gokceneraslan avatar gokceneraslan commented on July 17, 2024

Thanks!

from scikit-network.

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.