Update sections/07_practical_recommendations.md
Browse files- sections/07_practical_recommendations.md +144 -142
sections/07_practical_recommendations.md
CHANGED
|
@@ -14,192 +14,194 @@
|
|
| 14 |
* dataset3 \# ΔG measurements
|
| 15 |
* dataset3\_single \# ΔG measurements of single-point mutants with ThermoMPNN (Dieckhaus, et al., 2024\) splits
|
| 16 |
* dataset3\_single\_cv \# 5-fold cross validation of ΔG measurements of single-point mutants with ThermoMPNN (Dieckhaus, et al., 2024\) splits
|
| 17 |
-
* To load a specific subdataset:
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
#### Example: One .csv file dataset
|
| 21 |
|
| 22 |
One table named `outcomes.csv` to be pushed to HuggingFace dataset repository `maomlab/example_dataset`
|
| 23 |
First load the dataset locally then push it to the hub:
|
| 24 |
|
| 25 |
-
import datasets
|
| 26 |
-
dataset
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
-
dataset.
|
| 32 |
|
| 33 |
This will create the following files in the repo
|
| 34 |
|
| 35 |
-
data/
|
| 36 |
-
|
| 37 |
|
| 38 |
and add the following to the header of README.md
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
configs:
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
|
| 58 |
to load these data from HuggingFace
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
#### Example: train/valid/test split .csv files
|
| 63 |
|
| 64 |
Three tables train.csv, valid.csv, test.csv to be pushed to HuggingFace dataset repository `maomlab/example_dataset`
|
| 65 |
load the three splits into one dataset and push it to the hub:
|
| 66 |
|
| 67 |
-
import datasets
|
| 68 |
-
dataset
|
| 69 |
-
'csv',
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
'train': 'train.csv',
|
| 73 |
-
'valid': 'valid.csv',
|
| 74 |
-
'test': 'test.csv'},
|
| 75 |
-
|
| 76 |
|
| 77 |
-
dataset.
|
| 78 |
|
| 79 |
This will create the following files in the repo
|
| 80 |
|
| 81 |
-
data/
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
|
| 86 |
and add the following to the header of the README.md
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
configs:
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
|
| 116 |
to load these data from HuggingFace
|
| 117 |
|
| 118 |
-
|
| 119 |
|
| 120 |
#### Example: sub-datasets
|
| 121 |
|
| 122 |
If you have different related datasets (`dataset1.csv`, `dataset2.csv`, `dataset3.csv`) that should go into a single repository but contain different types of data so they aren't just splits of the same dataset, then load each dataset separately and push it to the hub with a given config name.
|
| 123 |
|
| 124 |
import datasets
|
| 125 |
-
dataset1
|
| 126 |
-
dataset2
|
| 127 |
-
dataset3
|
| 128 |
|
| 129 |
-
dataset1.
|
| 130 |
-
dataset2.
|
| 131 |
-
dataset3.
|
| 132 |
|
| 133 |
This will create the following files in the repo
|
| 134 |
|
| 135 |
-
dataset1/
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
dataset2/
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
dataset3/
|
| 142 |
-
|
| 143 |
-
|
| 144 |
|
| 145 |
and add the following to the header of the README.md
|
| 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 |
-
configs:
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
|
| 198 |
to load these datasets from HuggingFace
|
| 199 |
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
|
| 204 |
|
| 205 |
### **Format of a dataset**
|
|
@@ -209,7 +211,7 @@ The columns should follow typical database design guidelines
|
|
| 209 |
|
| 210 |
* Identifier columns
|
| 211 |
* sequential key
|
| 212 |
-
* For example:
|
| 213 |
* primary key
|
| 214 |
* single column that uniquely identify each row
|
| 215 |
* distinct for every row
|
|
@@ -218,7 +220,7 @@ The columns should follow typical database design guidelines
|
|
| 218 |
* composite key
|
| 219 |
* A set of columns that uniquely identify each row
|
| 220 |
* Either hierarchical or complementary ids that characterize the observation
|
| 221 |
-
* For example, for an observation of mutations, the (
|
| 222 |
* additional/foreign key identifiers
|
| 223 |
* identifiers to link the observation with other data
|
| 224 |
* For example
|
|
@@ -272,7 +274,7 @@ The columns should follow typical database design guidelines
|
|
| 272 |
* Often very fast to read/write, but may not be robust for across language/OS versions
|
| 273 |
* Not easily interoperable across programming languages
|
| 274 |
* In memory formats
|
| 275 |
-
* R data.frame/dplyr::tibble
|
| 276 |
* Widely used format for R data science
|
| 277 |
* Out of the box faster for tidyverse data manipulation, split-apply-combine workflows
|
| 278 |
* Python pandas DataFrame
|
|
@@ -292,5 +294,5 @@ Recommendations
|
|
| 292 |
* Smaller than .csv/.tsv
|
| 293 |
* Robust open source libraries in major language can read and write .parquet files faster than .csv/.tsv
|
| 294 |
* In memory
|
| 295 |
-
* Use dplyr::tibble / pandas DataFrame for data science tables
|
| 296 |
* Use numpy array / pytorch dataset for machine learning
|
|
|
|
| 14 |
* dataset3 \# ΔG measurements
|
| 15 |
* dataset3\_single \# ΔG measurements of single-point mutants with ThermoMPNN (Dieckhaus, et al., 2024\) splits
|
| 16 |
* dataset3\_single\_cv \# 5-fold cross validation of ΔG measurements of single-point mutants with ThermoMPNN (Dieckhaus, et al., 2024\) splits
|
| 17 |
+
* To load a specific subdataset:
|
| 18 |
+
```
|
| 19 |
+
datasets.load_dataset(path = "RosettaCommons/MegaScale", name = "dataset1", data_dir = "dataset1")
|
| 20 |
+
```
|
| 21 |
|
| 22 |
#### Example: One .csv file dataset
|
| 23 |
|
| 24 |
One table named `outcomes.csv` to be pushed to HuggingFace dataset repository `maomlab/example_dataset`
|
| 25 |
First load the dataset locally then push it to the hub:
|
| 26 |
|
| 27 |
+
import datasets
|
| 28 |
+
dataset = datasets.load_dataset(
|
| 29 |
+
"csv",
|
| 30 |
+
data_files ="outcomes.csv",
|
| 31 |
+
keep_in_memory = True)
|
| 32 |
|
| 33 |
+
dataset.push_to_hub(repo_id = "`maomlab/example_dataset`")
|
| 34 |
|
| 35 |
This will create the following files in the repo
|
| 36 |
|
| 37 |
+
data/
|
| 38 |
+
train-00000-of-00001.parquet
|
| 39 |
|
| 40 |
and add the following to the header of README.md
|
| 41 |
|
| 42 |
+
dataset_info:
|
| 43 |
+
features:
|
| 44 |
+
- name: id
|
| 45 |
+
dtype: int64
|
| 46 |
+
- name: value
|
| 47 |
+
dtype: int64
|
| 48 |
+
splits:
|
| 49 |
+
- name: train
|
| 50 |
+
num_bytes: 64
|
| 51 |
+
num_examples: 4
|
| 52 |
+
download_size: 1332
|
| 53 |
+
dataset_size: 64
|
| 54 |
+
configs:
|
| 55 |
+
- config_name: default
|
| 56 |
+
data_files:
|
| 57 |
+
- split: train
|
| 58 |
+
path: data/train-*
|
| 59 |
|
| 60 |
to load these data from HuggingFace
|
| 61 |
|
| 62 |
+
dataset = datasets.load_dataset("maomlab/example_dataset")
|
| 63 |
|
| 64 |
#### Example: train/valid/test split .csv files
|
| 65 |
|
| 66 |
Three tables train.csv, valid.csv, test.csv to be pushed to HuggingFace dataset repository `maomlab/example_dataset`
|
| 67 |
load the three splits into one dataset and push it to the hub:
|
| 68 |
|
| 69 |
+
import datasets
|
| 70 |
+
dataset = datasets.load_dataset(
|
| 71 |
+
'csv',
|
| 72 |
+
data_dir = "/tmp",
|
| 73 |
+
data_files = {
|
| 74 |
+
'train': 'train.csv',
|
| 75 |
+
'valid': 'valid.csv',
|
| 76 |
+
'test': 'test.csv'},
|
| 77 |
+
keep_in_memory = True)
|
| 78 |
|
| 79 |
+
dataset.push_to_hub(repo_id = "maomlab/example_dataset")
|
| 80 |
|
| 81 |
This will create the following files in the repo
|
| 82 |
|
| 83 |
+
data/
|
| 84 |
+
train-00000-of-00001.parquet
|
| 85 |
+
valid-00000-of-00001.parquet
|
| 86 |
+
test-00000-of-00001.parquet
|
| 87 |
|
| 88 |
and add the following to the header of the README.md
|
| 89 |
|
| 90 |
+
dataset_info:
|
| 91 |
+
features:
|
| 92 |
+
- name: id
|
| 93 |
+
dtype: int64
|
| 94 |
+
- name: value
|
| 95 |
+
dtype: int64
|
| 96 |
+
splits:
|
| 97 |
+
- name: train
|
| 98 |
+
num_bytes: 64
|
| 99 |
+
num_examples: 4
|
| 100 |
+
- name: valid
|
| 101 |
+
num_bytes: 64
|
| 102 |
+
num_examples: 4
|
| 103 |
+
- name: test
|
| 104 |
+
num_bytes: 64
|
| 105 |
+
num_examples: 4
|
| 106 |
+
download_size: 3996
|
| 107 |
+
dataset_size: 192
|
| 108 |
+
configs:
|
| 109 |
+
- config_name: default
|
| 110 |
+
data_files:
|
| 111 |
+
- split: train
|
| 112 |
+
path: data/train-*
|
| 113 |
+
- split: valid
|
| 114 |
+
path: data/valid-*
|
| 115 |
+
- split: test
|
| 116 |
+
path: data/test-*
|
| 117 |
|
| 118 |
to load these data from HuggingFace
|
| 119 |
|
| 120 |
+
dataset = datasets.load_dataset("maomlab/example_dataset")
|
| 121 |
|
| 122 |
#### Example: sub-datasets
|
| 123 |
|
| 124 |
If you have different related datasets (`dataset1.csv`, `dataset2.csv`, `dataset3.csv`) that should go into a single repository but contain different types of data so they aren't just splits of the same dataset, then load each dataset separately and push it to the hub with a given config name.
|
| 125 |
|
| 126 |
import datasets
|
| 127 |
+
dataset1 = datasets.load_dataset('csv', data_files = '/tmp/dataset1.csv', keep_in\_memory = True)
|
| 128 |
+
dataset2 = datasets.load_dataset('csv', data_files = '/tmp/dataset2.csv', keep_in\_memory = True)
|
| 129 |
+
dataset3 = datasets.load_dataset('csv', data_files = '/tmp/dataset3.csv', keep_in\_memory = True)
|
| 130 |
|
| 131 |
+
dataset1.push_to_hub(repo_id = "`maomlab/example_dataset`", config_name = 'dataset1', data_dir = 'dataset1/data')
|
| 132 |
+
dataset2.push_to_hub(repo_id = "`maomlab/example_dataset`", config_name = 'dataset2', data_dir = 'dataset2/data')
|
| 133 |
+
dataset3.push_to_hub(repo_id = "`maomlab/example_dataset`", config_name = 'dataset3', data_dir = 'dataset3/data')
|
| 134 |
|
| 135 |
This will create the following files in the repo
|
| 136 |
|
| 137 |
+
dataset1/
|
| 138 |
+
data/
|
| 139 |
+
train-00000-of-00001.parquet
|
| 140 |
+
dataset2/
|
| 141 |
+
data/
|
| 142 |
+
train-00000-of-00001.parquet
|
| 143 |
+
dataset3/
|
| 144 |
+
data/
|
| 145 |
+
train-00000-of-00001.parquet
|
| 146 |
|
| 147 |
and add the following to the header of the README.md
|
| 148 |
|
| 149 |
+
dataset_info:
|
| 150 |
+
- config_name: dataset1
|
| 151 |
+
features:
|
| 152 |
+
- name: id
|
| 153 |
+
dtype: int64
|
| 154 |
+
- name: value1
|
| 155 |
+
dtype: int64
|
| 156 |
+
splits:
|
| 157 |
+
- name: train
|
| 158 |
+
num_bytes: 64
|
| 159 |
+
num_examples: 4
|
| 160 |
+
download_size: 1344
|
| 161 |
+
dataset_size: 64
|
| 162 |
+
- config_name: dataset2
|
| 163 |
+
features:
|
| 164 |
+
- name: id
|
| 165 |
+
dtype: int64
|
| 166 |
+
- name: value2
|
| 167 |
+
dtype: int64
|
| 168 |
+
splits:
|
| 169 |
+
- name: train
|
| 170 |
+
num_bytes: 64
|
| 171 |
+
num_examples: 4
|
| 172 |
+
download_size: 1344
|
| 173 |
+
dataset_size: 64
|
| 174 |
+
- config_name: dataset3
|
| 175 |
+
features:
|
| 176 |
+
- name: id
|
| 177 |
+
dtype: int64
|
| 178 |
+
- name: value3
|
| 179 |
+
dtype: int64
|
| 180 |
+
splits:
|
| 181 |
+
- name: train
|
| 182 |
+
num_bytes: 64
|
| 183 |
+
num_examples: 4
|
| 184 |
+
download_size: 1344
|
| 185 |
+
dataset_size: 64
|
| 186 |
+
configs:
|
| 187 |
+
- config_name: dataset1
|
| 188 |
+
data_files:
|
| 189 |
+
- split: train
|
| 190 |
+
path: dataset1/data/train-*
|
| 191 |
+
- config_name: dataset2
|
| 192 |
+
data_files:
|
| 193 |
+
- split: train
|
| 194 |
+
path: dataset2/data/train-*
|
| 195 |
+
- config_name: dataset3
|
| 196 |
+
data_files:
|
| 197 |
+
- split: train
|
| 198 |
+
path: dataset3/data/train-*
|
| 199 |
|
| 200 |
to load these datasets from HuggingFace
|
| 201 |
|
| 202 |
+
dataset1 = datasets.load_dataset("maomlab/example_dataset", name = 'dataset1', data_dir = 'dataset1')
|
| 203 |
+
dataset2 = datasets.load_dataset("maomlab/example_dataset", name = 'dataset2', data_dir = 'dataset2')
|
| 204 |
+
dataset3 = datasets.load_dataset("maomlab/example_dataset", name = 'dataset3', data_dir = 'dataset3')
|
| 205 |
|
| 206 |
|
| 207 |
### **Format of a dataset**
|
|
|
|
| 211 |
|
| 212 |
* Identifier columns
|
| 213 |
* sequential key
|
| 214 |
+
* For example: `[1, 2, 3, ...]`
|
| 215 |
* primary key
|
| 216 |
* single column that uniquely identify each row
|
| 217 |
* distinct for every row
|
|
|
|
| 220 |
* composite key
|
| 221 |
* A set of columns that uniquely identify each row
|
| 222 |
* Either hierarchical or complementary ids that characterize the observation
|
| 223 |
+
* For example, for an observation of mutations, the (`structure_id`, `residue_id`, `mutation_aa`) is a unique identifier
|
| 224 |
* additional/foreign key identifiers
|
| 225 |
* identifiers to link the observation with other data
|
| 226 |
* For example
|
|
|
|
| 274 |
* Often very fast to read/write, but may not be robust for across language/OS versions
|
| 275 |
* Not easily interoperable across programming languages
|
| 276 |
* In memory formats
|
| 277 |
+
* R `data.frame`/`dplyr::tibble`
|
| 278 |
* Widely used format for R data science
|
| 279 |
* Out of the box faster for tidyverse data manipulation, split-apply-combine workflows
|
| 280 |
* Python pandas DataFrame
|
|
|
|
| 294 |
* Smaller than .csv/.tsv
|
| 295 |
* Robust open source libraries in major language can read and write .parquet files faster than .csv/.tsv
|
| 296 |
* In memory
|
| 297 |
+
* Use `dplyr::tibble` / pandas DataFrame for data science tables
|
| 298 |
* Use numpy array / pytorch dataset for machine learning
|