|
| 1 | +export CiteSeer |
| 2 | + |
| 3 | + |
| 4 | +""" |
| 5 | + CiteSeer |
| 6 | +
|
| 7 | +The CiteSeer citation network dataset from Ref. [1]. |
| 8 | +Nodes represent documents and edges represent citation links. |
| 9 | +The dataset is designed for the node classification task. |
| 10 | +The task is to predict the category of certain paper. |
| 11 | +The dataset is retrieved from Ref. [2]. |
| 12 | +
|
| 13 | +## Interface |
| 14 | +
|
| 15 | +- [`CiteSeer.dataset`](@ref) |
| 16 | +
|
| 17 | +## References |
| 18 | +
|
| 19 | +[1]: [Deep Gaussian Embedding of Graphs: Unsupervised Inductive Learning via Ranking](https://arxiv.org/abs/1707.03815) |
| 20 | +[2]: [Planetoid](https://github.com/kimiyoung/planetoid) |
| 21 | +""" |
| 22 | +module CiteSeer |
| 23 | + |
| 24 | +using DataDeps |
| 25 | +using ..MLDatasets: datafile, read_planetoid_data |
| 26 | +using DelimitedFiles: readdlm |
| 27 | + |
| 28 | +using PyCall |
| 29 | + |
| 30 | +const DEPNAME = "CiteSeer" |
| 31 | +const LINK = "https://github.com/kimiyoung/planetoid/raw/master/data" |
| 32 | +const DOCS = "https://github.com/kimiyoung/planetoid" |
| 33 | +const DATA = "ind.citeseer." .* ["x", "y", "tx", "allx", "ty", "ally", "graph", "test.index"] |
| 34 | + |
| 35 | +function __init__() |
| 36 | + register(DataDep( |
| 37 | + DEPNAME, |
| 38 | + """ |
| 39 | + Dataset: The $DEPNAME dataset. |
| 40 | + Website: $DOCS |
| 41 | + """, |
| 42 | + map(x -> "$LINK/$x", DATA), |
| 43 | + "7f7ec4df97215c573eee316de35754d89382011dfd9fb2b954a4a491057e3eb3", # if checksum omitted, will be generated by DataDeps |
| 44 | + # post_fetch_method = unpack |
| 45 | + )) |
| 46 | +end |
| 47 | + |
| 48 | +""" |
| 49 | + dataset(; dir=nothing, reverse_edges=true) |
| 50 | +
|
| 51 | +Retrieve the CiteSeer dataset. The output is a named tuple with fields |
| 52 | +```juliarepl |
| 53 | +julia> keys(CiteSeer.dataset()) |
| 54 | +(:node_features, :node_labels, :adjacency_list, :train_indices, :val_indices, :test_indices, :num_classes, :num_nodes, :num_edges, :directed) |
| 55 | +``` |
| 56 | +
|
| 57 | +In particular, `adjacency_list` is a vector of vector, |
| 58 | +where `adjacency_list[i]` will contain the neighbors of node `i` |
| 59 | +through outgoing edges. |
| 60 | +
|
| 61 | +If `reverse_edges=true`, the graph will contain |
| 62 | +the reverse of each edge and the graph will be undirected. |
| 63 | +
|
| 64 | +See also [`CiteSeer`](@ref). |
| 65 | +
|
| 66 | +## Usage Examples |
| 67 | +
|
| 68 | +```julia |
| 69 | +using MLDatasets: CiteSeer |
| 70 | +data = CiteSeer.dataset() |
| 71 | +train_labels = data.node_labels[data.train_indices] |
| 72 | +``` |
| 73 | +""" |
| 74 | +dataset(; dir=nothing, reverse_edges=true) = |
| 75 | + read_planetoid_data(DEPNAME, dir=dir, reverse_edges=reverse_edges) |
| 76 | + |
| 77 | + |
| 78 | +end #module |
| 79 | + |
0 commit comments