시작하기무료로 시작하기

신장 질환 케이스 스터디 II: Feature Union

수치형과 범주형 열을 각각 별도로 대치(impute)했으므로, 이제 scikit-learn의 FeatureUnion을 사용해 그 결과를 이어 붙이세요. 각 결과는 두 개의 개별 변환기 객체인 numeric_imputation_mappercategorical_imputation_mapper에 담겨 있습니다.

이미 Machine Learning with the Experts: School Budgets에서 FeatureUnion을 보셨을 수도 있어요. 파이프라인과 마찬가지로 (string, transformer) 형태의 튜플 리스트를 전달해야 하며, 각 튜플의 앞부분은 변환기의 이름입니다.

이 연습은 강의의 일부입니다

XGBoost로 익히는 Extreme Gradient Boosting

강의 보기

연습 안내

  • sklearn.pipeline에서 FeatureUnion을 가져오세요.
  • FeatureUnion()을 사용해 numeric_imputation_mappercategorical_imputation_mapper의 결과를 결합하세요. 각각의 이름은 "num_mapper", "cat_mapper"로 지정합니다.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Import FeatureUnion
from sklearn.pipeline import FeatureUnion

# Combine the numeric and categorical transformations
numeric_categorical_union = ____([
                                          ("____", ____),
                                          ("____", ____)
                                         ])
코드 편집 및 실행