GithubHelp home page GithubHelp logo

aligned_word_embeddings's Introduction

Aligned Word Embeddings

Documentation Status

Installing

  • Clone the repository
  • virtualenv -p python3.6 env
  • source env/bin/activate
  • pip install cython
  • pip install git+https://github.com/valedica/gensim.git
  • cd in repository
  • pip install -e .

Note

  • Remember: when you call the AlignedWordEmbeddings the script creates a "model/" folder

How To Use

  • Train
from aligned_word_embeddings.aligned_word_embeddings import  AlignedWordEmbeddings
from aligned_word_embeddings.spatial.distances import most_similar_from_model
from gensim.models.word2vec import Word2Vec

aligner = AlignedWordEmbeddings(size=30, siter=10, diter=10, workers=4)

aligner.train_compass("/path/to/compass_text", overwrite=False) # keep an eye on the overwrite behaviour

slice_one = aligner.train_slice("/path/to/slice_one.txt", save=True)
slice_two = aligner.train_slice("/path/to/slice_two.txt", save=True)

print(most_similar_from_model("flat", silce_one, slice_two))

slice_one = Word2Vec.load("model/slice_one.model") # model loading with gensim
slice_two = Word2Vec.load("model/slice_one.model")
  • Load and Visualize
from aligned_word_embeddings.utils.visualization import visualize_embeddings

model1 = Word2Vec.load("slice_one.model")
model2 = Word2Vec.load("slice_two.model")

import numpy as np
models = [model1, model2]

names = ["slice_one", "slice_two"]

key = "word"

visualize_embeddings(key, models, names, topn=2)
  • Moral Embeddings

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

aligned_word_embeddings's People

Contributors

vinid avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.