# Dataset labels with more than one identifier

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-labels-with-more-than-one-identifier%2F137218%3E%5C
**Category:** Beginners\
**Created:** [January 24, 2025, 8:14pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-labels-with-more-than-one-identifier%2F137218 "2025-01-24T20:14:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dconnell](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@dconnell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdconnell)%5C
**Post date:** [January 24, 2025, 8:14pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-labels-with-more-than-one-identifier%2F137218%2F1 "2025-01-24T20:14:39Z")

</div>

I am creating a dataset that uses genes as labels. I would like to store two sets of label identifiers / names with the datasets. Is there a way to do this?

This would be multiple identifiers for the same labels rather than two separate sets of labels attached to the dataset. For each gene, I have NCBI’s gene IDs and gene symbols. Gene IDs are useful for linking to other datasets but are less human friendly (i.e. I have no idea what gene 294928 is). Gene symbols are more meaningful but less formalized, the same gene ID may be associated with multiple symbols and, annoyingly, the same symbol can be used for multiple IDs.

I am using a `Sequence` of `ClassLabel`s to store the labels. I think deduplicated symbols makes more sense here since they are naturally strings and names of labels whereas gene IDs are integers. I could use the gene IDs as the label values, but these are non-sequential so I think it’s easier to create an index from the gene IDs to prevent large sequences of always empty columns when working with the labels as a binary array.

Ideally, I would like to add the gene IDs as an array that is stored in the dataset as metadata. So the gene ID of label index `i` would be obtained as `gene_ids[i]`. Any thoughts on the best way to store this extra information? I see I can set the name value of ClassLabel to arbitrary data types (potentially `zip(gene_ids, symbols)`) but that seems non-intuiteve and likely not supposed to be allowed.

---

<div class="post-metadata">

**Author:** ![dconnell](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@dconnell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdconnell)%5C
**Post date:** [January 24, 2025, 8:21pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-labels-with-more-than-one-identifier%2F137218%2F2 "2025-01-24T20:21:26Z")

</div>

I can attach arbitrary attributes to `ClassLabel.feature`. Would that be a reasonable place to stores these data? Something like `datasetfeature["labels"].feature.gene_ids = gene_ids`? Where the `"labels"` feature would be a `Sequence` of `ClassLabel`s.

Would this be lost when uploading to the dataset hub?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [January 25, 2025, 6:54am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-labels-with-more-than-one-identifier%2F137218%2F3 "2025-01-25T06:54:03Z")

</div>

Basically, I don’t think anything you upload will be lost, but it’s better to have it in a correct or easy-to-use data set format…🤔  
There is a way to output Python dict in JSON and upload it separately, but it’s not smart.  
Is there a better way? @lhoestq

> [@How to build a multi-label & multi-class dataset correctly?](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-build-a-multi-label-multi-class-dataset-correctly%2F76042)%3A
>
> I am unsure how to proceed creating a [Dataset](https://huggingface.co/docs/datasets/en/package_reference/main_classes#datasets.Dataset) with multiple labels and classes where the classes are not the same for the different labels. A multi-label example is shared [here](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcould-someone-please-explain-how-to-make-a-multi-label-dataset-from-csv%2F18534%2F2)%2C but the classes are always either 0 or 1. My task is slightly different. To illustrate what I mean, take this dataset: text (X) region (y₁) weather (y₂) sentiment (y₃) ‘The Taj Mahal was beautiful, even in monsoon season’ ‘asia’ ‘rain’ ‘positive’ ‘Surprisingly warm in London with blue skies…’ ‘europe’ ‘sun’ ‘…

---

<div class="post-metadata">

**Author:** ![dconnell](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@dconnell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdconnell)%5C
**Post date:** [January 25, 2025, 11:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdataset-labels-with-more-than-one-identifier%2F137218%2F4 "2025-01-25T23:34:16Z")

</div>

I ended up saving the symbols list with JSON for now. It works fine for my use case since I’m already converting the `dataset` to my data loader and can add reading in the symbols to the conversion function. But if anyone else were to use the dataset it would be on them to either find their own symbols or manually read them in.

Also adding additional attributes to `ClassLabel`’s features didn’t work since the `save_to_disk` method didn’t know to look for them.
