directory 확인
0. import library
필요 라이브러리 불러오기
1. load data
데이터 불러오기
2. data preprocessing
2-1. data check
- 각 변수 의미 확인
'id' ID
'MonsoonIntensity' 몬순강도
'TopographyDrainage' 지형배수
'RiverManagement' 하천관리
'Deforestation' 삼림벌채
'Urbanization' 도시화
'ClimateChange' 기후 변화
'DamsQuality' 댐 퀄리티
'Siltation' 침묵(?)
'AgriculturalPractices' 농업 관행
'Encroachments' 침략
'IneffectiveDisasterPreparedness' 비효과적인 재해 대비
'DrainageSystems' 배수 시스템
'CoastalVulnerability' 해안 취약성
'Landslides' 산사태
'Watersheds' 유역
'DeterioratingInfrastructure' 인프라 악화
'PopulationScore' 인구 점수
'WetlandLoss' 습지 손실
'InadequatePlanning' 부적절한 계획
'PoliticalFactors' 정치적 요인
'FloodProbability' 홍수확률
- 기술통계량 확인
- 시각화(히스토그램)
- 상관관계 확인
열별로 상관관계 크게 없음
2-2. data preprocessing
- 이상치 확인
IQR방법을 이용하여 이상치 확인
z점수를 이용하여 이상치 확인(threshold = 3)
두 이상치 결과와 히스토그램 확인 결과 이상치 제거 필요 없다고 간주
- 결측치 제거
결측치 없음
- 데이터 분할
train 데이터를 train_x, train_y로 분할
test 데이터를 test_x로 분할
- 변수는 많고 상관관계는 크게 없으므로 PCA도 적용해보도록 함 (n_component = 10)
train_x 데이터를 train_x_pca 생성
test_x 데이터를 test_x_pca 생성
3. 모델링
- 데이터 분할
train데이터를 train데이터와 validation데이터로 나눈 후 확인 (test_size = 0.2)
- 모델링
Linear Regression (code1.ipynb)
Random Forest Regressor (code2.ipynb)
4. 결과
- PCA 적용 전 데이터 결과
MSE: 0.00041
R2 score : 0.82820
- PCA 적용 후 데이터 결과
MSE: 0.00238
R2 score: 0.00452
- PCA 적용 전 데이터 결과
MSE: 0.00090
R2 score : 0.65602
- PCA 적용 후 데이터 결과
MSE: 0.00262
R2 score: -0.0050
5. 제출
- 더 결과가 좋은 PCA 적용 전 모델에 대해 코드 정리 후 제출 (result1.ipynb)
결과: 0.84458
링크
https://github.com/ornni/kaggle/tree/main/Regression%20with%20a%20Flood%20Prediction%20Dataset
'Kaggle' 카테고리의 다른 글
Mobile Price Classification (0) | 2024.10.30 |
---|---|
Titanic - Machine Learning from Disaster (0) | 2024.06.15 |