API Reference
NoGANSynth Class and Methods
NoGAN Tabular Data Synthesizer generates synthetic data based on the multivariate binning technique performed on the Training or Real Dataset.
The main NoGAN Synthesizer Class
Source code in nogan_synthesizer\nogan_synthesizer.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
__init__(data, random_seed=None)
Initialize Data, no of objects, features, no of features and epsilon
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data |
DataFrame
|
Input Pandas DataFrame to be trained on |
required |
random_seed |
int
|
Random seed to be set before
operations. If set random seed is set using |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
Throws error if Input Dataset is not a Pandas DataFrame |
ValueError
|
Throws error if Input Dataset is empty |
TypeError
|
Throws error if non numerical columns are present in the Input Dataset |
ValueError
|
Throws error if there are special characters or space in column names of Input Dataset |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in nogan_synthesizer\nogan_synthesizer.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
fit(bins=None)
Function to create bins for each Data column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bins |
List
|
Bins List. Defaults to None. If it is None, then random bins between 50 to 100 will be assigned. Recommended to pass a tuned hyperparameter bins list |
None
|
Source code in nogan_synthesizer\nogan_synthesizer.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
generate_synthetic_data(no_of_rows=100, stretch_type=None, stretch=None, gen_random_seed=None, debug=False)
The main function which Generates the Synthetic Data. It calls random bin to create the multinomial bin counts. Then for each key, gets the lower and upper bound and generates an observation (random uniform value) between those bounds. Once the new observations list is generated, convert into a pandas synthetic dataframe and return.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
no_of_rows |
int
|
Row Count |
100
|
stretch_type |
List
|
List of values {"Gaussian","Uniform"}. Specifies
the Sampling Type for each column. Any value in List which is not |
None
|
stretch |
List
|
Specifies the stretching factor (scale) for each
column. Values between 0 and 1 with |
None
|
gen_random_seed |
int
|
Random seed to be set before
generation. It is set using |
None
|
debug |
bool
|
Flag to activate debugging. Default is False |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Generate Synthetic Pandas DataFrame |
Source code in nogan_synthesizer\nogan_synthesizer.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
Preprocessing
wrap_category_columns(data: pd.DataFrame, cat_cols: List[str])
Categorical Columns can be preprocessed using key-value pairs (called flag vector) of all categorical columns and collapsing all these columns into a single feature with integer values. wrap_category_columns implements this concept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data |
DataFrame
|
Pandas DataFrame |
required |
cat_cols |
List[str]
|
List of all categorical columns |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Throws error if Input Dataset is not a Pandas DataFrame |
ValueError
|
Throws error if Input Dataset is empty |
ValueError
|
Throws error if there are special characters or space in column names of Input Dataset |
TypeError
|
Throws error if 'cat_cols' is not a list |
ValueError
|
Throws error if 'cat_cols' is empty |
Returns:
| Name | Type | Description |
|---|---|---|
Tuple |
Tuple
|
Returns a Pandas DataFrame with all category columns wrapped & Dictionaries 'idx_to_key' and 'key_to_idx' which contain key-index, index-key pairs of flag vector |
Source code in nogan_synthesizer\preprocessing.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
unwrap_category_columns(data: pd.DataFrame, idx_to_key: dict, cat_cols: List[str])
All the collapsed categorical columns can also be expanded using the same flag vector created during wrapping process
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data |
DataFrame
|
Pandas DataFrame |
required |
idx_to_key |
dict
|
Dictionary that holds the key-index pairs of the flag vector |
required |
cat_cols |
List[str]
|
List of all categorical columns |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Throws error if Input Dataset is not a Pandas DataFrame |
ValueError
|
Throws error if Input Dataset is empty |
ValueError
|
Throws error if there are special characters or space in column names of Input Dataset |
TypeError
|
Throws error if 'cat_label' column is not present in the Input Dataset |
TypeError
|
Throws error if 'idx_to_key' is not a Dictionary |
ValueError
|
Throws error if 'idx_to_key' is empty |
TypeError
|
Throws error if 'cat_cols' is not a List |
ValueError
|
Throws error if 'cat_cols' is empty |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Pandas DataFrame with expanded Categorical Columns |
Source code in nogan_synthesizer\preprocessing.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |