sknetwork-team / scikit-network Goto Github PK
View Code? Open in Web Editor NEWGraph Algorithms
License: Other
Graph Algorithms
License: Other
When I fit a LouvainHierarchy
and then try to get a clustering with e.g. 50 clusters (cut_straight(dendrogram, n_clusters=50)
), I am getting 81 clusters instead. Paris() works perfectly fine on the same dataset. See reproducible example below.
import numpy as np
import scanpy as sc # required for the dataset, pip install scanpy
from sknetwork.hierarchy import LouvainHierarchy, cut_straight
ad = sc.datasets.paul15()
sc.pp.log1p(ad)
adjacency = np.corrcoef(ad.X, rowvar=False)
adjacency[adjacency<0] = 0
louvain_hierarchy = LouvainHierarchy()
dendrogram = louvain_hierarchy.fit_transform(adjacency)
n_clusters = 50
labels = cut_straight(dendrogram, n_clusters=n_clusters)
n_clusters_observed = len(np.unique(labels))
assert n_clusters_observed == n_clusters, f'{n_clusters} clusters requested but {n_clusters_observed} clusters returned'
Output:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-12-a465df4cc71e> in <module>
15 n_clusters_observed = len(np.unique(labels))
16
---> 17 assert n_clusters_observed == n_clusters, f'{n_clusters} clusters requested but {n_clusters_observed} clusters returned'
AssertionError: 50 clusters requested but 81 clusters returned
Hello,
I am a beginner in the analysis of large graphs. It's glad to be able to find such an excellent package. Thanks for your contributions!
Now I am learning Bilouvain algorithm. Is the code about Bilouvain developed based on the paper "Efficient Detection of Communities in Biological Bipartite Networks"? Or another paper?
Look forward to your reply!
I generated a bipartite graph using the svg_bigraph function and the output is really difficult to see as all the nodes are squished together. I tried changing several parameters including width, height, scale, and margin but nothing spaced the nodes out better.
I took the star_wars demo dataset and ran it through the bi-louvain soft clustering example. I decided to print out what values we're getting for the clusters as well to see how they matched up.
While things seem fine in the image when you compare the values of the scores:
[('Jabba', 0.5), ('Greedo', 1.0), ('Vador', 0.3333333333333333), ('Boba', 0.0)]
[('A New Hope', 0.6666666666666666), ('The Empire Strikes Back', 0.0), ('Return Of The Jedi', 0.3333333333333333)]
You can see that Vader and RoTJ had the same score but different colors. I've looked for an explanation of what your soft clustering scores are based on to figure out what that could mean but it seems like it just used the max and min values for rows and columns respectively to color the rows/columns on a spectrum for each.
I decided to try the bi-louvain demo using the Star Wars dataset.
graph = star_wars(metadata=True)
names_row = graph.names_row
names_col = graph.names_col
biadjacency = graph.biadjacency
bilouvain = BiLouvain()
bilouvain.fit(biadjacency)
labels_row = bilouvain.labels_row_
labels_col = bilouvain.labels_col_
image = svg_bigraph(biadjacency, names_row, names_col, labels_row, labels_col)
scores_row = bilouvain.membership_row_[:,1].toarray().ravel()
scores_col = bilouvain.membership_col_[:,1].toarray().ravel()
image = svg_bigraph(biadjacency, names_row, names_col, scores_row=scores_row, scores_col=scores_col)
with open("tmp.svg", "w") as text_file:
print(image, file=text_file)
print(list(zip(names_row,scores_row)),list(zip(names_col,scores_col)))
P.S.: Not sure if Vader --> Vador was deliberate change to french spelling or a typo.
There is a ModuleNotFoundError: No module named 'sknetwork.utils.knn1d'
after a fresh install.
On a fresh install, after running:
pip install -r requirements_dev.txt
python setup.py install
On import I get:
In [2]: import sknetwork
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-67de0695dc56> in <module>()
----> 1 import sknetwork
~/Documents/scikit-network/sknetwork/__init__.py in <module>()
8
9 import sknetwork.connectivity
---> 10 import sknetwork.classification
11 import sknetwork.clustering
12 import sknetwork.embedding
~/Documents/scikit-network/sknetwork/classification/__init__.py in <module>()
1 """classification module"""
2 from sknetwork.classification.base import BaseClassifier, BaseBiClassifier
----> 3 from sknetwork.classification.knn import KNN, BiKNN
4 from sknetwork.classification.pagerank import BiPageRankClassifier, PageRankClassifier, CoPageRankClassifier
5 from sknetwork.classification.diffusion import BiDiffusionClassifier, DiffusionClassifier
~/Documents/scikit-network/sknetwork/classification/knn.py in <module>()
16 from sknetwork.linalg.normalization import normalize
17 from sknetwork.utils.check import check_seeds, check_n_neighbors, check_n_jobs
---> 18 from sknetwork.utils.seeds import stack_seeds
19
20
~/Documents/scikit-network/sknetwork/utils/__init__.py in <module>()
1 """utils module"""
----> 2 from sknetwork.utils.co_neighbors import co_neighbors_graph
3 from sknetwork.utils.format import *
4 from sknetwork.utils.kmeans import KMeansDense
5 from sknetwork.utils.knn import KNNDense, PNNDense
~/Documents/scikit-network/sknetwork/utils/co_neighbors.py in <module>()
14 from sknetwork.linalg.normalization import normalize
15 from sknetwork.utils.check import check_format
---> 16 from sknetwork.utils.knn import KNNDense
17
18
~/Documents/scikit-network/sknetwork/utils/knn.py in <module>()
11 from scipy.spatial import cKDTree
12
---> 13 from sknetwork.utils.knn1d import knn1d
14 from sknetwork.utils.format import directed2undirected
15 from sknetwork.utils.base import Algorithm
ModuleNotFoundError: No module named 'sknetwork.utils.knn1d'
If I follow the contributor guidelines instead (so running python setup.py develop
instead of install
) there are no issues.
Thanks for your work ! :)
When runing the comand erdos_renyi(5, 1.0)
I would expect to receive a graph with exactly 10 edges. However, runing it 1'000 times I get on average 7.44 edges.
With other graph libraries this works fine. For example networkx.generators.random_graphs.erdos_renyi_graph(5, 1.0)
produces the desired result.
The issue does not depend on this exact combination of numbers.
Further I do not expect erdos_renyi(5, 1.5)
to produce any sensible result (since p > 1), but not only does this work the result differs (on average) from what you get from erdos_renyi(5, 1.0)
. This indicates that a probability larger than 1 makes any sense and is different than a probability of exactly 1.
I run this comparison between networx and scikit-network. However the networkx parts are not needed to reproduce the wrong results.
from networkx.generators.random_graphs import erdos_renyi_graph
import networkx as nx
import numpy as np
from sknetwork.data import erdos_renyi
def experiment_1(n = 5, p = 1.0, i = 1000):
nx_sum = 0
scikit_sum = 0
for i in range(i):
nx_edges = np.count_nonzero(nx.to_numpy_array(erdos_renyi_graph(n, p)))//2
scikit_edges = np.count_nonzero(erdos_renyi(n,p).toarray())//2
nx_sum += nx_edges
scikit_sum += scikit_edges
print(f"nx avg = {nx_sum/i:9.4f}")
print(f"scikit avg = {scikit_sum/i:9.4f}")
print(f"expected avg = {(n*(n-1))//2*min(p,1)}")
0.24
3.8.1
Ubuntu 20.04
I think the way sknetwork
computes the tree-sampling divergence (TSD) is not correct. There seems to be an issue in the way that the node sampling distribution (q(z)
in the paper) is computed. Specifically, this this line increases the q(z)
score by p(i) * p(j)
effectively (ignoring directionality). However, we also need to take into account p(i)*p(i)
and p(j)*p(j)
. Otherwise, the node sampling distribution does not add up to one.
This is also consistent with the equation in the TSD paper (p. 2069 top left):
Here, the summation does not specify that u≠v
, i.e. we should also take into account the "diagonal" entries where u=v
.
In the code, I think we could achieve this by first "initializing" the node sampling distribution by adding p(u)*p(u)
to each leaf node u
's direct parent in the tree.
After fresh install of version 0.24.0, I get ImportError: Symbol not found: ____chkstk_darwin
error when importing scikit-network package.
I installed scikit-network's latest version using pip
:
pip install scikit-network
On import I get the following error:
File "myFile.py", line 2, in <module>
import sknetwork
File "~/opt/anaconda3/envs/graphEmbedEnv/lib/python3.7/site-packages/sknetwork/__init__.py", line 9, in <module>
import sknetwork.topology
File "~/opt/anaconda3/envs/graphEmbedEnv/lib/python3.7/site-packages/sknetwork/topology/__init__.py", line 2, in <module>
from sknetwork.topology.kcliques import Cliques
ImportError: dlopen(~/opt/anaconda3/envs/graphEmbedEnv/lib/python3.7/site-packages/sknetwork/topology/kcliques.cpython-37m-darwin.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: ~/opt/anaconda3/envs/graphEmbedEnv/lib/python3.7/site-packages/sknetwork/topology/../.dylibs/libomp.dylib (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib
in ~/opt/anaconda3/envs/graphEmbedEnv/lib/python3.7/site-packages/sknetwork/topology/../.dylibs/libomp.dylib
Following previous issues resolution, I tried to install the package following contributor guideline (python setup.py develop
), which was a success.
Thanks very much !
Thanks for this great library! I'm trying to run clustering.Louvain
on graphs with billions of edges (1 to 15 billion) and few millions of nodes (~5 million). The algorithm runs fine with 1,5 billion rows, but with more than that it fails without a traceback and exit code SIGSEV. Since max int is 2147483647, I believe the problem is louvain.py
uses np.int32
in multiple places and louvain_core.pyx
uses int
s instead of long
s.
My question is: is it fine to open a PR increasing Louvain to deal with 64-bit integers? Or even leveraging from "fused types" and support both versions (see: https://stackoverflow.com/questions/28112599/writing-cython-for-both-32-bit-and-64-bit)?
Hi all, thanks for this repo which has proven really useful.
The PARIS clustering algorithm publication discusses probabilistic similarity between nodes, but is the clustering itself also probabilistic. is it guaranteed to produce the same clustering for a given network?
Thanks!
First I installed sknetwork using pip install sknetwork. Installation works well. Then when I import sknetwork I get ModuleNotFoundError: No module named 'sknetwork.topology.kcliques'
After trying different things I gave up. Uninstalled with pip and decided to compile from source.
git clone https://github.com/sknetwork-team/scikit-network.git
python -m pip install scikit-network/
Processing ./scikit-network
Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy>=1.21.5 in /clusterfs/.pyenv/versions/3.9.6/envs/proptech_env/lib/python3.9/site-packages (from scikit-network==0.26.0) (1.22.2)
Requirement already satisfied: scipy>=1.6.3 in /clusterfs/.pyenv/versions/3.9.6/envs/proptech_env/lib/python3.9/site-packages (from scikit-network==0.26.0) (1.8.0)
Building wheels for collected packages: scikit-network
Building wheel for scikit-network (setup.py) ... error
error: subprocess-exited-with-error
python setup.py bdist_wheel did not run successfully.
exit code: 1
[26 lines of output]
running bdist_wheel
running build
running build_py
running egg_info
writing scikit_network.egg-info/PKG-INFO
writing dependency_links to scikit_network.egg-info/dependency_links.txt
writing entry points to scikit_network.egg-info/entry_points.txt
writing requirements to scikit_network.egg-info/requires.txt
writing top-level names to scikit_network.egg-info/top_level.txt
adding license file 'LICENSE' (matched pattern 'LICEN[CS]E*')
adding license file 'AUTHORS.rst' (matched pattern 'AUTHORS*')
reading manifest file 'scikit_network.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
warning: no files found matching '*.jpg' under directory 'docs'
warning: no files found matching '*.png' under directory 'docs'
warning: no files found matching '*.gif' under directory 'docs'
writing manifest file 'scikit_network.egg-info/SOURCES.txt'
running build_ext
building 'sknetwork.topology.triangles' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/clusterfs/.pyenv/versions/proptech_env/lib/python3.9/site-packages/numpy/core/include -I/clusterfs/.pyenv/versions/proptech_env/lib/python3.9/site-packages/numpy/core/include -I/clusterfs/.pyenv/versions/proptech_env/include -I/clusterfs/.pyenv/versions/3.9.6/include/python3.9 -I/clusterfs/.pyenv/versions/proptech_env/lib/python3.9/site-packages/numpy/core/include -c ./sknetwork/topology/triangles.cpp -o build/temp.linux-aarch64-3.9/./sknetwork/topology/triangles.o
gcc: error: ./sknetwork/topology/triangles.cpp: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for scikit-network
Running setup.py clean for scikit-network
Failed to build scikit-network
Installing collected packages: scikit-network
Running setup.py install for scikit-network ... error
error: subprocess-exited-with-error
Running setup.py install for scikit-network did not run successfully.
exit code: 1
[230 lines of output]
running install
running build
running build_py
creating build
creating build/lib.linux-aarch64-3.9
creating build/lib.linux-aarch64-3.9/sknetwork
copying sknetwork/sknetwork.py -> build/lib.linux-aarch64-3.9/sknetwork
copying sknetwork/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork
creating build/lib.linux-aarch64-3.9/sknetwork/topology
copying sknetwork/topology/weisfeiler_lehman.py -> build/lib.linux-aarch64-3.9/sknetwork/topology
copying sknetwork/topology/structure.py -> build/lib.linux-aarch64-3.9/sknetwork/topology
copying sknetwork/topology/dag.py -> build/lib.linux-aarch64-3.9/sknetwork/topology
copying sknetwork/topology/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/topology
creating build/lib.linux-aarch64-3.9/sknetwork/embedding
copying sknetwork/embedding/spring.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding
copying sknetwork/embedding/metrics.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding
copying sknetwork/embedding/louvain_embedding.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding
copying sknetwork/embedding/base.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding
copying sknetwork/embedding/spectral.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding
copying sknetwork/embedding/random_projection.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding
copying sknetwork/embedding/svd.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding
copying sknetwork/embedding/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding
copying sknetwork/embedding/force_atlas.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding
copying sknetwork/embedding/louvain_hierarchy.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding
creating build/lib.linux-aarch64-3.9/sknetwork/linalg
copying sknetwork/linalg/operators.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg
copying sknetwork/linalg/sparse_lowrank.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg
copying sknetwork/linalg/eig_solver.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg
copying sknetwork/linalg/polynome.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg
copying sknetwork/linalg/basics.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg
copying sknetwork/linalg/ppr_solver.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg
copying sknetwork/linalg/svd_solver.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg
copying sknetwork/linalg/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg
copying sknetwork/linalg/normalization.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg
creating build/lib.linux-aarch64-3.9/sknetwork/regression
copying sknetwork/regression/base.py -> build/lib.linux-aarch64-3.9/sknetwork/regression
copying sknetwork/regression/diffusion.py -> build/lib.linux-aarch64-3.9/sknetwork/regression
copying sknetwork/regression/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/regression
creating build/lib.linux-aarch64-3.9/sknetwork/data
copying sknetwork/data/toy_graphs.py -> build/lib.linux-aarch64-3.9/sknetwork/data
copying sknetwork/data/load.py -> build/lib.linux-aarch64-3.9/sknetwork/data
copying sknetwork/data/test_graphs.py -> build/lib.linux-aarch64-3.9/sknetwork/data
copying sknetwork/data/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/data
copying sknetwork/data/parse.py -> build/lib.linux-aarch64-3.9/sknetwork/data
copying sknetwork/data/models.py -> build/lib.linux-aarch64-3.9/sknetwork/data
creating build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/check.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/timeout.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/verbose.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/ward.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/base.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/membership.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/co_neighbor.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/neighbors.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/knn.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/simplex.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/format.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/seeds.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
copying sknetwork/utils/kmeans.py -> build/lib.linux-aarch64-3.9/sknetwork/utils
creating build/lib.linux-aarch64-3.9/sknetwork/hierarchy
copying sknetwork/hierarchy/ward.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy
copying sknetwork/hierarchy/metrics.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy
copying sknetwork/hierarchy/base.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy
copying sknetwork/hierarchy/postprocess.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy
copying sknetwork/hierarchy/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy
copying sknetwork/hierarchy/louvain_hierarchy.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy
creating build/lib.linux-aarch64-3.9/sknetwork/visualization
copying sknetwork/visualization/graphs.py -> build/lib.linux-aarch64-3.9/sknetwork/visualization
copying sknetwork/visualization/colors.py -> build/lib.linux-aarch64-3.9/sknetwork/visualization
copying sknetwork/visualization/dendrograms.py -> build/lib.linux-aarch64-3.9/sknetwork/visualization
copying sknetwork/visualization/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/visualization
creating build/lib.linux-aarch64-3.9/sknetwork/classification
copying sknetwork/classification/base_rank.py -> build/lib.linux-aarch64-3.9/sknetwork/classification
copying sknetwork/classification/metrics.py -> build/lib.linux-aarch64-3.9/sknetwork/classification
copying sknetwork/classification/base.py -> build/lib.linux-aarch64-3.9/sknetwork/classification
copying sknetwork/classification/diffusion.py -> build/lib.linux-aarch64-3.9/sknetwork/classification
copying sknetwork/classification/pagerank.py -> build/lib.linux-aarch64-3.9/sknetwork/classification
copying sknetwork/classification/knn.py -> build/lib.linux-aarch64-3.9/sknetwork/classification
copying sknetwork/classification/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/classification
copying sknetwork/classification/propagation.py -> build/lib.linux-aarch64-3.9/sknetwork/classification
creating build/lib.linux-aarch64-3.9/sknetwork/linkpred
copying sknetwork/linkpred/base.py -> build/lib.linux-aarch64-3.9/sknetwork/linkpred
copying sknetwork/linkpred/first_order.py -> build/lib.linux-aarch64-3.9/sknetwork/linkpred
copying sknetwork/linkpred/postprocessing.py -> build/lib.linux-aarch64-3.9/sknetwork/linkpred
copying sknetwork/linkpred/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/linkpred
creating build/lib.linux-aarch64-3.9/sknetwork/path
copying sknetwork/path/search.py -> build/lib.linux-aarch64-3.9/sknetwork/path
copying sknetwork/path/metrics.py -> build/lib.linux-aarch64-3.9/sknetwork/path
copying sknetwork/path/shortest_path.py -> build/lib.linux-aarch64-3.9/sknetwork/path
copying sknetwork/path/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/path
creating build/lib.linux-aarch64-3.9/sknetwork/ranking
copying sknetwork/ranking/base.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking
copying sknetwork/ranking/pagerank.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking
copying sknetwork/ranking/postprocess.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking
copying sknetwork/ranking/hits.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking
copying sknetwork/ranking/katz.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking
copying sknetwork/ranking/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking
copying sknetwork/ranking/closeness.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking
copying sknetwork/ranking/harmonic.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking
creating build/lib.linux-aarch64-3.9/sknetwork/clustering
copying sknetwork/clustering/metrics.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering
copying sknetwork/clustering/base.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering
copying sknetwork/clustering/postprocess.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering
copying sknetwork/clustering/louvain.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering
copying sknetwork/clustering/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering
copying sknetwork/clustering/propagation_clustering.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering
copying sknetwork/clustering/kmeans.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering
creating build/lib.linux-aarch64-3.9/sknetwork/topology/tests
copying sknetwork/topology/tests/test_triangles.py -> build/lib.linux-aarch64-3.9/sknetwork/topology/tests
copying sknetwork/topology/tests/test_cliques.py -> build/lib.linux-aarch64-3.9/sknetwork/topology/tests
copying sknetwork/topology/tests/test_wl_kernel.py -> build/lib.linux-aarch64-3.9/sknetwork/topology/tests
copying sknetwork/topology/tests/test_wl_coloring.py -> build/lib.linux-aarch64-3.9/sknetwork/topology/tests
copying sknetwork/topology/tests/test_dag.py -> build/lib.linux-aarch64-3.9/sknetwork/topology/tests
copying sknetwork/topology/tests/test_structure.py -> build/lib.linux-aarch64-3.9/sknetwork/topology/tests
copying sknetwork/topology/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/topology/tests
copying sknetwork/topology/tests/test_cores.py -> build/lib.linux-aarch64-3.9/sknetwork/topology/tests
creating build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
copying sknetwork/embedding/tests/test_spring.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
copying sknetwork/embedding/tests/test_force_atlas.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
copying sknetwork/embedding/tests/test_random_projection.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
copying sknetwork/embedding/tests/test_API.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
copying sknetwork/embedding/tests/test_louvain_embedding.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
copying sknetwork/embedding/tests/test_louvain_hierarchy.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
copying sknetwork/embedding/tests/test_spectral.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
copying sknetwork/embedding/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
copying sknetwork/embedding/tests/test_metrics.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
copying sknetwork/embedding/tests/test_svd.py -> build/lib.linux-aarch64-3.9/sknetwork/embedding/tests
creating build/lib.linux-aarch64-3.9/sknetwork/linalg/tests
copying sknetwork/linalg/tests/test_eig.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg/tests
copying sknetwork/linalg/tests/test_operators.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg/tests
copying sknetwork/linalg/tests/test_sparse_lowrank.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg/tests
copying sknetwork/linalg/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg/tests
copying sknetwork/linalg/tests/test_normalization.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg/tests
copying sknetwork/linalg/tests/test_polynome.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg/tests
copying sknetwork/linalg/tests/test_svd.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg/tests
copying sknetwork/linalg/tests/test_ppr.py -> build/lib.linux-aarch64-3.9/sknetwork/linalg/tests
creating build/lib.linux-aarch64-3.9/sknetwork/regression/tests
copying sknetwork/regression/tests/test_diffusion.py -> build/lib.linux-aarch64-3.9/sknetwork/regression/tests
copying sknetwork/regression/tests/test_API.py -> build/lib.linux-aarch64-3.9/sknetwork/regression/tests
copying sknetwork/regression/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/regression/tests
creating build/lib.linux-aarch64-3.9/sknetwork/data/tests
copying sknetwork/data/tests/test_parse.py -> build/lib.linux-aarch64-3.9/sknetwork/data/tests
copying sknetwork/data/tests/test_test_graphs.py -> build/lib.linux-aarch64-3.9/sknetwork/data/tests
copying sknetwork/data/tests/test_API.py -> build/lib.linux-aarch64-3.9/sknetwork/data/tests
copying sknetwork/data/tests/test_load.py -> build/lib.linux-aarch64-3.9/sknetwork/data/tests
copying sknetwork/data/tests/test_models.py -> build/lib.linux-aarch64-3.9/sknetwork/data/tests
copying sknetwork/data/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/data/tests
copying sknetwork/data/tests/test_toy_graphs.py -> build/lib.linux-aarch64-3.9/sknetwork/data/tests
creating build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_kmeans.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_base.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_seeds.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_ward.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_check.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_neighbors.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_projection_simplex.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_format.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_verbose.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_co_neighbor.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_bunch.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
copying sknetwork/utils/tests/test_knn.py -> build/lib.linux-aarch64-3.9/sknetwork/utils/tests
creating build/lib.linux-aarch64-3.9/sknetwork/hierarchy/tests
copying sknetwork/hierarchy/tests/test_ward.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy/tests
copying sknetwork/hierarchy/tests/test_algos.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy/tests
copying sknetwork/hierarchy/tests/test_API.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy/tests
copying sknetwork/hierarchy/tests/test_postprocess.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy/tests
copying sknetwork/hierarchy/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy/tests
copying sknetwork/hierarchy/tests/test_metrics.py -> build/lib.linux-aarch64-3.9/sknetwork/hierarchy/tests
creating build/lib.linux-aarch64-3.9/sknetwork/visualization/tests
copying sknetwork/visualization/tests/test_dendrograms.py -> build/lib.linux-aarch64-3.9/sknetwork/visualization/tests
copying sknetwork/visualization/tests/test_graphs.py -> build/lib.linux-aarch64-3.9/sknetwork/visualization/tests
copying sknetwork/visualization/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/visualization/tests
creating build/lib.linux-aarch64-3.9/sknetwork/classification/tests
copying sknetwork/classification/tests/test_diffusion.py -> build/lib.linux-aarch64-3.9/sknetwork/classification/tests
copying sknetwork/classification/tests/test_propagation.py -> build/lib.linux-aarch64-3.9/sknetwork/classification/tests
copying sknetwork/classification/tests/test_API.py -> build/lib.linux-aarch64-3.9/sknetwork/classification/tests
copying sknetwork/classification/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/classification/tests
copying sknetwork/classification/tests/test_knn.py -> build/lib.linux-aarch64-3.9/sknetwork/classification/tests
copying sknetwork/classification/tests/test_pagerank.py -> build/lib.linux-aarch64-3.9/sknetwork/classification/tests
creating build/lib.linux-aarch64-3.9/sknetwork/linkpred/tests
copying sknetwork/linkpred/tests/test_API.py -> build/lib.linux-aarch64-3.9/sknetwork/linkpred/tests
copying sknetwork/linkpred/tests/test_postprocessing.py -> build/lib.linux-aarch64-3.9/sknetwork/linkpred/tests
copying sknetwork/linkpred/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/linkpred/tests
creating build/lib.linux-aarch64-3.9/sknetwork/path/tests
copying sknetwork/path/tests/test_search.py -> build/lib.linux-aarch64-3.9/sknetwork/path/tests
copying sknetwork/path/tests/test_shortest_path.py -> build/lib.linux-aarch64-3.9/sknetwork/path/tests
copying sknetwork/path/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/path/tests
copying sknetwork/path/tests/test_metrics.py -> build/lib.linux-aarch64-3.9/sknetwork/path/tests
creating build/lib.linux-aarch64-3.9/sknetwork/ranking/tests
copying sknetwork/ranking/tests/test_API.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking/tests
copying sknetwork/ranking/tests/test_hits.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking/tests
copying sknetwork/ranking/tests/test_closeness.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking/tests
copying sknetwork/ranking/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking/tests
copying sknetwork/ranking/tests/test_pagerank.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking/tests
copying sknetwork/ranking/tests/test_betweenness.py -> build/lib.linux-aarch64-3.9/sknetwork/ranking/tests
creating build/lib.linux-aarch64-3.9/sknetwork/clustering/tests
copying sknetwork/clustering/tests/test_kmeans.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering/tests
copying sknetwork/clustering/tests/test_post_processing.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering/tests
copying sknetwork/clustering/tests/test_API.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering/tests
copying sknetwork/clustering/tests/__init__.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering/tests
copying sknetwork/clustering/tests/test_metrics.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering/tests
copying sknetwork/clustering/tests/test_louvain.py -> build/lib.linux-aarch64-3.9/sknetwork/clustering/tests
running egg_info
writing scikit_network.egg-info/PKG-INFO
writing dependency_links to scikit_network.egg-info/dependency_links.txt
writing entry points to scikit_network.egg-info/entry_points.txt
writing requirements to scikit_network.egg-info/requires.txt
writing top-level names to scikit_network.egg-info/top_level.txt
adding license file 'LICENSE' (matched pattern 'LICEN[CS]E*')
adding license file 'AUTHORS.rst' (matched pattern 'AUTHORS*')
reading manifest file 'scikit_network.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
warning: no files found matching '*.jpg' under directory 'docs'
warning: no files found matching '*.png' under directory 'docs'
warning: no files found matching '*.gif' under directory 'docs'
writing manifest file 'scikit_network.egg-info/SOURCES.txt'
running build_ext
building 'sknetwork.topology.triangles' extension
creating build/temp.linux-aarch64-3.9
creating build/temp.linux-aarch64-3.9/sknetwork
creating build/temp.linux-aarch64-3.9/sknetwork/topology
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/clusterfs/.pyenv/versions/proptech_env/lib/python3.9/site-packages/numpy/core/include -I/clusterfs/.pyenv/versions/proptech_env/lib/python3.9/site-packages/numpy/core/include -I/clusterfs/.pyenv/versions/proptech_env/include -I/clusterfs/.pyenv/versions/3.9.6/include/python3.9 -I/clusterfs/.pyenv/versions/proptech_env/lib/python3.9/site-packages/numpy/core/include -c ./sknetwork/topology/triangles.cpp -o build/temp.linux-aarch64-3.9/./sknetwork/topology/triangles.o
gcc: error: ./sknetwork/topology/triangles.cpp: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
Encountered error while trying to install package.
scikit-network
note: This is an issue with the package mentioned above, not pip.
In the sknetwork/topology dir there are no *.cpp files (as per the repo). Only:
dag_core.pyx dag.py init.py kcliques.pyx kcore.pyx structure.py tests triangles.pyx weisfeiler_lehman_core.pyx weisfeiler_lehman.py
Hi scikit-network,
Thanks for this library. It's really fast and well written and has been very useful for clustering large graphs (~10-100K nodes). The Paris cluster algorithm works really well for my purposes.
Instead of straight cuts, I've been using balanced cuts, which aim to keep all clusters a similar size. Essentially it uses the sknetwork.hierarchy.straight_cut
multiple times while increasing the number of clusters until any new cluster gets below some maximum size. Heres an example:
https://gist.github.com/ljmartin/7533d3837bad597b0b2971488808d87b
If there's any interest then Ill submit a PR. At the moment I'm trying to get this (and straight_cut
) to jit
because it gets quite slow to call straight_cut
multiple times on large graphs.
Inspiration came from https://github.com/vreyespue/ward_cut_tree_balanced which is now being merged into scipy. However doing a scipy.cluster.hierarchy.cut_tree
on a 10,000 node graph gives me a memory error, hence the successive calls to your straight_cut
method instead.
cheers
lewis
when i run
from sknetwork.clustering import Louvain, modularity labels = louvain.fit_transform(adjacency) #adjacency is a adjacent matrix and it‘s type is numpy.ndarray
Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.
File "~/lib/python3.8/site-packages/sknetwork/clustering/base.py", line 51, in fit_transform self.fit(*args, **kwargs) File "~/lib/python3.8/site-packages/sknetwork/clustering/louvain.py", line 252, in fit self._secondary_outputs(input_matrix) File "~/lib/python3.8/site-packages/sknetwork/clustering/base.py", line 77, in _secondary_outputs if np.issubdtype(input_matrix.data.dtype, np.bool_): AttributeError: 'memoryview' object has no attribute 'dtype'
I do not how to debug it, and it is right when the scikit-network version <= 0.20.0
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
skn.data.load_edge_list is missing from the package.
Documentation and tutorial for it are also unavailable.
https://scikit-network.readthedocs.io/en/latest/tutorials/data/index.html#datatag
installed 0.26.0
Had to roll back to 0.25.0
I'm trying to load an RDF graph. I have a file in a TSV format with separator ' ' (in fact, an NT file - n-triples)
Each line on the model
<http://fr.dbpedia.org/resource/Walter_Scott> <http://dbpedia.org/ontology/wikiPageWikiLink> <http://fr.dbpedia.org/resource/Antiquaire> .
or
<http://fr.dbpedia.org/resource/Walter_Scott> <http://www.w3.org/2000/01/rdf-schema#label> "Walter Scott"@fr .
graph
= skn.data.load_edge_list(file="ctxgraphPM.nt", directed=True, named=True, delimiter=" " )`
But, the data part of the documentation doesn't explain what is supposed to be in the TSV file for the load_edge_list method.
Could you point me to the good part of the documentation or complete it here.
Thank's in advance
Importing sknetwork yields:
>>> import sknetwork
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/conda/envs/new1/lib/python3.9/site-packages/sknetwork/__init__.py", line 9, in <module>
import sknetwork.topology
File "/opt/conda/envs/new1/lib/python3.9/site-packages/sknetwork/topology/__init__.py", line 2, in <module>
from sknetwork.topology.kcliques import Cliques
File "sknetwork/topology/kcliques.pyx", line 1, in init sknetwork.topology.kcliques
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
Any ideas what may cause this?
import numpy as np
from sknetwork.regression import Dirichlet
from sknetwork.data import house
dirichlet = Dirichlet()
adjacency = house()
seeds = {0: 1, 2: 0}
values = dirichlet.fit_transform(adjacency, seeds, verbose=True)
np.round(values, 2)
outputs
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [5], in <cell line: 11>()
7 adjacency = house()
9 seeds = {0: 1, 2: 0}
---> 11 values = dirichlet.fit_transform(adjacency, seeds, verbose=True)
13 np.round(values, 2)
File ~/miniconda3/envs/diffusion/lib/python3.9/site-packages/sknetwork/regression/base.py:37, in BaseRegressor.fit_transform(self, *args, **kwargs)
29 def fit_transform(self, *args, **kwargs) -> np.ndarray:
30 """Fit algorithm to data and return the scores. Same parameters as the ``fit`` method.
31
32 Returns
(...)
35 Values.
36 """
---> 37 self.fit(*args, **kwargs)
38 return self.values_
TypeError: fit() got an unexpected keyword argument 'verbose'
import sknetwork as skn
python report SyntaxError: invalid syntax for the line "increase: bool = True " in louvain.py
For SVG graph
Is it possible to set a positions array for labels, or automatically place them below the nodes?
https://scikit-network.readthedocs.io/en/latest/reference/visualization.html#sknetwork.visualization.graphs.svg_graph
I didn't see a way to flag it as a feature request, but currently unless something is pre-generated in NetSet it's impossible to actually load data in without reading from a file. This can add problems with trying to implement an scikit style pipeline since you have to write data to a file and perform operations after opening the file, and you create needless file i/o overhead everytime you might want to make small changes to the loaded network. Can the edgelist reading functionality be extended to include some kind of internal edgelist/TSV/SciPy Sparse matrix or a clear interface to generate a Bundle be laid out to allow loading of in memory data structures/at least file objects.
I'd like to be able to load in memory entities into scikit network edgelists
# currently have to do some variation of something like this operation with an edge list dataframe named df
location="tmp"
df.to_csv(location,sep="\t",index=False,header=False)
skn=load_edge_list(loc,bipartite=True,weighted=True)
I try to use the svg_bigraph
function to draw the images for my study, but the one of the output results is not displayed correctly.
I draw image with:
image = svg_bigraph(sparse.csr_matrix(sub_adjacency),
[company[j] for j in cluster_comp_index[i]],
[repo[j] for j in cluster_proj_index[i]],
filename="""./louvain_test_sub-{}""".format(i))
One of the images doesn't display correctly, it seems to be related to the text "b<>com", then I manually replace the '<' and '>' with '<' and '>' and the image can be displayed correctly.
I tried to build a block model using the corresponding function but got an error.
from sknetwork.toy_graphs import block_model
block_model(5)
TypeError Traceback (most recent call last)
in ()
----> 1 block_model(5)
TypeError: 'module' object is not callable
Is it not compatible with numpy 1.22.2? I just installed the package but get the error:
import sknetwork as skn
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
I'm trying to cluster mesh points depending on the distance of the descriptors extracted from, starting from each node as a cluster, then grouping points into a single cluster if they are relatively close !!
I have several wonderings;
1 - why there's a big difference between the numbers of clusters extracted from using:
Louvain()
7 clusters and : Louvain(modularity='potts')
nearly more than 100!
2- Isn't it weird to have single point as a cluster?
below is a piece of coding for what I'm doing and the output.
def clustering_regions(F):
louvain = Louvain(modularity='potts')
labels = louvain.fit_transform(F)
print(len(labels))
seen = set()
uniq = []
for x in labels:
if x not in seen:
uniq.append(x)
seen.add(x)
#print(seen)
regions = []
for j in seen:
regions.append([i for i, e in enumerate(labels) if e == j])
print(len(regions))
return regions,labels
Output:
n_of_vertices: 1926
n_clusters: 962
cluster: [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 276, 283, 296, 325, 328, 330, 331, 333, 336, 337, 340, 342, 343, 345, 347, 348, 350, 356, 358, 363, 383, 397, 399, 401, 402, 407, 408, 417, 424, 425, 428, 437, 453, 454, 455, 460, 463, 466, 468, 470, 471, 475, 477, 480, 482, 511, 522, 537, 548, 562, 566, 600, 601, 604, 607, 610, 611, 612, 616, 620, 622, 623, 624, 627, 630, 637, 639, 640, 642, 643, 644, 645, 646, 647, 653, 654, 655, 658, 659, 661, 662, 663, 664, 665, 668, 669, 672, 676, 678, 680, 681, 682, 685, 686, 689, 690, 693, 694, 697, 698, 702, 704, 706, 708, 709, 711, 712, 715, 716, 717, 718, 721, 722, 723, 724, 725, 727, 728, 729, 732, 733, 735, 736, 739, 741, 744, 745, 746, 748, 749, 752, 754, 758, 760, 761, 762, 763, 764, 765, 767, 768, 769, 770, 772, 773, 774, 775, 777, 779, 780, 781, 782, 784, 785, 787, 788, 789, 790, 791, 793, 795, 797, 798, 801, 803, 804, 805, 806, 807, 808, 809, 814, 816, 819, 827, 830, 836, 839, 840, 842, 844, 845, 846, 850, 853, 854, 855, 856, 857, 859, 862, 864, 865, 868, 869, 870, 872, 874, 875, 876, 877, 878, 880, 881, 882, 883, 884, 885, 886, 887, 889, 891, 892, 894, 896, 897, 899, 900, 901, 902, 903, 905, 906, 907, 908, 909, 910, 911, 912, 915, 916, 917, 918, 919, 920, 921, 922, 923, 925, 926, 927, 931, 932, 938, 939, 941, 943, 944, 945, 946, 947, 948, 949, 950, 951, 979, 981, 982, 983, 985, 987, 988, 994, 995, 998, 999, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1012, 1013, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1023, 1024, 1025, 1026, 1027, 1028, 1030, 1032, 1033, 1034, 1036, 1037, 1039, 1040, 1042, 1044, 1046, 1049, 1050, 1052, 1055, 1057, 1058, 1060, 1062, 1065, 1066, 1067, 1068, 1070, 1076, 1078, 1079, 1080, 1082, 1083, 1085, 1086, 1090, 1092, 1094, 1095, 1097, 1098, 1101, 1104, 1106, 1107, 1113, 1117, 1118, 1119, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1133, 1134, 1138, 1139, 1141, 1142, 1143, 1145, 1146, 1148, 1151, 1157, 1166, 1168, 1170, 1171, 1175, 1176, 1177, 1178, 1179, 1182, 1183, 1185, 1188, 1189, 1191, 1193, 1195, 1197, 1198, 1199, 1207, 1211, 1214, 1215, 1216, 1217, 1219, 1225, 1227, 1231, 1233, 1234, 1240, 1241, 1242, 1253, 1257, 1260, 1262, 1264, 1265, 1274, 1277, 1279, 1280, 1283, 1285, 1286, 1295, 1302, 1304, 1659, 1661, 1663, 1665, 1667, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1700, 1701, 1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1756, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925], [268, 269, 270, 271, 272, 273, 274, 275, 277, 278, 279, 280, 281, 282, 284, 286, 291, 292, 293, 299, 319, 320, 327, 339, 351, 353, 365, 372, 442, 496, 539, 584, 699, 757, 976, 1339], [1341], [1342], [1343], [1344], [1345], [1346], [1347], [1348], [1349], [1350], [1351], [1352], [1353], [1354], [1355], [1356], [1357], [1358], [1359], [1360], [1361], [1362], [1363], [1364], [1365], [1366], [1340], [1338], [1337], [1336], [1310], [1311], [1312], [1313], [1314], [1315], [1316], [1317], [1318], [1319], [1320], [1321], [1367], [1322], [1324], [1325], [1326], [1327], [1328], [1329], [1330], [1331], [1332], [1333], [1334], [1335], [1323], [1368], [1369], [1370], [1401], [1402], [1403], [1404], [1405], [1406], [1407], [1408], [1409], [1410], [1411], [1412], [1400], [1413], [1415], [1416], [1417], [1418], [1419], [1420], [1421], [1422], [1423], [1424], [1425], [1426], [1414], [1309], [1399], [1397], [1371], [1372], [1373], [1374], [1375], [1376], [1377], [1378], [1379], [1380], [1381], [1382], [1398], [1383], [1385], [1386], [1387], [1388], [1389], [1390], [1391], [1392], [1393], [1394], [1395], [1396], [1384], [1308], [1307], [1306], [1173], [1174], [1180], [1181], [1184], [1186], [1187], [1190], [1192], [1194], [1196], [1200], [1172], [1201], [1203], [1204], [1205], [1206], [1208], [1209], [1210], [1212], [1213], [1218], [1220], [1221], [1202], [1222], [1169], [1165], [1120], [1121], [1129], [1130], [1131], [1132], [1135], [1136], [1137], [1140], [1144], [1147], [1167], [1149], [1152], [1153], [1154], [1155], [1156], [1158], [1159], [1160], [1161], [1162], [1163], [1164], [1150], [1427], [1223], [1226], [1270], [1271], [1272], [1273], [1275], [1276], [1278], [1281], [1282], [1284], [1287], [1288], [1269], [1289], [1291], [1292], [1293], [1294], [1296], [1297], [1298], [1299], [1300], [1301], [1303], [1305], [1290], [1224], [1268], [1266], [1228], [1229], [1230], [1232], [1235], [1236], [1237], [1238], [1239], [1243], [1244], [1245], [1267], [1246], [1248], [1249], [1250], [1251], [1252], [1254], [1255], [1256], [1258], [1259], [1261], [1263], [1247], [1428], [1429], [1430], [1582], [1583], [1584], [1585], [1586], [1587], [1588], [1589], [1590], [1591], [1592], [1593], [1581], [1594], [1596], [1597], [1598], [1599], [1600], [1601], [1602], [1603], [1604], [1605], [1606], [1607], [1595], [1608], [1580], [1578], [1552], [1553], [1554], [1555], [1556], [1557], [1558], [1559], [1560], [1561], [1562], [1563], [1579], [1564], [1566], [1567], [1568], [1569], [1570], [1571], [1572], [1573], [1574], [1575], [1576], [1577], [1565], [1551], [1609], [1611], [1642], [1643], [1644], [1645], [1646], [1647], [1648], [1649], [1650], [1651], [1652], [1653], [1641], [1654], [1656], [1657], [1658], [1660], [1662], [1664], [1666], [1668], [1669], [1746], [1755], [1757], [1655], [1610], [1640], [1638], [1612], [1613], [1614], [1615], [1616], [1617], [1618], [1619], [1620], [1621], [1622], [1623], [1639], [1624], [1626], [1627], [1628], [1629], [1630], [1631], [1632], [1633], [1634], [1635], [1636], [1637], [1625], [1550], [1549], [1548], [1461], [1462], [1463], [1464], [1465], [1466], [1467], [1468], [1469], [1470], [1471], [1472], [1460], [1473], [1475], [1476], [1477], [1478], [1479], [1480], [1481], [1482], [1483], [1484], [1485], [1486], [1474], [1487], [1459], [1457], [1431], [1432], [1433], [1434], [1435], [1436], [1437], [1438], [1439], [1440], [1441], [1442], [1458], [1443], [1445], [1446], [1447], [1448], [1449], [1450], [1451], [1452], [1453], [1454], [1455], [1456], [1444], [1488], [1489], [1490], [1522], [1523], [1524], [1525], [1526], [1527], [1528], [1529], [1530], [1531], [1532], [1533], [1521], [1534], [1536], [1537], [1538], [1539], [1540], [1541], [1542], [1543], [1544], [1545], [1546], [1547], [1535], [1520], [1519], [1518], [1491], [1492], [1493], [1494], [1495], [1496], [1497], [1498], [1499], [1500], [1501], [1502], [1503], [1504], [1505], [1506], [1507], [1508], [1509], [1510], [1511], [1512], [1513], [1514], [1515], [1516], [1517], [1116], [1115], [1114], [1112], [492], [493], [494], [495], [497], [498], [499], [500], [501], [502], [503], [504], [491], [505], [507], [508], [509], [510], [512], [513], [514], [515], [516], [517], [518], [519], [506], [520], [490], [488], [449], [450], [451], [452], [456], [457], [458], [459], [461], [462], [464], [465], [489], [467], [472], [473], [474], [476], [478], [479], [481], [483], [484], [485], [486], [487], [469], [448], [521], [524], [558], [559], [560], [561], [563], [564], [565], [567], [568], [569], [570], [571], [557], [572], [574], [575], [576], [577], [578], [579], [580], [581], [582], [583], [585], [586], [573], [523], [556], [554], [525], [526], [527], [528], [529], [530], [531], [532], [533], [534], [535], [536], [555], [538], [541], [542], [543], [544], [545], [546], [547], [549], [550], [551], [552], [553], [540], [587], [447], [445], [323], [324], [326], [329], [332], [334], [335], [338], [341], [344], [346], [349], [322], [352], [355], [357], [359], [360], [361], [362], [364], [366], [367], [368], [369], [370], [354], [371], [321], [317], [285], [287], [288], [289], [290], [294], [295], [297], [298], [300], [301], [302], [318], [303], [305], [306], [307], [308], [309], [310], [311], [312], [313], [314], [315], [316], [304], [446], [373], [375], [413], [414], [415], [416], [418], [419], [420], [421], [422], [423], [426], [427], [412], [429], [431], [432], [433], [434], [435], [436], [438], [439], [440], [441], [443], [444], [430], [374], [411], [409], [376], [377], [378], [379], [380], [381], [382], [384], [385], [386], [387], [388], [410], [389], [391], [392], [393], [394], [395], [396], [398], [400], [403], [404], [405], [406], [390], [588], [589], [590], [936], [937], [940], [942], [952], [953], [954], [955], [956], [957], [958], [959], [935], [960], [962], [963], [964], [965], [966], [967], [968], [969], [970], [971], [972], [973], [961], [974], [934], [930], [843], [847], [848], [849], [851], [852], [858], [860], [861], [863], [866], [867], [933], [871], [879], [888], [890], [893], [895], [898], [904], [913], [914], [924], [928], [929], [873], [841], [975], [978], [1063], [1064], [1069], [1071], [1072], [1073], [1074], [1075], [1077], [1081], [1084], [1087], [1061], [1088], [1091], [1093], [1096], [1099], [1100], [1102], [1103], [1105], [1108], [1109], [1110], [1111], [1089], [977], [1059], [1054], [980], [984], [986], [989], [990], [991], [992], [993], [996], [997], [1000], [1010], [1056], [1011], [1022], [1029], [1031], [1035], [1038], [1041], [1043], [1045], [1047], [1048], [1051], [1053], [1014], [838], [837], [835], [635], [636], [638], [641], [648], [649], [650], [651], [652], [656], [657], [660], [634], [666], [670], [671], [673], [674], [675], [677], [679], [683], [684], [687], [688], [691], [667], [692], [633], [631], [591], [592], [593], [594], [595], [596], [597], [598], [599], [602], [603], [605], [632], [606], [609], [613], [614], [615], [617], [618], [619], [621], [625], [626], [628], [629], [608], [695], [696], [700], [792], [794], [796], [799], [800], [802], [810], [811], [812], [813], [815], [817], [786], [818], [821], [822], [823], [824], [825], [826], [828], [829], [831], [832], [833], [834], [820], [783], [778], [776], [701], [703], [705], [707], [710], [713], [714], [719], [720], [726], [730], [731], [734], [737], [738], [740], [742], [743], [747], [750], [751], [753], [755], [756], [759], [766], [771], [1765], [1766]]
I'm trying to visualize each cluster with a single color: and here what I got as visualizing:
For the life of me I cannot get my four node classes to be colored by class for SVG visualization:
Labels_named = []
for l in Labels:
if l == 0:
Labels_named.append('blue')
elif l == 1:
Labels_named.append("orange")
elif l == 2:
Labels_named.append("brown")
elif l == 3:
Labels_named.append("fuchsia")
else:
print("Error: Nothing should be > 3")
Labels_named[:5]
image = svg_graph(adjacency, embedding, node_color=Labels_named)
SVG(image)
Note in the above that I have 4 node classes labeled 0, 1, 2, and 3.
I'm not understanding what I am doing incorrectly. The documentation is not very helpful either. Any guidance would be very helpful!
Just finding this library, and wow! I wish I had found this sooner.
Was working on some implementations for edge filtering (see here) but eventually would love to contribute using this framework.
LinearOperator
so extensively, so any resources on using those?scipy.linalg.pinv
wrapped in an Algorithm
ok here?When there are no edges, i.e., every node is a component; there would be an error.
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
I want to compute the k-core decomposition of my bipartite graph. But when I compute it with k=5, I find odd results: some nodes with core value of k are not connected to at least k nodes of core value >= k.
adjacency = bipartite2undirected(biadjacency)
kcore = CoreDecomposition()
kcore.fit(adjacency)
k = 5
kcore_nodes = kcore.labels_ >= k
red_adj = adjacency[kcore_nodes,:][:, kcore_nodes]
red_adj.eliminate_zeros()
for indice in range(red_adj.shape[0]):
assert red_adj.indptr[indice + 1] - red_adj.indptr[indice] >= k
AssertionError
Thanks!
Playing with cut_balanced failed
Here's my dendrogram
[[ 8. 18. 0.20704904 2. ]
[ 0. 2. 0.37775594 2. ]
[16. 21. 0.45278056 3. ]
[ 4. 22. 0.48408993 4. ]
[ 1. 23. 0.49373192 5. ]
[ 3. 24. 0.54854167 6. ]
[ 9. 17. 0.5539515 2. ]
[13. 14. 0.56726755 2. ]
[ 5. 10. 0.59249521 2. ]
[20. 26. 0.59532007 4. ]
[12. 15. 0.61572425 2. ]
[ 7. 19. 0.6221304 2. ]
[27. 28. 0.62684343 4. ]
[11. 30. 0.65255261 3. ]
[ 6. 25. 0.65711535 7. ]
[31. 33. 0.66109365 5. ]
[29. 32. 0.68098031 8. ]
[35. 36. 0.79584075 13. ]
[34. 37. 1.03229063 20. ]]
labels, dendrogram = cut_balanced(dendrogram, max_cluster_size=4, return_dendrogram=True)
print(dendrogram)
print(labels)
results in this invalid dendrogram...
[[ 0. 0. 0.62684343 4. ]
[ 0. 0. 0.65255261 3. ]
[ 7. 0. 0.65711535 7. ]
[ 4. 9. 0.66109365 5. ]
[ 1. 8. 0.68098031 8. ]
[11. 12. 0.79584075 13. ]
[10. 13. 1.03229063 20. ]]
Great package! Really loving the efficiency and integration with numpy arrays / scipy.sparse matrices.
I'm interested in applying sknetwork.ranking.PageRank
iteratively for each node as a seed:
matrix # the input adjacency matrix
rwr_matrix = np.zeros(matrix.shape)
for i in range(nrows):
pagerank = skn.ranking.PageRank(damping_factor=0.85)
scores = pagerank.fit_transform(adjacency=matrix, seeds={i: 1.0})
rwr_matrix[i] = scores # set values in row i to contain scores
The output rwr_matrix
would be a 2D matrix, with the same shape as the input adjacency matrix, but where edge weights are replaced with random walk with restart proximity scores.
I was wondering if there was a more efficient implementation that iterating through each seed node, one at a time. Is there some linear algebra that could solve this matrix all at once that sknetwork would be interested in implementing?
Performing SCC analysis fails due to calling max() on ndarray.data.
Here is a minimal example for reproducing:
>>> import numpy as np
>>> from sknetwork.topology import connected_components
>>> connected_components(np.zeros([4,4]), connection="strong")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\jan svejda\Projects\JMCS-TSI\setup-scripts\sct\applications\venv\lib\site-packages\sknetwork\topology\structure.py", line 36, in connected_components
return sparse.csgraph.connected_components(adjacency, not is_symmetric(adjacency), connection, True)[1]
File "C:\Users\jan svejda\Projects\JMCS-TSI\setup-scripts\sct\applications\venv\lib\site-packages\sknetwork\utils\check.py", line 74, in is_symmetric
return np.all(np.abs(sym_error.data) <= tol * np.abs(adjacency.data.max()))
AttributeError: 'memoryview' object has no attribute 'max'
I was trying to form a graph with from_edge_list
method, which is located here: sknetwork.data.from_edge_list
However, current version of sknetwork does not recognize the method.
Note that I've installed scikit-network with 'pip install scikit-network', and the current version is 0.20.0.
Note that 'pip install scikit-network==0.26.0' results in the following error message:
ERROR: Could not find a version that satisfies the requirement scikit-network==0.26.0
ERROR: No matching distribution found for scikit-network==0.26.0
How could I install the latest version of scikit-network?
I'm trying to install scikit-network via pip
.
Version 0.12.1 is installed.
If I use Python 3.8 then the latest version is installed as expected.
pip install scikit-network
I tried to install the last version of scimitar-network with pip and it failed with the following error message :
ERROR: Failed building wheel for scikit-network
I ran pip install scikit-network==0.24
(otherwise pip installs an old version [0.12]).
I got the following output:
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/Caskroom/miniforge/base/envs/py38/bin/python3.8 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2q/xm5zz8nx625f77jbbst372y40000gn/T/pip-install-5q7j1v8s/scikit-network_f1250cebe26741c3bea827403aa5a663/setup.py'"'"'; __file__='"'"'/private/var/folders/2q/xm5zz8nx625f77jbbst372y40000gn/T/pip-install-5q7j1v8s/scikit-network_f1250cebe26741c3bea827403aa5a663/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/2q/xm5zz8nx625f77jbbst372y40000gn/T/pip-record-_s0ilauy/install-record.txt --single-version-externally-managed --compile --install-headers /opt/homebrew/Caskroom/miniforge/base/envs/py38/include/python3.8/scikit-network
cwd: /private/var/folders/2q/xm5zz8nx625f77jbbst372y40000gn/T/pip-install-5q7j1v8s/scikit-network_f1250cebe26741c3bea827403aa5a663/
Complete output (26 lines):
/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
warnings.warn(
WARNING: Ignoring invalid distribution -cikit-network (/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/2q/xm5zz8nx625f77jbbst372y40000gn/T/pip-install-5q7j1v8s/scikit-network_f1250cebe26741c3bea827403aa5a663/setup.py", line 14, in <module>
dist.Distribution().fetch_build_eggs(['Cython', 'numpy==1.20.0'])
File "/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages/setuptools/dist.py", line 812, in fetch_build_eggs
resolved_dists = pkg_resources.working_set.resolve(
File "/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages/pkg_resources/__init__.py", line 771, in resolve
dist = best[req.key] = env.best_match(
File "/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1056, in best_match
return self.obtain(req, installer)
File "/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1068, in obtain
return installer(requirement)
File "/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages/setuptools/dist.py", line 883, in fetch_build_egg
return fetch_build_egg(self, req)
File "/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages/setuptools/installer.py", line 87, in fetch_build_egg
wheel.install_as_egg(dist_location)
File "/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages/setuptools/wheel.py", line 95, in install_as_egg
self._install_as_egg(destination_eggdir, zf)
File "/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages/setuptools/wheel.py", line 103, in _install_as_egg
self._convert_metadata(zf, destination_eggdir, dist_info, egg_info)
File "/opt/homebrew/Caskroom/miniforge/base/envs/py38/lib/python3.8/site-packages/setuptools/wheel.py", line 124, in _convert_metadata
os.mkdir(destination_eggdir)
FileExistsError: [Errno 17] File exists: '/private/var/folders/2q/xm5zz8nx625f77jbbst372y40000gn/T/pip-install-5q7j1v8s/scikit-network_f1250cebe26741c3bea827403aa5a663/.eggs/numpy-1.20.0-py3.8-macosx-11.0-arm64.egg'
----------------------------------------
Thank you for helping me !
Alexandre Le Bris
Hi, I read in that there is a means to build a "pure python" version of the library on one of the prior issues where individuals were talking about issues debugging in Cython with PyCharm. I too am having trouble debugging in PyCharm due to a similar "NoneType is not callable" exception. I saw in the setup.py that there was an environmental flag to turn off Cythonizing.
I'm wondering what the easiest way to compile a non-Cython version that I can debug with PyCharm on macOS would be? Appreciate any thoughts on this subject.
Do a simple test in debug mode under the PyCharm IDE
Succesfully install scikit-network (checked in console)
My test code in PyCharm:
import sknetwork as skn
graph = skn.data.karate_club(metadata=True)
Error message
C:\outils\Python\Python36\python.exe "C:\Program Files\JetBrains\PyCharm 2019.2.5\helpers\pydev\pydevd.py" --cmd-line --multiproc --qt-support=auto --client 127.0.0.1 --port 55127 --file C:/wamp64/www/givingsense.eu/datamusee/python/datamusee/trials/trialScikitNetwork.py
pydev debugger: process 1888 is connecting
Connected to pydev debugger (build 192.7142.79)
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2019.2.5\helpers\pydev\pydevd.py", line 2108, in
main()
File "C:\Program Files\JetBrains\PyCharm 2019.2.5\helpers\pydev\pydevd.py", line 2099, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm 2019.2.5\helpers\pydev\pydevd.py", line 1408, in run
return self.exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "C:\Program Files\JetBrains\PyCharm 2019.2.5\helpers\pydev\pydevd.py", line 1415, in exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2019.2.5\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/wamp64/www/givingsense.eu/datamusee/python/datamusee/trials/trialScikitNetwork.py", line 1, in
import sknetwork as skn
File "C:\outils\Python\Python36\lib\site-packages\sknetwork_init.py", line 9, in
import sknetwork.topology
File "C:\outils\Python\Python36\lib\site-packages\sknetwork\topology_init.py", line 2, in
from sknetwork.topology.kcliques import Cliques
File "sknetwork\topology\kcliques.pyx", line 11, in init sknetwork.topology.kcliques
File "sknetwork\topology\kcliques.pyx", line 11, in __Pyx_PyMODINIT_FUNC PyInit_kcliques(void)
TypeError: 'NoneType' object is not callable
Process finished with exit code 1
I am trying to form a weighted graph from a weighted edge list. Given that my nodes have specific names, I wonder how I
may figure out the mapping between the actual node names and the indices.
This is the code I use for graph formation:
adjacency = skn.data.from_edge_list(cui_data_exported, weighted=True, reindex=True, matrix_only=False)
The idea is to calculate node embeddings with the Spectral approach:
spectral = Spectral(n_components=self.factors, decomposition='laplacian', normalized=False, regularization=0.0)
pos = spectral.fit_transform(adjacency)
In the above, pos
will not be a dict which I may query by the actual node name, but a list of coordinates.
How could I access the position of a node with its original name?
would it be useful to check a graph's cyclicity? (eg whether this graph is a dag)
it could look something like this:
edgelist = [(0, 1), (1, 2), (2, 3), (3, 0), (0, 2)]
adjacency = edgelist2adjacency(edgelist)
adjacency.is_cyclic # returns true if cyclic
and it could be part of the utils/check.py
(along with other checks eg symmetric).
Hi,
I noticed that the link of the article for the stochastic block model is the wrong one : https://arxiv.org/abs/0803.0476 instead of https://arxiv.org/pdf/0705.4485.pdf
I needed to generate a stochastic block model with p_in<p_out but it is still not directly possible. It would be great if you could make it.
I am actually working on EM type algorithms for graphs, and I wondered if you would be interested in adding algorithms such as the variational EM : VEM
I implemented it using numba to speed up the loops. But it would probably be better to use cython. Unfortunately, I don't really know it.
Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
Hello,
I've been checking your implementation for what was called before "BiLouvain". I know you merged it with the Louvain code for directed and non-directed general static networks. However, I find it a bit confusing, as I don't see Barber's modularity (or any specific modularity for bipartite networks) cited neither in the documentation or code. Are you still using Barber's modularity from "Modularity and community detection in bipartite graphs"? Is the implementation based on "A novel community detection method in bipartite networks"?
Thanks!
Omar
Hello Scikit-Network Team!
I've been running some Louvain algorithms to hard cluster my networks (node sizes between 1k and 2k) and received some unexpected results when I tried hierarchical Louvain and the plain Louvain.
(1) I get way too many clusters when I shuffle nodes (both for heirarchical Louvain and plain Louvain)
My understanding that the default algorithm produces stable results (i.e., same cluster assignment in every iteration) and the only way to randomize for optimization is to set shuffle_nodes as True.
When I set shuffle_nodes as False with resolution parameter 1, Louvain returns 6 clusters.
When I set shuffle_nodes as True, however, it returns more than 35 and sometimes more than 50 clusters with the same resolution parameter!
I would appreciate if you could check if there's an issue with the algorithm. If I am supposed to expect such difference, a brief explanation would help a lot.
My guess is that there's a possibility that when I shuffle nodes, the modularity sets into 'potts'. This is a wild guess based on my observation that that's the only way I can that many clusters.
(2) Cluster assignments from non-shuffled Louvain and Hierarchical Louvain are different
So now I'm dealing with non-shuffled cases. I expected the plain Louvain and the first-level clusters in Hierarchical Louvain to return the same assignment (given they're not randomized) but they don't.
(3) Non-shuffled Louvain methods are different Gephi's modularity clustering
For your Louvain I get 6 clusters. When I run the Gephi algorithm without randomizing, it returns 5 and assignments are obviously different. Sk network returns 6 clusters both in Newman and Dugue methods. I wonder what may be causing this difference?
The most urgent issue is (1). In general, I would like to understand more on how the "shuffle_nodes" argument works.
Many thanks in advance!
(1) For the first issue I ran
from sknetwork.clustering import Louvain
LC_noshuffle = clustering.Louvain(shuffle_nodes=False)
LC_shuffle = clustering.Louvain(shuffle_nodes=True)
print("Number of clusters without shuffling Louvain")
print(len(set(LC_noshuffle.fit_transform(G_adj)))) #G_adj is the adjacency matrix
print("-----")
print("Number of clusters while shuffling Louvain (25 iterations)")
n_clusters = list()
for i in range(25):
n_clusters.append(len(set(LC_shuffle.fit_transform(G_adj))))
print(n_clusters)
The output returns
Number of clusters without shuffling Louvain
6
-----
Number of clusters while shuffling Louvain (25 iterations)
[44, 37, 41, 42, 38, 34, 47, 44, 34, 51, 38, 42, 48, 39, 39, 41, 43, 38, 45, 39, 45, 37, 49, 47, 44]
(2) For the second issue I ran
from sknetwork.hierarchy import LouvainHierarchy
from sknetwork.clustering import Louvain
from scipy.cluster import hierarchy
LC = clustering.Louvain(shuffle_nodes=False)
LH = LouvainHierarchy(shuffle_nodes=False)
LC_assign = LC.fit_transform(G_adj) # 6 cluster assignment from plain Louvain
LH_assign = hierarchy.fcluster(LH.fit_transform(G_adj), t=6 , criterion='maxclust')
# 6 cluster assignment from Hierarchical Louvain when the maximum number of clusters is restricted to 6
print("Do they produce the same number of clusters?")
print(len(set(LC_assign)) == len(set(LH_assign)) )
print("-------------")
print("Do they produce the assignment?")
print(list(LC_assign) == list(LH_assign) )
The output is
Do they produce the same number of clusters?
True
-------------
Do they produce the same assignment?
False
Is there any plan to make this package available on a conda channel?
This is a feature request. I would be interested in adding this to the library if the other contributors like it. The single commodity flow problem centers on finding the maximum flow from a set of source node to a set of target nodes with edge capacity constraints. We could implement a maximum flow method by wrapping (https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csgraph.maximum_flow.html).
Hello, this is not an issue but a question. I would like to test scikit-network with a huge graph db hosted in Amazon Neptune.
I can extract a random sample and rebuild the graph by recursive edge traversing. Am I wondering if scikit-network has any better and more elegant way to import a graph from a graph db?
Thanx in advance
Dear scikit-net
I used page rank algorithm for ranking my directed graph. Now how can find the name of nodes from scores. scores is the output if pageranking algorithm.
thanks
scikit-network version: 0.26.0
Python version: 3.8
Operating System: Linux Mint
I am using your PageRank-based recommender, described at: https://scikit-network.readthedocs.io/en/latest/use_cases/recommendation.html
So, for each user, I want to return a number of recommendations. However, since the number of users and items is large, the pagerank algorithm walks over the whole graph, meaning it would be prohibitive to use the approach in inference time. Could I somehow limit the walk to a local portion of the graph, given that I only need top-10 items? I thought about extracting a local graph for each user, and then perform pagerank, but I'm not sure it this is a clever way (and how I would approach it). Do you have an idea on how I might achieve a speedup? Any suggestion is highly welcome.
When I run py file which has following 2 simple lines, error occures that says 'TypeError: 'NoneType' object is not callable' .
The following phenomenon I find is same at both VS code(1.59.1) on Win10 and VS code(1.63.2) on Ubuntu20.04.
When I run py file that contains following 2 simple lines, error occures that says 'TypeError: 'NoneType' object is not callable' before printing 'test'. I suppose that the error happens during importing sknetwork.
However, when I execute a cell contains only 'import sknetwork' in Jupyter notebook in VS code it is fine. Then I can use Louvain clustering function as I expected. Also, importing the sknetwork on Python which is launched by conda is fine.
This is posted on stack overflow, but it is not closed yet. Someone said that this happens on Pycharm too.
I installed scikit-network from source file, but resulted same error.
It will be really helpful if you give us some advice.
Thanks,
**import sknetwork
print('test')**
(net01) C:\Users\CXXXXX\Documents\AI_development\workspace_\From-To_Analize\source> c: && cd c:\Users\CXXXXX\Documents\AI_development\workspace_\From-To_Analize\source && cmd /C "C:\Users\CXXXXX\Anaconda3\envs\net01\python.exe c:\Users\CXXXXX\.vscode\extensions\ms-python.python-2021.10.1365161279\pythonFiles\lib\python\debugpy\launcher 62711 -- c:\Users\CXXXXX\Documents\AI_development\workspace_\From-To_Analize\source\Process_community.py "
Traceback (most recent call last):
File "C:\Users\CXXXXX\Anaconda3\envs\net01\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\CXXXXX\Anaconda3\envs\net01\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\Users\CXXXXX\.vscode\extensions\ms-python.python-2021.10.1365161279\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
cli.main()
File "c:\Users\CXXXXX\.vscode\extensions\ms-python.python-2021.10.1365161279\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
run()
File "c:\Users\CXXXXX\.vscode\extensions\ms-python.python-2021.10.1365161279\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
File "C:\Users\CXXXXX\Anaconda3\envs\net01\lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\CXXXXX\Anaconda3\envs\net01\lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\CXXXXX\Anaconda3\envs\net01\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\Users\CXXXXX\Documents\AI_development\workspace_\From-To_Analize\source\Process_community.py", line 2, in <module>
import sknetwork as skn
File "C:\Users\CXXXXX\Anaconda3\envs\net01\lib\site-packages\sknetwork\__init__.py", line 9, in <module>
import sknetwork.topology
File "C:\Users\CXXXXX\Anaconda3\envs\net01\lib\site-packages\sknetwork\topology\__init__.py", line 2, in <module>
from sknetwork.topology.kcliques import Cliques
File "sknetwork\topology\kcliques.pyx", line 11, in init sknetwork.topology.kcliques
File "sknetwork\topology\kcliques.pyx", line 11, in __Pyx_PyMODINIT_FUNC PyInit_kcliques(void)
**TypeError: 'NoneType' object is not callable**
I didn't see any code in the library that supports checking if two graphs are isomorphic. Graphs G and H are said to be isomorphic if there exists a bijection f: G -> H s.t. for all u in G, v in H, f(u) is adjacent to f(v) iff u is adjacent to v. I would like to add a function that tests if a given function forms an isomorphism between G and H, and a function that checks if two graphs could be isomorphic.
Tried to import
from sknetwork.visualization import svg_graph, svg_digraph, svg_bigraph
from sknetwork.topology import CoreDecomposition
from sknetwork.topology import Triangles, Cliques
from sknetwork.classification import KNN
from sknetwork.embedding import GSVD
ValueError Traceback (most recent call last)
Input In [48], in <cell line: 3>()
1 from IPython.display import SVG
2 from scipy import sparse
----> 3 from sknetwork.visualization import svg_graph, svg_digraph, svg_bigraph
4 from sknetwork.topology import CoreDecomposition
5 from sknetwork.topology import Triangles, Cliques
File /opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/sknetwork/__init__.py:9, in <module>
6 __email__ = "[email protected]"
7 __version__ = '0.26.0'
----> 9 import sknetwork.topology
10 import sknetwork.path
11 import sknetwork.classification
File /opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/sknetwork/topology/__init__.py:2, in <module>
1 """Module on topology."""
----> 2 from sknetwork.topology.kcliques import Cliques
3 from sknetwork.topology.kcore import CoreDecomposition
4 from sknetwork.topology.triangles import Triangles
File sknetwork/topology/kcliques.pyx:1, in init sknetwork.topology.kcliques()
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.