/matrixor

Matrix transformation in Python

Primary LanguagePythonMIT LicenseMIT

matrixor

GitHub release PyPI release Build MIT License

Matrix transformations in Python. Implements algorithm 2.4 (AO+Scaling) of the paper:

@article{devetal2018,
    title={{Absolute Orientation for Word Embedding Alignment}},
    author={Sunipa Dev and Safia Hassan and Jeff M. Phillips},
    journal={CoRR},
    year={2018},
    volume={abs/1806.01330}
}

Install

pip install matrixor

or, after a git clone:

python3 setup.py install

Run

Align two models with Absolute Orientation + Scaling and return RMSE

To align two embeddings, run:

matrixor align \
  --matrix-1 /abs/path/to/xxx.vec.npy  \
  --matrix-2 /abs/path/to/yyy.vec.npy \

pass in the --average to return the averaged RMSE by aligning A and B then B and A (alignment may not be symmetric due to floating point average)