thunlp / OpenNE

An Open-Source Package for Network Embedding (NE)
MIT License
1.68k stars 485 forks source link

How to perform Predictions? #90

Closed arshpreetsingh closed 4 years ago

arshpreetsingh commented 5 years ago

Can you tell how I can perform predictions for in the folowing code and to tet the accuracy of my mode:.........? https://github.com/thunlp/OpenNE/blob/master/visualization_example/20newsgroup.py

Bznkxs commented 4 years ago

Hi arshpreetsingh,

You can get the network embedding in line 56. The next thing to do is train a classifier using a certain portion of nodes (say 10%), with their embedding as input and labels as output. After training, use the classifier to predict the label of other nodes. You can test the accuracy using F1-score.

A similar process is implemented in __main__.py:

    vectors = model.vectors
    X, Y = read_node_label(args.label_file)
    print("Training classifier using {:.2f}% nodes...".format(
        args.clf_ratio*100))
    clf = Classifier(vectors=vectors, clf=LogisticRegression())
    clf.split_train_evaluate(X, Y, args.clf_ratio, seed=0)

where Classifier is implemented in classifier.py.