graphembed-rs 0.1.0__cp313-cp313-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
graphembed/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .graphembed import *
2
+
3
+ __doc__ = graphembed.__doc__
4
+ if hasattr(graphembed, "__all__"):
5
+ __all__ = graphembed.__all__
@@ -0,0 +1,79 @@
1
+ from typing import Optional
2
+
3
+ # ---------- Embedding ----------
4
+ def embed_hope_rank(
5
+ csv: str,
6
+ symetric: bool,
7
+ target_rank: int,
8
+ nbiter: int,
9
+ output: Optional[str] = None,
10
+ ) -> None: ...
11
+ def embed_hope_precision(
12
+ csv: str,
13
+ symetric: bool,
14
+ epsil: float,
15
+ maxrank: int,
16
+ blockiter: int,
17
+ output: Optional[str] = None,
18
+ ) -> None: ...
19
+ def embed_sketching(
20
+ csv: str,
21
+ symetric: bool,
22
+ decay: float,
23
+ dim: int,
24
+ nbiter: int,
25
+ output: Optional[str] = None,
26
+ ) -> None: ...
27
+
28
+ # ---------- Validation (returns mean AUC) ----------
29
+ def validate_hope_rank(
30
+ csv: str,
31
+ symetric: bool,
32
+ target_rank: int,
33
+ nbiter: int,
34
+ nbpass: int = 10,
35
+ skip_frac: float = 0.1,
36
+ centric: bool = False,
37
+ ) -> float: ...
38
+ def validate_hope_precision(
39
+ csv: str,
40
+ symetric: bool,
41
+ epsil: float,
42
+ maxrank: int,
43
+ blockiter: int,
44
+ nbpass: int = 10,
45
+ skip_frac: float = 0.1,
46
+ centric: bool = False,
47
+ ) -> float: ...
48
+ def validate_sketching(
49
+ csv: str,
50
+ symetric: bool,
51
+ decay: float,
52
+ dim: int,
53
+ nbiter: int,
54
+ nbpass: int = 10,
55
+ skip_frac: float = 0.1,
56
+ centric: bool = False,
57
+ ) -> float: ...
58
+
59
+ # ---------- VCMPR (precision/recall curves) ----------
60
+ def estimate_vcmpr_hope_rank(
61
+ csv: str,
62
+ symetric: bool,
63
+ target_rank: int,
64
+ nbiter: int,
65
+ nbpass: int = 2,
66
+ topk: int = 10,
67
+ skip_frac: float = 0.1,
68
+ ) -> None: ...
69
+ def estimate_vcmpr_sketching(
70
+ csv: str,
71
+ symetric: bool,
72
+ decay: float,
73
+ dim: int,
74
+ nbiter: int,
75
+ nbpass: int = 2,
76
+ topk: int = 10,
77
+ skip_frac: float = 0.1,
78
+ ) -> None: ...
79
+
graphembed/py.typed ADDED
File without changes
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.4
2
+ Name: graphembed_rs
3
+ Version: 0.1.0
4
+ Summary: Python bindings for the high‑performance Rust graph/network embedding library graphembed
5
+ Keywords: graph,embedding,hash
6
+ Author: Jianshu Zhao
7
+ Author-email: jeanpierre.both@gmail.com, jianshuzhao@yahoo.com
8
+ License: MIT OR Apache-2.0
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
11
+ Project-URL: Source Code, https://gitlab.com/Jianshu_Zhao/graphembed
12
+
13
+ [![install with bioconda](https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg?style=flat)](http://bioconda.github.io/recipes/graphembed/README.html)
14
+ ![](https://anaconda.org/bioconda/graphembed/badges/license.svg)
15
+ ![](https://anaconda.org/bioconda/graphembed/badges/version.svg)
16
+ ![](https://anaconda.org/bioconda/graphembed/badges/latest_release_relative_date.svg)
17
+ ![](https://anaconda.org/bioconda/graphembed/badges/platforms.svg)
18
+ [![install with conda](https://anaconda.org/bioconda/graphembed/badges/downloads.svg)](https://anaconda.org/bioconda/graphembed)
19
+
20
+
21
+ # GraphEmbed: Efficient and Robust Network Embedding via High-Order Proximity Preservation or Recursive Sketching
22
+
23
+ This crate provides an executable and a library for embedding of directed or undirected graphs with positively weighted edges. We engineered and optimized current network embedding algorithms for large-scale network embedding, especially biological network. This crate was developed by [Jianshu Zhao](https://gitlab.com/Jianshu_Zhao) and Jean-Pierre Both [jpboth](https://gitlab.com/jpboth).
24
+
25
+
26
+ - For simple graphs, without data attached to nodes, there are 2 modules **nodesketch** and **atp**. A simple executable with a validation option based on link prediction is also provided.
27
+
28
+ ## Quick Install
29
+
30
+ ### Pre-built binaries on Linux
31
+ ```bash
32
+ wget https://gitlab.com/-/project/64961144/uploads/ea72ca007e9e4899e0c830e708f52939/graphembed_Linux_x86-64_v0.1.4.zip
33
+ unzip graphembed_Linux_x86-64_v0.1.4.zip
34
+ chmod a+x ./graphembed
35
+ ./graphembed -h
36
+ ```
37
+
38
+ ### Bioconda on Linux
39
+ ```bash
40
+ conda install -c conda-forge -c bioconda graphembed
41
+ ```
42
+
43
+ ### Homebrew on MacOS
44
+ ```bash
45
+ brew tap jianshu93/graphembed
46
+ brew update
47
+ brew install graphembed
48
+
49
+ ```
50
+
51
+ ## Methods
52
+ ### The embedding algorithms used in this crate are based on the following papers
53
+
54
+ - **nodesketch**
55
+
56
+ *NodeSketch : Highly-Efficient Graph Embeddings via Recursive Sketching KDD 2019*. see [nodesketch](https://dl.acm.org/doi/10.1145/3292500.3330951)
57
+ D. Yang,P. Rosso,Bin-Li, P. Cudre-Mauroux.
58
+
59
+ It is based on multi hop neighbourhood identification via sensitive hashing based on the recent algorithm **probminhash**. See [arxiv](https://arxiv.org/abs/1911.00675) or [ieee-2022](https://ieeexplore.ieee.org/document/9185081).
60
+
61
+ The algorithm associates a probability distribution on neighbours of each point depending on edge weights and distance to the point.
62
+ Then this distribution is hashed to build a (discrete) embedding vector consisting in nodes identifiers.
63
+ The distance between embedded vectors is the Jaccard distance so we get
64
+ a real distance on the embedding space for the symetric embedding.
65
+
66
+ An extension of the paper is also implemented to get asymetric embedding for directed graph. The similarity is also based on the hash of sets (nodes going to or from) a given node but then the dissimilarity is no more a distance (no symetry and some discrepancy with the triangular inequality).
67
+
68
+ **The orkut graph with 3 millions nodes and 100 millions of edge is embedded in 5' with a 24 core i9 laptop with this algorithm giving an AUC of 0.95**.
69
+
70
+
71
+ - **atp**
72
+
73
+ *Asymetric Transitivity Preserving Graph Embedding 2016*.
74
+ M. Ou, P Cui, J. Pei, Z. Zhang and W. Zhu. See [hope](https://dl.acm.org/doi/10.1145/2939672.2939751).
75
+
76
+ The objective is to provide an asymetric graph embedding and get estimate of the precision of the embedding in function of its dimension.
77
+
78
+ We use the Adamic-Adar matricial representation of the graph. (It must be noted that the ponderation of a node by the number of couples joined by it is called Resource Allocation in the Graph Kernel litterature).
79
+ The asymetric embedding is obtained from the left and right singular eigenvectors of the Adamic-Adar representation of the graph.
80
+ Source node are related to left singular vectors and target nodes to the right ones.
81
+ The similarity measure is the dot product, so it is not a norm.
82
+ The svd is approximated by randomization as described in Halko-Tropp 2011 as implemented in the [annembed crate](https://crates.io/crates/annembed).
83
+
84
+ ## Validation
85
+
86
+ Validation of embeddings is assessed via standard Auc with random deletion of edges. See documentation in the *link* module and *embed* binary.
87
+ We give also a variation based on centric quality assessment as explained at [cauc](http://github.com/jean-pierreBoth/linkauc)
88
+ ## Some data sets
89
+
90
+ Small datasets are given in the Data subdirectory (with 7z compression) to run tests.
91
+ Larger datasets can be downloaded from the SNAP data collections <https://snap.stanford.edu/data>
92
+
93
+ #### Some small test graphs are provided in a Data subdirectory
94
+
95
+ - Symetric graphs
96
+
97
+ - Les miserables <http://konect.cc/networks/moreno_lesmis>.
98
+ This is the graph of co-occurence of characters in Victor Hugo's novel 'Les Misérables'.
99
+
100
+ - Asymetric graphs
101
+
102
+ - wiki-vote <https://snap.stanford.edu/data/wiki-Vote.html>
103
+ 7115 nodes 103689 edges
104
+
105
+ - Cora : <http://konect.cc/networks/subelj_cora>
106
+ citation network 23166 nodes 91500 edges
107
+
108
+ #### Some larger data tests for user to download
109
+
110
+ These graphs were used in results see below.
111
+
112
+ Beware of the possible need to convert from Windows to Linux End Of Line, see the dos2unix utility.
113
+ Possibly some data can need to be converted from Tsv format to Csv, before being read by the program.
114
+
115
+ - Symetric
116
+
117
+ - Amazon. Nodes: 334 863 Edges: 925 872 <https://snap.stanford.edu/data/amazon0601.html>
118
+ - youtube. Nodes: 1 134 890 Edges: 2 987 624 <https://snap.stanford.edu/data/com-Youtube.html>
119
+ - orkut. Nodes: 3 072 441 Edges: 117 185 083 <https://snap.stanford.edu/data/com-Orkut.html>
120
+
121
+ - Asymetric
122
+
123
+ - twitter as tested in Hope <http://konect.cc/networks/munmun_twitter_social>
124
+ 465017 nodes 834797 edges
125
+
126
+ ## Some results
127
+
128
+ ### results for the *atp* and *nodesketch* modules
129
+
130
+ Embedding and link prediction evaluation for the above data sets are given in file [resultats.md](./resultats.md)
131
+ A more global analysis of the embedding with the nodesketch module is done for the orkut graph in file [orkut.md](./orkut.md)
132
+
133
+ A preliminary of node centric quality estimation is provided in the validation module (see documentation in validation::link).
134
+
135
+ ### Some qualitative comments
136
+
137
+ - For the embedding using the randomized svd, increasing the embedding dimension is interesting as far as the corresponding eigenvalues continue to decrease significantly.
138
+
139
+ - The munmun_twitter_social graph shows that treating a directed graph as an undirected graph give significantly different results in terms of link prediction AUC.
140
+
141
+
142
+ ## Generalized Svd
143
+
144
+ An implementation of Generalized Svd comes as a by-product in module [gsvd](./src/atp/gsvd.rs).
145
+
146
+ ## Detailed Installation and Usage
147
+
148
+ ### Installation
149
+
150
+ The crate provides features (with a default configuration), required by the *annembed* dependency, to specify which version of lapack you want to use or the choice of simd implementation.
151
+ - For example compilation is done by :
152
+ *cargo build --release --features="openblas-system"* to use a dynamic link with openblas.
153
+ The choice of one feature is mandatory to provide required linear algebra library.
154
+ - On Intel the simdeez_f feature can be used. On other cpus the stdsimd feature can be chosen but it requires compiler >= 1.79
155
+
156
+ ### Usage
157
+
158
+ The embed module can be generated with the standard : cargo doc --no-deps --bin embed.
159
+
160
+ - The Hope embedding relying on matrices computations limits the size of the graph to some hundred thousands nodes.
161
+ It is intrinsically asymetric in nature. It nevertheless gives access to the spectrum of Adamic Adar matrix representing the graph and
162
+ so to the required dimension to get a valid embedding in $R^{n}$.
163
+
164
+ - The Sketching embedding is much faster for large graphs but embeds in a space consisting in sequences of node id equipped with the Jaccard distance. It is particularly efficient in low degrees graph.
165
+
166
+ - The *embed* module takes embedding and possibly validation commands (link prediction task) in one directive.
167
+ The general syntax is :
168
+
169
+ graphembed file_description [validation_command --validation_arguments] sketching mode --embedding_arguments
170
+ for example:
171
+
172
+ For a symetric graph we get:
173
+
174
+ - just embedding:
175
+ graphembed --csv ./Data/Graphs/Orkut/com-orkut.ungraph.txt --symetric sketching --decay 0.2 --dim 200 --nbiter
176
+
177
+ - embedding and validation:
178
+
179
+ graphembed --csv ./Data/Graphs/Orkut/com-orkut.ungraph.txt --symetric validation --nbpass 5 --skip 0.15 sketching --decay 0.2 --dim 200 --nbiter 5
180
+
181
+ For an asymetric graph we get
182
+
183
+ graphembed --csv ./Data/Graphs/asymetric.csv validation --nbpass 5 --skip 0.15 sketching --decay 0.2 --dim 200 --nbiter 5
184
+
185
+
186
+ More details can be found in docs of the embed module. Use cargo doc --no-dep --bin embed (and cargo doc --no-dep) as usual.
187
+
188
+ - Use the environment variable RUST_LOG gives access to some information at various level (debug, info, error) via the **log** and **env_logger** crates.
189
+
190
+ ## License
191
+
192
+ Licensed under either of
193
+
194
+ * Apache License, Version 2.0, [LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>
195
+ * MIT license [LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>
196
+
197
+ at your option.
198
+
@@ -0,0 +1,7 @@
1
+ graphembed_rs-0.1.0.dist-info/METADATA,sha256=dxYkTamZDsIFcEqterZ0LEeXQDItlSW2aZjmL6u1vuI,9694
2
+ graphembed_rs-0.1.0.dist-info/WHEEL,sha256=_czbP61TsBkf9T201RekHMHlqESnWn7yJwXBJC9P-w0,104
3
+ graphembed/__init__.py,sha256=RCcLraveWf-myTsDQGePMYq-scNNfz-3Mv1baSbgAmM,123
4
+ graphembed/__init__.pyi,sha256=3_KBFG4g9akylo32CHlm9bZStcLwxIY2X4si21ilD3w,1626
5
+ graphembed/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ graphembed/graphembed.cpython-313-darwin.so,sha256=6MnpRaFtxd9VQ4aK_yHbA-C9eqiVELPJGAIs6KJwt8I,5126848
7
+ graphembed_rs-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.8.3)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-macosx_11_0_arm64