- 특정 data type을 가진 열을 골라내고 싶을 때: data.select_dtypes(include='',exclude='')
train.select_dtypes(include=['float64'])
DataFrame.select_dtypes(include=None, exclude=None) 의 구조에서
include = ['float64']
include = ['int64']
-> 숫자형은 [ ] 를 이용해서 표현
include = np.number (or 'number')
include = np.datetime64 (or 'datetime')
include = 'category'
include = 'bool'
-> 숫자, 날짜, bool, category등 특정 type을 표현할 때는 ' ' 혹은 numpy를 이용해서 표현
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.select_dtypes.html
- from sklearn.feature_selection import mutual_info_classif
sklearn.feature_selection.mutual_info_classif(X, y, *, discrete_features='auto', n_neighbors=3, copy=True, random_state=None)
각 변수간의 의존성을 파악할 때 사용 (0에 가까울 수록 독립적)
X: Feature matrixy: target vector
여기서 반환하는 값은 Mutual information (MI)인데, 이는 확률 이론에서 '두 랜덤변수 간의 상호 종속적인 정보의 양'을 의미한다. sklearn 홈페이지에는 mutual_info_classif는 'k-최근접 이웃 거리 기반의 엔트로피 추정을 수행하는 비모수적 방법에 해당'한다고 하는데 이는 아래 논문에서 자세한 수식과 설명을 볼 수 있었다.일반적으로 MI는 결합확률분포 (X,Y) 추정을 통해 상호정보(MI)를 계산하는데 mutual_info_classif는 k-최근접 이웃방법을 적용한다는 것인데 개념 자체는 2004년에 제시되었다고 한다.
https://journals.aps.org/pre/pdf/10.1103/PhysRevE.69.066138
'Data Science' 카테고리의 다른 글
ChatGPT 이용 상세 리뷰 😮 (0) | 2022.12.26 |
---|---|
데이터 타입별 컬럼 구분하기 ✔ (0) | 2022.10.12 |
[ 데이터 시각화 ] matplotlib 기본 개념 | 그래프 정리 (0) | 2022.10.11 |
[ Scikit-learn] Preprocessing.PolynomialFeatures 정리 (0) | 2022.10.01 |
[Scikit-learn] Impute.SimpleImputer (0) | 2022.09.22 |
댓글