request.deserialize_zipfile
¶
Request copies of relational datasets.
deserialize_zipfile(data_location, name, *, fold=1)
¶
Deserialize a zipfile, returning train and test sets.
Warning
This method is presented here to illustrate how data are unpacked from zip archives. The user is responsible for the structure of custom archives.
The srlearn/datasets
repository defines the assumptions for how datasets are stored.
Structure generally falls into two categories, where {{ name }}
represents the dataset (e.g. cora
, toy_cancer
):
{{ name }}
├── README.md
└── {{ name }}
├─── background.txt
├─── train ─── train_pos.txt, train_neg.txt, train_facts.txt
└─── test ──── test_pos.txt, test_neg.txt, test_facts.txt
... or:
{{ name }}
├── README.md
└── {{ name }}
├─── background.txt
├─── fold1
│ ├─── train ─── train_pos.txt, train_neg.txt, train_facts.txt
│ └─── test ──── test_pos.txt, test_neg.txt, test_facts.txt
├─── fold2
.
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_location |
str
|
Location of a zipfile. |
required |
name |
str
|
Name of the dataset. |
required |
fold |
int
|
In datasets with multiple folds, return this fold. This value is ignored if the data is not split into multiple folds. |
1
|
Returns:
Type | Description |
---|---|
Tuple[RelationalDataset, RelationalDataset]
|
Tuple of training and test sets. |
Examples:
This loads fold-2 of cora-v0.0.3 using an absolute path to the dataset, assuming that it is already downloaded:
from relational_datasets.request import deserialize_zipfile
train, test = deserialize_zipfile(
'/home/user/relational_datasets/cora_v0.0.3.zip',
'cora',
fold=2,
)
This can also load from the current directory:
from relational_datasets.request import deserialize_zipfile
train, test = deserialize_zipfile(
'./cora_v0.0.3.zip',
'cora',
)
Source code in relational_datasets/request.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|