Docs · Machine learning

pic: power iteration clustering.

Graph clustering by power iteration, the equivalent of Spark MLlib's PowerIterationClustering with random initialisation.

Module
ml_pic
Header
clio_ml/pic.h

What it does

Graph clustering by power iteration, the equivalent of Spark MLlib's PowerIterationClustering with random initialisation. Each iteration computes v = D-1Wv over the paged edge list in one pass; k-means on the final vector assigns the clusters.

Rows

Directed edges [src, dst, weight, pad]; an undirected graph stores both directions. Vertex ids are below 224.

Python

python
import numpy as np, clio_ml as cm
r = cm.fit_pic(E, num_vertices=10000, k=4)     # E: rows of (src, dst, w, 0)
print(r.assignment[:10])
  • fit_pic(X, **options) accepts an in-memory array or a paged Dataset from cm.dataset(X) or cm.assimilate(...).
  • Options: num_vertices (required), k (2), iters (10), seed (1), threads (256).
  • Result PicResult: embedding (the final vector, one value per vertex), assignment (cluster per vertex), stats.

C++

cpp
PicResult FitPic(Dataset &ds, const PicOptions &opt);
PicResult FitPicPlain(const float *edges, u64 n_edges, u64 elems_per_page,
                      u32 nblocks, const PicOptions &opt);

The paged call needs the runtime; the Plain call runs the same kernel over a plain copy of the data without one.

Related: k-means, ALS. Back to the machine learning overview.