Feature Engineering
- very important process in the field of data analysis and machine learning
- data scientists spend most of their time on data cleaning <- the data looks pretty messy
- 도메인 지식과 창의성을 바탕으로
- 데이터셋에 존재하는 Feature들을 재조합하여 새로운 Feature를 만드는 것
- 더 좋은 퍼포먼스를 위하여
- 새롭고, 더 의미있는 패턴을 제공하는 것이 궁긍적인 목적
- example
-- Outlier Detection
-- Handling missing values
-- One Hot Encoding
DataFrame
- 테이블 형태의 데이터
- tidy 형태 권장
-- 하나의 행에는 하나의 데이터 혹은 관측치
-- 하나의 열에는 하나의 feature를 기반으로 저장
-- 다른 라이브러리와의 호환성을 위해서
NaN(Not a Number)
- pandas에서 결측치를 표현하는 방법
- 파이썬에서 float type
문자를 숫자로 바꾸는 프로세스
- 1. 숫자가 아닌 부분 제거
- 2. 문자를 숫자로 형변환
testString = '25,970'
testString = testString.replace(',','')
int(testString)
- 함수 사용
# 입력된 문자열에 대해서 숫자로 바꾸는 작업을 하는 함수 작성
def toInt(string):
return int(string.replace(',',''))
- coumn 단위로 함수 사용
-- 1. apply 안에 들어갈 함수(toInt) 선언
-- 2. column에 apply 적용
df['자산2'] = df['자산'].apply(toInt)