This release is a pre-release and may not be stable for production use.
Emgraph
Emgraph is a Python toolkit for graph embedding.
| Number | Algorithm |
| 1 | TransE |
| 2 | ComplEx |
| 3 | HolE |
| 4 | DistMult |
| 5 | ConvE |
| 6 | ConvKB |
| 7 | RandomBaseline |
Installation
Install the latest version of Emgraph:
$ pip install emgraph
Documentation
Soon
Simple example
Embedding wordnet11 graph using
TransE model:
from sklearn.metrics import brier_score_loss, log_loss
from scipy.special import expit
from emgraph.datasets import BaseDataset, DatasetType
from emgraph.models import TransE
def train_transe():
X = BaseDataset.load_dataset(DatasetType.WN11)
model = TransE(batches_count=64, seed=0, epochs=20, k=100, eta=20,
optimizer='adam', optimizer_params={'lr': 0.0001},
loss='pairwise', verbose=True, large_graphs=False)
model.fit(X['train'])
scores = model.predict(X['test'])
print("Scores: ", scores)
print("Brier score loss:", brier_score_loss(X['test_labels'], expit(scores)))
# Executing the function
if __name__ == '__main__':
train_transe()
Evaluating ComplEx model after training:
import numpy as np
from emgraph.datasets import BaseDataset, DatasetType
from emgraph.models import ComplEx
from emgraph.evaluation import evaluate_performance
def complex_performance():
X = BaseDataset.load_dataset(DatasetType.WN18)
model = ComplEx(batches_count=10, seed=0, epochs=20, k=150, eta=1,
loss='nll', optimizer='adam')
model.fit(np.concatenate((X['train'], X['valid'])))
filter_triples = np.concatenate((X['train'], X['valid'], X['test']))
ranks = evaluate_performance(X['test'][:5], model=model,
filter_triples=filter_triples,
corrupt_side='s+o',
use_default_protocol=False)
return ranks
# Executing the function
if __name__ == '__main__':
ranks = complex_performance()
print("ranks {}".format(ranks))
Call for Contributions
The Emgraph project welcomes your expertise and enthusiasm!
Ways to contribute to Emgraph:
- Writing code
- Review pull requests
- Develop tutorials, presentations, and other educational materials
- Translate documentation and readme contents
Issues
If you happened to encounter any issue in the codes, please report it here. A better way is to fork the repository on Github and/or create a pull request.
More examples
Embedding wordnet11 graph using
DistMult model:
from sklearn.metrics import brier_score_loss, log_loss
from scipy.special import expit
from emgraph.datasets import BaseDataset, DatasetType
from emgraph.models import DistMult
def train_dist_mult():
X = BaseDataset.load_dataset(DatasetType.WN11)
model = DistMult(batches_count=1, seed=555, epochs=20, k=10, loss='pairwise',
loss_params={'margin': 5})
model.fit(X['train'])
scores = model.predict(X['test'])
print("Scores: ", scores)
print("Brier score loss:", brier_score_loss(X['test_labels'], expit(scores)))
# Executing the function
if __name__ == '__main__':
train_dist_mult()
Future work
- Modulate the functions
- Add more algorithms
- Run on CUDA cores
- Make it faster using vectorization etc.
- Add more preprocessors
- Add dataset, graph, and dataframe manipulations
- Unify and reconstruct the architecture and eliminate redundancy
If you found it helpful, please give us a :star:
License
Released under the BSD license
Metadata
Release files for emgraph 1.0.0rc1
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 |
|---|---|---|---|---|
| emgraph-1.0.0rc1.tar.gz | 122.0 kB | Without provenance | Details for emgraph-1.0.0rc1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| emgraph-1.0.0rc1-py3-none-any.whl | Python 3 | none | any | Details for emgraph-1.0.0rc1-py3-none-any.whl |
Total release size: 279.2 kB
Release files / emgraph-1.0.0rc1.tar.gz
| Download URL | emgraph-1.0.0rc1.tar.gz |
|---|---|
| Size | 122.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df91d3c1958e88a3c65e286ba433dfec5200fdaa131d4a804117b937b469c0aa
|
|
BLAKE2b-256 checksum How to use checksums |
f447658b77a018b506aab44dca94b6101d47a4e26d0d8c2be52d781f2102d146
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.3 Linux/5.15.0-43-generic
|
Release files / emgraph-1.0.0rc1-py3-none-any.whl
| Download URL | emgraph-1.0.0rc1-py3-none-any.whl |
|---|---|
| Size | 157.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd5e7ade7d1e12e18f886ff9e9501e3ba9b215aca2fdda41757c70164f3e9441
|
|
BLAKE2b-256 checksum How to use checksums |
61a8d94dbe956d227f219dd107cd95f05a737bbd3ccd3fcf4a944a792af79673
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.3 Linux/5.15.0-43-generic
|
Security for emgraph 1.0.0rc1
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.