Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HyperTransformer: Memory usage increase when reverse_transform is called #156

Closed
pvk-developer opened this issue Mar 11, 2021 · 0 comments · Fixed by #157
Closed

HyperTransformer: Memory usage increase when reverse_transform is called #156

pvk-developer opened this issue Mar 11, 2021 · 0 comments · Fixed by #157
Assignees
Labels
bug Something isn't working
Milestone

Comments

@pvk-developer
Copy link
Member

pvk-developer commented Mar 11, 2021

Environment Details

  • RDT version: 0.4.0
  • Python version: Python 3.8
  • Operating System: PopOS! 20.04

Error Description

When trying to reverse_transform categorical data using rdt.transformers.OneHotEncoder having more than 500 categories the memory usage is being increased drastically.

Steps to reproduce

In [1]: import pandas as pd
In [2]: data = pd.DataFrame({
   ...:     'categorical': [str(x) for x in range(600)] * 10
   ...: })

In [3]: from rdt.hyper_transformer import HyperTransformer 
In [4]: from rdt.transformers import OneHotEncodingTransformer
In [5]: ht = HyperTransformer(transformers={'categorical': OneHotEncodingTransformer()})
In [6]: ht.fit(data)
In [7]: transform = ht.transform(data)
In [8]: reverse = ht.reverse_transform(transform)

Screenshot from 2021-03-11 18-30-47

On the image can be observed the memory consumption which increases when reverse_transform is run.

This issue was originally raised on sdv-dev/SDV#304

Cause

The main cause of this memory increase is that using pandas.DataFrame.pop duplicates the data frame view and increases the memory used by the application instead of reducing it. When we try to pop more than 500 columns we end up creating 500+ views of the data frame which ends up increasing the memory drastically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants