recbole.data.social_dataset

class recbole.data.dataset.social_dataset.SocialDataset(config, saved_dataset=None)[source]

Bases: recbole.data.dataset.dataset.Dataset

SocialDataset is based on Dataset, and load .net additionally.

It also provides several interfaces to transfer .net features into coo sparse matrix, csr sparse matrix, DGL.Graph or PyG.Data.

source_field

The same as config['SOURCE_ID_FIELD'].

Type

str

target_field

The same as config['TARGET_ID_FIELD'].

Type

str

net_feat

Internal data structure stores the network features. It’s loaded from file .net.

Type

pandas.DataFrame

net_graph(form='coo', value_field=None)[source]

Get graph or sparse matrix that describe relations between users.

For an edge of <src, tgt>, graph[src, tgt] = 1 if value_field is None, else graph[src, tgt] = self.net_feat[value_field][src, tgt].

Currently, we support graph in DGL and PyG, and two type of sparse matrices, coo and csr.

Parameters
  • form (str, optional) – Format of sparse matrix, or library of graph data structure. Defaults to coo.

  • value_field (str, optional) – edge attributes of graph, or data of sparse matrix, Defaults to None.

Returns

Graph / Sparse matrix of relations.