> For the complete documentation index, see [llms.txt](https://seattle-university.gitbook.io/sdgne/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://seattle-university.gitbook.io/sdgne/auto-encoder/single-encoder-autoencoder.md).

# Single Encoder Autoencoder

The single-encoder autoencoder has a single encoder and multiple layers of decoder. This makes it suitable for simple data representations.

```python
from sdgne.datagenerator.autoencoder import SingleEncoderAutoencoder

minority_column_label = 'class'
minority_class_label = 0

synthesizer = SingleEncoderAutoencoder(dataset,
                               minority_column_label,
                               minority_class_label)
```

## Importing Heavy Decoder Autoencoder

```python
from sdgne.datagenerator.autoencoder import SingleEncoderAutoencoder
```

***

## Creating a synthesizer

```python
synthesizer = SingleEncoderAutoencoder(dataset,
                               minority_column_label,
                               minority_class_label)
```

### Parameters

<table data-header-hidden data-full-width="false"><thead><tr><th width="216.66666666666669">variable</th><th width="140">type</th><th>datatype</th><th>info</th></tr></thead><tbody><tr><td>dataset</td><td>required</td><td>pd.Dataframe</td><td>Represents a pandas data frame containing both, the original minority and the original majority data</td></tr><tr><td>minority_column_label</td><td>required</td><td>string</td><td>Represents the column label. Eg. 'class' , 'output'</td></tr><tr><td>minority_class_label</td><td>required</td><td>string</td><td>Represents the minority class label. Eg. '1', '0'</td></tr></tbody></table>

### Returns

An instance of class SingleEncoderAutoencoder.

## Network Architecture

Below is the network architecture for the Single Encoder Autoencoder. Here, the encoder has a single layer, with 20 nodes. The bottleneck is a single Dense layer with 16 nodes. The decoder has two layers with 18 and 20 nodes respectively. The decoder layer activation is sigmoid.

| encoder\_dense\_layers | 20      |
| ---------------------- | ------- |
| bottle\_neck           | 16      |
| decoder\_dense\_layers | 18, 20  |
| decoder\_activation    | sigmoid |

## Synthetic Data Generation

### data\_generator()

The data generator function generates synthetic data using the synthesizer. It has an option parameter  `no_of_syntetic_data.`

* If no\_of\_syntetic\_data is not defined, data\_generator by default generates the \`n\` number of synthetic data such that the majority data and minority datasets get balanced.
* If no\_of\_syntetic\_data is defined and the dataset is already balanced, data\_generator generates \
  2 \* Number of original minority data.
* If no\_of\_syntetic\_data is defined and the dataset is not balanced, it generates synthetic data equal to the value passed.

```python
synthesized_data = synthesizer.data_generator(no_of_syntetic_data)
```

### Parameters

<table data-header-hidden><thead><tr><th width="204">variable</th><th width="212">type</th><th>datatype</th><th>info</th></tr></thead><tbody><tr><td>no_of_syntetic_data</td><td>optional (default: None)</td><td>integer</td><td>Represents the number of synthetic data to be generated</td></tr></tbody></table>

### Returns

A pandas data frame that combines original data and synthetic data.

## Usage

`synthesizer.data_generator()`

`synthesizer.data_generator(no_of_syntetic_data=100)`

{% hint style="warning" %}
synthesize\_data returned from data\_generator( ) adds a column \`**synthetic\_data**\` to the data frame.&#x20;

\
df\['synthetic\_data'] = 0 : For original data\
df\['synthetic\_data'] = 1  : For Synthetic generated data&#x20;
{% endhint %}
