fix dataset loading script
Browse files14 unmodified lines1516171819202170 unmodified lines929394959697989924 unmodified lines1241251261271281291301311321331341351361371381392 unmodified lines14214314414514614714814915015115215315415515615715815916016116216316416514 unmodified lines"""TODO: A dataset of protein sequences, ligand SMILES and binding affinities."""import huggingface_hubimport pandas as pdimport osimport pyarrow.parquet as pqimport datasets70 unmodified linesfeatures = datasets.Features({"seq": datasets.Value("string"),"smiles_can": datasets.Value("string"),"neg_log10_affinity_M": datasets.Value("float"),"affinity": datasets.Value("float"),# These are the features of your dataset like images, labels ...}24 unmodified lines# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archivefiles = dl_manager.download_and_extract(_URLs)return [datasets.SplitGenerator(name=datasets.Split.TRAIN,# These kwargs will be passed to _generate_examplesgen_kwargs={"filepath": files["default"],},),datasets.SplitGenerator(name=datasets.Split.TRAIN+"_no_kras",# These kwargs will be passed to _generate_examplesgen_kwargs={"filepath": files["no_kras"],2 unmodified lines]def _generate_examples(self, filepath, split # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`):""" Yields examples as (key, example) tuples. """# This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.# The `key` is here for legacy reason (tfds) and is not important in itself.df = pd.read_parquet(filepath)for k, row in df.iterrows():yield k, {"seq": row["seq"],"smiles_can": row["smiles_can"],"neg_log10_affinity_M": row["neg_log10_affinity_M"],"affinity_uM": row["affinity_uM"],}def _generate_tables(self, filepath, split # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`):df = pq.read_table(filepath)yield split, df14 unmodified lines15161718192070 unmodified lines91929394959697989910024 unmodified lines1251261271281291301311321331341351361371381391401412 unmodified lines14414514614714814915015115215315415514 unmodified lines"""TODO: A dataset of protein sequences, ligand SMILES and binding affinities."""import huggingface_hubimport osimport pyarrow.parquet as pqimport datasets70 unmodified linesfeatures = datasets.Features({"seq": datasets.Value("string"),"smiles": datasets.Value("string"),"affinity_uM": datasets.Value("float"),"neg_log10_affinity_M": datasets.Value("float"),"smiles_can": datasets.Value("string"),"affinity": datasets.Value("float"),# These are the features of your dataset like images, labels ...}24 unmodified lines# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archivefiles = dl_manager.download_and_extract(_URLs)print(files)return [datasets.SplitGenerator(# These kwargs will be passed to _generate_examplesname=datasets.Split.TRAIN,gen_kwargs={'filepath': files["default"],},),datasets.SplitGenerator(name='no_kras',# These kwargs will be passed to _generate_examplesgen_kwargs={"filepath": files["no_kras"],2 unmodified lines]def _generate_tables(self, filepath):from pyarrow import fslocal = fs.LocalFileSystem()for i, f in enumerate([filepath]):print(f)yield i, pq.read_table(f,filesystem=local)
binding_affinity.py+14-24