Comments (2)
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.
Thanks!
from scikit-network.
Related Issues (20)
- Feature Request - Graph Isomorphism HOT 1
- Confusing results from shuffle_nodes in Louvain algorithm HOT 4
- Cannot load package HOT 4
- data.load_edge_list is missing in 0.26.0 version HOT 1
- Single commodity flow feature HOT 1
- umpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObjec HOT 5
- python -m pip install scikit-network/ fails because it is looking for /triangles.cpp: HOT 1
- Installing the latest version HOT 2
- Verbose argument not expected in regression.Dirichlet fit_transform method though in description HOT 4
- Original node name mappings HOT 1
- PageRank-based recommendations HOT 1
- module 'sknetwork.data' has no attribute 'from_edge_list' HOT 5
- Error when cutting Paris dendrogram HOT 6
- KMeans does not work with numpy.ndarray HOT 1
- Feature Request GNN for KNN HOT 7
- Error installing on Linux for Python 3.11 HOT 2
- cython: linetrace=True causes TypeError: 'NoneType' object is not callable error HOT 8
- from sknetwork.utils import edgelist2adjacency, edgelist2biadjacency HOT 1
- do you have some where description for bimodularity HOT 5
- From Louvain to Leiden: guaranteeing well-connected communities. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scikit-network.