Search-Convolutional Neural Networks
Project description
SCNN
====
An implementation of search-convolutional neural networks [1], a new model for graph-structured data.
Installation
------------
Using pip:
pip install scnn
Usage
-----
import numpy as np
from scnn import SCNN, data
from sklearn.metrics import f1_score
# Parse the cora dataset and return an adjacency matrix, a design matrix, and a 1-hot label matrix
A, X, Y = data.parse_cora()
# Construct array indices for the training, validation, and test sets
n_nodes = A.shape[0]
indices = np.arange(n_nodes)
train_indices = indices[:n_nodes // 3]
valid_indices = indices[n_nodes // 3:(2* n_nodes) // 3]
test_indices = indices[(2* n_nodes) // 3:]
# Instantiate an SCNN and fit it to cora
scnn = SCNN()
scnn.fit(A, X, Y, train_indices=train_indices, valid_indices=valid_indices)
# Predict labels for the test set
preds = scnn.predict(X, test_indices)
actuals = np.argmax(Y[test_indices,:], axis=1)
# Display performance
print 'F score: %.4f' % (f1_score(actuals, preds))
References
----------
[1] http://arxiv.org/abs/1511.02136
====
An implementation of search-convolutional neural networks [1], a new model for graph-structured data.
Installation
------------
Using pip:
pip install scnn
Usage
-----
import numpy as np
from scnn import SCNN, data
from sklearn.metrics import f1_score
# Parse the cora dataset and return an adjacency matrix, a design matrix, and a 1-hot label matrix
A, X, Y = data.parse_cora()
# Construct array indices for the training, validation, and test sets
n_nodes = A.shape[0]
indices = np.arange(n_nodes)
train_indices = indices[:n_nodes // 3]
valid_indices = indices[n_nodes // 3:(2* n_nodes) // 3]
test_indices = indices[(2* n_nodes) // 3:]
# Instantiate an SCNN and fit it to cora
scnn = SCNN()
scnn.fit(A, X, Y, train_indices=train_indices, valid_indices=valid_indices)
# Predict labels for the test set
preds = scnn.predict(X, test_indices)
actuals = np.argmax(Y[test_indices,:], axis=1)
# Display performance
print 'F score: %.4f' % (f1_score(actuals, preds))
References
----------
[1] http://arxiv.org/abs/1511.02136
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
scnn-1.3.1.tar.gz
(20.0 kB
view details)
File details
Details for the file scnn-1.3.1.tar.gz.
File metadata
- Download URL: scnn-1.3.1.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbd28586ea75dbfa3d3f359a914f54e99bbbe6b7ce37fdd0cb88dfd67176aedd
|
|
| MD5 |
469b2bde05e85eb832f5af4ac4ebbc93
|
|
| BLAKE2b-256 |
112f4d239db4d06abfecc4333834644d837c2724ddf72214d0c40ed7346fc826
|