# Storing custom attribute in IterableDataset

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fstoring-custom-attribute-in-iterabledataset%2F54725%3E%5C
**Category:** 🤗Datasets\
**Created:** [September 12, 2023, 7:33pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fstoring-custom-attribute-in-iterabledataset%2F54725 "2023-09-12T19:33:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffliu-LL](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jeffliu-LL](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjeffliu-LL)%5C
**Post date:** [September 12, 2023, 7:33pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fstoring-custom-attribute-in-iterabledataset%2F54725%2F1 "2023-09-12T19:33:23Z")

</div>

I’d like to store some metadata in a streaming IterableDataset which would be expensive to compute on the fly - for example, the total number of positive examples of each class. Is there a way for me to store that in a custom dataset without including it in a feature that is returned every example?

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmariosasko)%5C
**Post date:** [September 13, 2023, 5:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fstoring-custom-attribute-in-iterabledataset%2F54725%2F2 "2023-09-13T17:05:54Z")

</div>

Storing metadata is not natively supported, so one option is to assign this metadata to the dataset object (`iterable_ds.metadata` = …) and re-assign it after each operation (the dataset ops are immutable and return a new dataset object)

---

<div class="post-metadata">

**Author:** ![jeffliu-LL](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jeffliu-LL](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjeffliu-LL)%5C
**Post date:** [September 13, 2023, 6:27pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fstoring-custom-attribute-in-iterabledataset%2F54725%2F3 "2023-09-13T18:27:50Z")

</div>

Thanks for the response. It seems that if the attribute can’t be assigned at creation and does not persist through operations, I might as well keep track of it separately from the dataset object.
