Scikit-network
Scikit-network is a Python library for the analysis of large graphs, providing state-of-the-art algorithms for clustering, classification, ranking, embedding, and more. It is currently at version 0.33.5 and actively maintained with frequent minor releases that include new features, bug fixes, and Python version support.
Warnings
- breaking Major API changes for clustering, classification, ranking, and GNN algorithms. Methods like `fit_transform` were introduced, and parameter names were changed (e.g., `seeds` to `labels` for classification, `seeds` to `weights` for ranking).
- breaking The parameter `membership` was renamed to `probs` in soft classification and clustering algorithms.
- breaking Support for older Python versions has been dropped. Python 3.9 was dropped in 0.33.5, and Python 3.8 was dropped in 0.33.0.
- deprecated The 'hierarchical Louvain embedding' feature was removed.
- deprecated First-order methods for link prediction were removed.
Install
-
pip install scikit-network
Imports
- Louvain
from sknetwork.clustering import Louvain
- KarateClub
from sknetwork.data import karate_club
- DiffusionClassifier
from sknetwork.classification import DiffusionClassifier
- PageRank
from sknetwork.ranking import PageRank
Quickstart
from sknetwork.data import karate_club
from sknetwork.clustering import Louvain
# Load an example graph (Karate Club dataset)
graph = karate_club()
adjacency = graph.adjacency
# Apply Louvain clustering algorithm
louvain = Louvain()
labels = louvain.fit_predict(adjacency)
print(f"Number of nodes: {adjacency.shape[0]}")
print(f"Detected cluster labels (first 10): {labels[:10]}")
print(f"Unique clusters found: {len(set(labels))}")