Feature Engine
Feature engineering package with sklearn like functionality
Installation
From PyPI using pip:
pip install feature_engineFrom Anaconda:
conda install -c conda-forge feature_engineOr simply clone it:
git clone https://github.com/feature-engine/feature_engine.gitExample Usage
Python ์ ์ฌ์ฉํ ๋ง์ ML ์ฝ๋ ์์ ์์ ๋ฐ๋ณต์ ์ผ๋ก ์์ฑํ๊ฒ ๋๋ feature engineering ์ ํธ ํจ์๋ฅผ ๋ชจ์๋์ ํจํค์ง. ์๋ฅผ ๋ค์ด, ์๋ ์ฝ๋๋ ์ผ์ ๊ฐ์ ๋ฏธ๋ง์ label ์ ์ทจํฉํด์ ๋ณ๋์ label ๋ก ์ฌ์ ์ ํ๋ ์ฝ๋. ์ด๋ฅผ feature_engine ํจํค์ง์ RareLabelEncoder ๋ฅผ ์ฌ์ฉํ์ฌ ์ฝ๋ ๋ช ์ค๋ก ํด๊ฒฐํ ์ ์์.
>>> 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()Out[1]:
A 10
B 10
C 2
D 1
Name: var_A, dtype: int64>>> rare_encoder = RareLabelEncoder(tol=0.10, n_categories=3)
>>> data_encoded = rare_encoder.fit_transform(data)
>>> data_encoded['var_A'].value_counts()Out[2]:
A 10
B 10
Rare 3
Name: var_A, dtype: int64Find more examples in our Jupyter Notebook Gallery or in the documentation.
Last updated