haneulpark commited on
Commit
04fae7a
Β·
verified Β·
1 Parent(s): 19e0336

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +79 -1
README.md CHANGED
@@ -72,4 +72,82 @@ We utilized the raw data uploaded on [Github](https://github.com/LumosBio/MolDat
72
  3. Split the dataset (train, test, validation)
73
 
74
  If you would like to try these processes with the original dataset,
75
- please follow the instructions in the [Preprocessing Script.py](address) file located in our MolData repository.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  3. Split the dataset (train, test, validation)
73
 
74
  If you would like to try these processes with the original dataset,
75
+ please follow the instructions in the [Preprocessing Script.py](address) file located in our MolData repository.
76
+
77
+
78
+
79
+ ## Quickstart Usage
80
+
81
+ ### Load a dataset in python
82
+ Each subset can be loaded into python using the Huggingface [datasets](https://huggingface.co/docs/datasets/index) library.
83
+ First, from the command line install the `datasets` library
84
+
85
+ $ pip install datasets
86
+
87
+ then, from within python load the datasets library
88
+
89
+ >>> import datasets
90
+
91
+ and load the `MolData` datasets, e.g.,
92
+
93
+ >>> MolData = datasets.load_dataset("maomlab/MolData")
94
+ Downloading readme: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 5.23k/5.23k [00:00<00:00, 35.1kkB/s]
95
+ Downloading data: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 34.5k//34.5k/ [00:00<00:00, 155kB/s]
96
+ Downloading data: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 97.1k/97.1k [00:00<00:00, 587kB/s]
97
+ Generating test split: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 594/594 [00:00<00:00, 12705.92 examples/s]
98
+ Generating train split: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1788/1788 [00:00<00:00, 43895.91 examples/s]
99
+
100
+ and inspecting the loaded dataset
101
+
102
+ >>> MolData
103
+ MolData
104
+ DatasetDict({
105
+ test: Dataset({
106
+ features: ['SMILES', 'Y'],
107
+ num_rows: 594
108
+ })
109
+ train: Dataset({
110
+ features: ['SMILES', 'Y'],
111
+ num_rows: 1788
112
+ })
113
+ })
114
+
115
+ ### Use a dataset to train a model
116
+ One way to use the dataset is through the [MolFlux](https://exscientia.github.io/molflux/) package developed by Exscientia.
117
+ First, from the command line, install `MolFlux` library with `catboost` and `rdkit` support
118
+
119
+ pip install 'molflux[catboost,rdkit]'
120
+
121
+ then load, featurize, split, fit, and evaluate the catboost model
122
+
123
+ import json
124
+ from datasets import load_dataset
125
+ from molflux.datasets import featurise_dataset
126
+ from molflux.features import load_from_dicts as load_representations_from_dicts
127
+ from molflux.splits import load_from_dict as load_split_from_dict
128
+ from molflux.modelzoo import load_from_dict as load_model_from_dict
129
+ from molflux.metrics import load_suite
130
+
131
+ Split and evaluate the catboost model
132
+
133
+ split_dataset = load_dataset('maomlab/MolData', name = 'MolData')
134
+
135
+ split_featurised_dataset = featurise_dataset(
136
+ split_dataset,
137
+ column = "SMILES",
138
+ representations = load_representations_from_dicts([{"name": "morgan"}, {"name": "maccs_rdkit"}]))
139
+
140
+ model = load_model_from_dict({
141
+ "name": "cat_boost_regressor",
142
+ "config": {
143
+ "x_features": ['SMILES::morgan', 'SMILES::maccs_rdkit'],
144
+ "y_features": ['Y']}})
145
+
146
+ model.train(split_featurised_dataset["train"])
147
+ preds = model.predict(split_featurised_dataset["test"])
148
+
149
+ regression_suite = load_suite("regression")
150
+
151
+ scores = regression_suite.compute(
152
+ references=split_featurised_dataset["test"]['Y'],
153
+ predictions=preds["cat_boost_regressor::Y"])