-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a00cbf0
commit 3002025
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"""Dataset Generators for 'text' transformers.""" | ||
|
||
from abc import ABC | ||
|
||
import numpy as np | ||
|
||
from rdt.performance.datasets.base import BaseDatasetGenerator | ||
from rdt.performance.datasets.utils import add_nans | ||
|
||
|
||
class RegexGeneratorGenerator(BaseDatasetGenerator, ABC): | ||
"""Base class for generators that generate ID data.""" | ||
|
||
SDTYPE = 'text' | ||
|
||
|
||
class RandomStringGenerator(RegexGeneratorGenerator): | ||
"""Generator that creates an array of random strings.""" | ||
|
||
@staticmethod | ||
def generate(num_rows): | ||
"""Generate a ``num_rows`` number of rows.""" | ||
categories = ['Alice', 'Bob', 'Charlie', 'Dave', 'Eve'] | ||
return np.random.choice(a=categories, size=num_rows) | ||
|
||
@staticmethod | ||
def get_performance_thresholds(): | ||
"""Return the expected threseholds.""" | ||
return { | ||
'fit': {'time': 1e-05, 'memory': 500.0}, | ||
'transform': {'time': 1e-05, 'memory': 500.0}, | ||
'reverse_transform': { | ||
'time': 2e-05, | ||
'memory': 1000.0, | ||
}, | ||
} | ||
|
||
|
||
class RandomStringNaNsGenerator(RegexGeneratorGenerator): | ||
"""Generator that creates an array of random strings with nans.""" | ||
|
||
@staticmethod | ||
def generate(num_rows): | ||
"""Generate a ``num_rows`` number of rows.""" | ||
return add_nans(RandomStringGenerator.generate(num_rows).astype('O')) | ||
|
||
@staticmethod | ||
def get_performance_thresholds(): | ||
"""Return the expected threseholds.""" | ||
return { | ||
'fit': {'time': 1e-05, 'memory': 400.0}, | ||
'transform': {'time': 1e-05, 'memory': 1000.0}, | ||
'reverse_transform': { | ||
'time': 2e-05, | ||
'memory': 1000.0, | ||
}, | ||
} |