vec2graph
Mini-library for producing graph visualizations from embedding models
Code is available at https://github.com/lizaku/vec2graph
Usage
pip install vec2graph
from vec2graph import visualize
visualize(OUTPUT_DIR, MODEL, WORD, depth=0, topn=10, threshold=0, edge=1, sep=False, library="web")
Example
model = gensim.models.KeyedVectors.load_word2vec_format('googlenews300.bin', binary=True)
visualize('tmp/graphs', model, 'apple')
Required arguments
- OUTPUT_DIR is the directory to store your visualizations
- MODEL is a word embedding model loaded with Gensim
- WORD is your query (single word or list of the words:
['apple', 'pear']). If in the model PoS-tag is attached to the word, it shoul be written explicitly:'apple_NOUN'
Optional arguments
- depth: integer, default 0
depth to which the algorithm has to drill down into the relations of semantic neighbours (the higher this number is, the deeper the recursion, which means that it produces visualizations for the neighbours of the neighbours of the query word). - topn: integer, default 10
the number of neighbors to extract for each word - threshold: float, default 0
the value from which we start drawing edges between nodes. By default the fully connected graph is produced. - edge: integer, default 1
the width of edges in the graph - sep: bool, default False
if this parameter is used, token is split by a separator (underscore), and only first part is shown in visualization (E.g. it is useful when PoS is attached to a word -'apple_NOUN'). - library: str, default 'web'
the path to D3.js library, can be 'web' (link to version at the D3.js site) or 'local' (file in the directory with generated HTML, if not present, it is downloaded from web).
Metadata
Release files for vec2graph 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vec2graph-0.3.0.tar.gz | 5.7 kB | Without provenance | Details for vec2graph-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vec2graph-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for vec2graph-0.3.0-py3-none-any.whl |
Total release size: 14.2 kB
Release files / vec2graph-0.3.0.tar.gz
| Download URL | vec2graph-0.3.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c1c702a20da5cf3c2d38eacaadd1400ea81dbd0ccdefeaf7a785b07e1f6e6af
|
|
BLAKE2b-256 checksum How to use checksums |
ad822a4adecca8cb2075fc7aa584357ad6eb79bde3e4d81b56935113e15d35a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.8
|
Release files / vec2graph-0.3.0-py3-none-any.whl
| Download URL | vec2graph-0.3.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16dab170deb8d891c31fee94c0961ea047c3972f0e758d17dca9a3b79e918428
|
|
BLAKE2b-256 checksum How to use checksums |
25bf45db06130554f4b35478c5989be745fa251114ba280cac04ba3ee0932396
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.8
|
Security for vec2graph 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.