KXkonstantinos.xafis
Machine Learning & AIAcademic2025

DeepWalk from Scratch

PythonPyTorchnetworkxscikit-learn

Overview

An implementation of the DeepWalk node-embedding technique built entirely from scratch: random walks over a graph, treated as sentences for a Continuous Bag-of-Words model.

What I built

Random-walk generation over Zachary’s Karate Club graph (nx.karate_club_graph), with walk/context-window datasets cached to CSV for reproducible runs. The CBOW model is minimal by design: an embedding layer, mean-pooled context, a linear layer and log-softmax — trained with Adam and cross-entropy.

The CLI grid-searches over window size, walk length, number of walks and embedding dimension (12–32), with early stopping. Evaluation clusters the learned embeddings with KMeans and compares against the true club split, and t-SNE visualizations expose the embedding geometry.

Technical highlights

Outcome

Learned embeddings that recover the club structure — the classic technique, implemented by hand.