설문 데이터 처리와 LightGBM 모델 설정
이미지 데이터 처리
우선, 학습에 사용할 이미지 데이터의 경로를 설정하고, 해당 이미지를 불러와 데이터프레임으로 정리합니다.
# 이미지 경로 설정
train_dir = '/content/sample_data/train'
test_dir = '/content/sample_data/test'
valid_dir = '/content/sample_data/valid'
# train 폴더와 test 폴더의 이미지 파일 리스트를 불러와 데이터프레임으로 정리
train_images = os.listdir(train_dir)
test_images = os.listdir(test_dir)
# 이미지 파일 이름에 따라 클래스 할당 (Autistic 또는 Non_Autistic)
train_df = pd.DataFrame({
'filename': train_images,
'class': ['Autistic' if 'autistic' in name.lower() and 'non' not in name.lower() else 'Non_Autistic' for name in train_images]
})
test_df = pd.DataFrame({
'filename': test_images,
'class': ['Autistic' if 'autistic' in name.lower() and 'non' not in name.lower() else 'Non_Autistic' for name in test_images]
})
- os.listdir(): 지정된 디렉토리 내 파일 목록을 반환합니다.
- DataFrame 생성: 이미지 파일 이름에 따라 자폐스펙트럼 여부를 클래스(label)로 지정합니다.
다음으로는 설문 데이터를 처리하고, LightGBM 모델을 통해 예측하는 과정을 다룹니다.
'ABC 부트캠프 데이터 탐험가 4기' 카테고리의 다른 글
[36 일차] ABC 부트캠프 : 최종 프로젝트(6) (0) | 2024.08.25 |
---|---|
[35 일차] ABC 부트캠프 : 최종 프로젝트(5) (0) | 2024.08.25 |
[33 일차] ABC 부트캠프 : 최종 프로젝트(3) (0) | 2024.08.25 |
[32일차] ABC 부트캠프 : 최종프로젝트 (2) (0) | 2024.08.25 |
[31 일차] ABC 부트캠프 : 최종 프로젝트(1) (0) | 2024.08.17 |