> For the complete documentation index, see [llms.txt](https://ensemble-ai.gitbook.io/ensemble-ai-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ensemble-ai.gitbook.io/ensemble-ai-api-docs/dark-matter/integrations/on-premise-api/ensemble-core-1.0/generator.md).

# Generator

The Generator object learns to generate enhanced features that approximate unobserved confounder variables.  This class is designed to intake and generate various data types, including continuous and discrete variables.

**Parameters:**&#x20;

* `in_size`: int

  &#x20;          Input dimension. Number of variables to be transformed. Value must be >= 1.
* `out_size`: int

  &#x20;          Output dimension. Number of variables to predict. Value must be >= 1.
* `n_features`: int, *default=2*

  &#x20;          Number of enhanced or generated features. Value must be >= 1.
* `datatype`: str, *default="continuous"*

  &#x20;          The generated data type. This can be "continuous" or "categorical".&#x20;
* `explainable`: bool, default=False

  &#x20;          If set to True, output will be pandas.DataFrame and include column names of origin variable.

**Methods:**

* [`fit(X, y)`](/ensemble-ai-api-docs/dark-matter/integrations/on-premise-api/ensemble-core-1.0/generator/fit.md)

  &#x20;          Fit the Generator object to inputs and target variables using Ensemble's proprietary Feature Enhancement algorithm to learn enhanced statistical properties.&#x20;
* [`generate(X)`](/ensemble-ai-api-docs/dark-matter/integrations/on-premise-api/ensemble-core-1.0/generator/generate.md)

  &#x20;          Apply fitted Generator object to inputs to get enhanced features.&#x20;

### Example:

```python
import ensemble_core as ec

# Login
user = ec.User()
user.login(username="YOUR_USERNAME", password="YOUR_PASSWORD", token="YOUR_TOKEN")

# Example data
X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
y = np.dot(X, np.array([1, 2])) + 3

# Initialize generator with your desired specifications
generator = ec.Generator(in_size=2, out_size=1, n_features=5)

# Run Feature Enhancement
generator.fit(X, y)           

# Generate new and enhanced features
enhanced_X = generator.generate(X)  
```
