Skip to content

Instantly share code, notes, and snippets.

View tangert's full-sized avatar
🐢
turtles all the way down

Tyler Angert tangert

🐢
turtles all the way down
View GitHub Profile
@tangert
tangert / gensim_word2vec_procrustes_align.py
Last active June 6, 2024 18:00 — forked from quadrismegistus/gensim_word2vec_procrustes_align.py
Function to align any number of word2vec models using Procrustes matrix alignment.
# Code originally ported from HistWords <https://github.com/williamleif/histwords> by William Hamilton <[email protected]>.
def align_gensim_models(models, words=None):
"""
Returns the aligned/intersected models from a list of gensim word2vec models.
Generalized from original two-way intersection as seen above.
Also updated to work with the most recent version of gensim
Requires reduce from functools