caterby / vldb2021_fauce

2 stars 3 forks source link

An issue with Join2Vec: The number of classes has to be greater than one; got 1 class #1

Open PengJiazhen408 opened 1 year ago

PengJiazhen408 commented 1 year ago

Thanks for sharing this code. I'm trying to run it and I encountered an issue with Join2Vec (cf. error message below). It seems that there is a problem with data format in example data (And it may be helpful to guide how to generate the example data in Join2Vec 🙂) Thanks, in advance!

INFO:root:Loaded 2 graph file names form ../example_data/datasets/node_edges
INFO:root:Dumped subgraph2vec sentences for all 2 graphs in ../example_data/datasets/node_edges in 0.0 sec
INFO:root:The embedding file: ../embeddings/node_edges_dims_4_epochs_3_embeddings.txt is already present, hence NOT training skipgram model for subgraph vectors
INFO:root:Trained the skipgram model in 0.0 sec.
INFO:gensim.models.utils_any2vec:loading projection weights from ../embeddings/node_edges_dims_4_epochs_3_embeddings.txt
INFO:gensim.models.utils_any2vec:loaded (22, 4) matrix from ../embeddings/node_edges_dims_4_epochs_3_embeddings.txt
INFO:root:Loaded gensim model of subgraph vectors
INFO:root:Vocab consists of 22 subgraph features
INFO:root:Loaded 2 graph WL kernel files for performing classification
INFO:root:X (sample) matrix shape: (2, 22)
['../example_data/datasets/node_edges/0.WL2', '../example_data/datasets/node_edges/1.WL2']
INFO:root:Y (label) matrix shape: (2,)
INFO:root:Train and Test matrix shapes: (1, 22), (1, 22), (1,), (1,)
Traceback (most recent call last):
  File "main.py", line 105, in <module>
    main(args)
  File "main.py", line 53, in main
    perform_classification (corpus_dir, wl_extn, embedding_fname, class_labels_fname)
  File "/data/pjz_data/sql/vldb2021_fauce/queries_featurization/Joins2Vec/classify.py", line 128, in perform_classification
    linear_kernel_svm_classify(X_train, X_test, Y_train, Y_test)
  File "/data/pjz_data/sql/vldb2021_fauce/queries_featurization/Joins2Vec/classify.py", line 55, in linear_kernel_svm_classify
    classifier.fit(train_kernel.toarray(), Y_train)
  File "/home/zju/anaconda3/envs/gensim/lib/python2.7/site-packages/sklearn/svm/base.py", line 150, in fit
    y = self._validate_targets(y)
  File "/home/zju/anaconda3/envs/gensim/lib/python2.7/site-packages/sklearn/svm/base.py", line 525, in _validate_targets
    " class" % len(cls))
ValueError: The number of classes has to be greater than one; got 1 class
Erostrate9 commented 4 weeks ago

Thanks for sharing this code. I'm trying to run it and I encountered an issue with Join2Vec (cf. error message below). It seems that there is a problem with data format in example data (And it may be helpful to guide how to generate the example data in Join2Vec 🙂) Thanks, in advance!

INFO:root:Loaded 2 graph file names form ../example_data/datasets/node_edges
INFO:root:Dumped subgraph2vec sentences for all 2 graphs in ../example_data/datasets/node_edges in 0.0 sec
INFO:root:The embedding file: ../embeddings/node_edges_dims_4_epochs_3_embeddings.txt is already present, hence NOT training skipgram model for subgraph vectors
INFO:root:Trained the skipgram model in 0.0 sec.
INFO:gensim.models.utils_any2vec:loading projection weights from ../embeddings/node_edges_dims_4_epochs_3_embeddings.txt
INFO:gensim.models.utils_any2vec:loaded (22, 4) matrix from ../embeddings/node_edges_dims_4_epochs_3_embeddings.txt
INFO:root:Loaded gensim model of subgraph vectors
INFO:root:Vocab consists of 22 subgraph features
INFO:root:Loaded 2 graph WL kernel files for performing classification
INFO:root:X (sample) matrix shape: (2, 22)
['../example_data/datasets/node_edges/0.WL2', '../example_data/datasets/node_edges/1.WL2']
INFO:root:Y (label) matrix shape: (2,)
INFO:root:Train and Test matrix shapes: (1, 22), (1, 22), (1,), (1,)
Traceback (most recent call last):
  File "main.py", line 105, in <module>
    main(args)
  File "main.py", line 53, in main
    perform_classification (corpus_dir, wl_extn, embedding_fname, class_labels_fname)
  File "/data/pjz_data/sql/vldb2021_fauce/queries_featurization/Joins2Vec/classify.py", line 128, in perform_classification
    linear_kernel_svm_classify(X_train, X_test, Y_train, Y_test)
  File "/data/pjz_data/sql/vldb2021_fauce/queries_featurization/Joins2Vec/classify.py", line 55, in linear_kernel_svm_classify
    classifier.fit(train_kernel.toarray(), Y_train)
  File "/home/zju/anaconda3/envs/gensim/lib/python2.7/site-packages/sklearn/svm/base.py", line 150, in fit
    y = self._validate_targets(y)
  File "/home/zju/anaconda3/envs/gensim/lib/python2.7/site-packages/sklearn/svm/base.py", line 525, in _validate_targets
    " class" % len(cls))
ValueError: The number of classes has to be greater than one; got 1 class

请问最后解决了吗?我不明白gexf文件里attvalue是什么含义。为什么example_data里有0.gexf和1.gexf两个不同的图呢?