# Feature Engine

{% embed url="<https://feature-engine.trainindata.com/en/latest/>" %}

{% embed url="<https://github.com/feature-engine/feature_engine>" %}

### Installation

From PyPI using pip:

```bash
pip install feature_engine
```

From Anaconda:

```bash
conda install -c conda-forge feature_engine
```

Or simply clone it:

```bash
git clone https://github.com/feature-engine/feature_engine.git
```

### Example Usage

Python 을 사용한 많은 ML 코드 작업에서 반복적으로 작성하게 되는 feature engineering 유틸 함수를 모아놓은 패키지. 예를 들어, 아래 코드는 일정 개수 미만의 label 을 취합해서 별도의 label 로 재정의 하는 코드. 이를 feature\_engine 패키지의 RareLabelEncoder 를 사용하여 코드 몇 줄로 해결할 수 있음.

```python
>>> import pandas as pd
>>> from feature_engine.encoding import RareLabelEncoder

>>> data = {'var_A': ['A'] * 10 + ['B'] * 10 + ['C'] * 2 + ['D'] * 1}
>>> data = pd.DataFrame(data)
>>> data['var_A'].value_counts()
```

```python
Out[1]:
A    10
B    10
C     2
D     1
Name: var_A, dtype: int64
```

```python
>>> rare_encoder = RareLabelEncoder(tol=0.10, n_categories=3)
>>> data_encoded = rare_encoder.fit_transform(data)
>>> data_encoded['var_A'].value_counts()
```

```python
Out[2]:
A       10
B       10
Rare     3
Name: var_A, dtype: int64
```

Find more examples in our [Jupyter Notebook Gallery](https://nbviewer.org/github/feature-engine/feature-engine-examples/tree/main/) or in the [documentation](https://feature-engine.trainindata.com/).
