일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- ProDS
- 골목상권데이터분석
- houseprice
- 회귀모형평가
- samsungsds
- IT멘토링
- 코딩없이데이터분석
- 상권배후지
- 삼성sds
- Datascientist
- BrighticsStudio
- Brightics
- 삼성자격증
- EDA
- 서울시상권분석
- Brightics서포터즈
- 브라이틱스데이터분석
- Kaggle출전
- 데이터전처리
- kaggle
- 데이터분석
- SDSBrightics
- 브라이틱스
- 분석모델링
- 모델링
- 브라이틱스서포터즈
- 데이터분석대외활동
- associateDS
- AdSP
- 삼성SDSBrightics
- Today
- Total
Database for Everything
[삼성 SDS Brightics] Brightics 서포터즈와 함께 코딩없이 Kaggle Competition 도전하기!_데이터 전처리① 본문
[삼성 SDS Brightics] Brightics 서포터즈와 함께 코딩없이 Kaggle Competition 도전하기!_데이터 전처리①
Yeenn 2021. 8. 3. 00:56
안녕하세요, Brightics 서포터즈 yeenn입니다!
드디어!
Brightic3의 팀분석 프로젝트가 시작되었습니다.
Brightic3의 팀분석프로젝트 주제는 "Kaggle의 Houseprice 데이터를 활용한 집값예측+Kaggle Competition 도전하기"입니다!
이번 Brightics 팀분석프로젝트에서는 작년과는 다르게 Kaggle Competition참가가 필수 참여 미션으로 지정되었는데요, Ongoing중인 여러 Kaggle competition중에 "데이터 접근성 + Brightics를 통한 모델링 구축"의 측면에서
"House Price - Advanced Regression Techniques" competition
이 팀원의 최다 득표를 얻어 주제로 선정되었습니다.
↓
https://www.kaggle.com/c/house-prices-advanced-regression-techniques/overview
House Prices - Advanced Regression Techniques | Kaggle
www.kaggle.com
팀분석 1주차에는 이를 이용해 간단한 데이터 전처리과정을 진행해볼 예정인데요,
Brightics의 null값 처리 방법과 Target변수의 탐색과정 위주로 포스팅을 작성해보려고합니다!
Dataset 정보
● 독립변수: 79개(ID변수 제외)
● 종속변수: Saleprice
Data fields
Here's a brief version of what you'll find in the data description file.
(출처: https://www.kaggle.com/c/house-prices-advanced-regression-techniques/data)
- SalePrice - the property's sale price in dollars. This is the target variable that you're trying to predict.
- MSSubClass: The building class
- MSZoning: The general zoning classification
- LotFrontage: Linear feet of street connected to property
- LotArea: Lot size in square feet
- Street: Type of road access
- Alley: Type of alley access
- LotShape: General shape of property
- LandContour: Flatness of the property
- Utilities: Type of utilities available
- LotConfig: Lot configuration
- LandSlope: Slope of property
- Neighborhood: Physical locations within Ames city limits
- Condition1: Proximity to main road or railroad
- Condition2: Proximity to main road or railroad (if a second is present)
- BldgType: Type of dwelling
- HouseStyle: Style of dwelling
- OverallQual: Overall material and finish quality
- OverallCond: Overall condition rating
- YearBuilt: Original construction date
- YearRemodAdd: Remodel date
- RoofStyle: Type of roof
- RoofMatl: Roof material
- Exterior1st: Exterior covering on house
- Exterior2nd: Exterior covering on house (if more than one material)
- MasVnrType: Masonry veneer type
- MasVnrArea: Masonry veneer area in square feet
- ExterQual: Exterior material quality
- ExterCond: Present condition of the material on the exterior
- Foundation: Type of foundation
- BsmtQual: Height of the basement
- BsmtCond: General condition of the basement
- BsmtExposure: Walkout or garden level basement walls
- BsmtFinType1: Quality of basement finished area
- BsmtFinSF1: Type 1 finished square feet
- BsmtFinType2: Quality of second finished area (if present)
- BsmtFinSF2: Type 2 finished square feet
- BsmtUnfSF: Unfinished square feet of basement area
- TotalBsmtSF: Total square feet of basement area
- Heating: Type of heating
- HeatingQC: Heating quality and condition
- CentralAir: Central air conditioning
- Electrical: Electrical system
- 1stFlrSF: First Floor square feet
- 2ndFlrSF: Second floor square feet
- LowQualFinSF: Low quality finished square feet (all floors)
- GrLivArea: Above grade (ground) living area square feet
- BsmtFullBath: Basement full bathrooms
- BsmtHalfBath: Basement half bathrooms
- FullBath: Full bathrooms above grade
- HalfBath: Half baths above grade
- Bedroom: Number of bedrooms above basement level
- Kitchen: Number of kitchens
- KitchenQual: Kitchen quality
- TotRmsAbvGrd: Total rooms above grade (does not include bathrooms)
- Functional: Home functionality rating
- Fireplaces: Number of fireplaces
- FireplaceQu: Fireplace quality
- GarageType: Garage location
- GarageYrBlt: Year garage was built
- GarageFinish: Interior finish of the garage
- GarageCars: Size of garage in car capacity
- GarageArea: Size of garage in square feet
- GarageQual: Garage quality
- GarageCond: Garage condition
- PavedDrive: Paved driveway
- WoodDeckSF: Wood deck area in square feet
- OpenPorchSF: Open porch area in square feet
- EnclosedPorch: Enclosed porch area in square feet
- 3SsnPorch: Three season porch area in square feet
- ScreenPorch: Screen porch area in square feet
- PoolArea: Pool area in square feet
- PoolQC: Pool quality
- Fence: Fence quality
- MiscFeature: Miscellaneous feature not covered in other categories
- MiscVal: $Value of miscellaneous feature
- MoSold: Month Sold
- YrSold: Year Sold
- SaleType: Type of sale
- SaleCondition: Condition of sale
데이터 수가 조금...많죠..?
그 말인 즉슨..=전처리 해야 할 게 많다는 뜻ㅎㅎ.
변수별 category가 포함된 세부 dataset정보는 아래의 data description.txt파일에서 확인하실 수 있습니다!
1. Data Load
House Price의 Train data를 load 해주세요. Delimiter은 Comma로 설정하면 됩니다!
다 Load가 되는 줄 알았으나...문제가 발생했네요!
Brightics에서는 모든 column의 이름이 알파벳과 숫자, '_'로 시작되어야 하는데요,
일부 Column name이 숫자로 시작되어 있어 load에 문제가 생긴듯합니다.
변수명에 너무 많은 변화를 주면 나중에 데이터 탐색할 때에도 헷갈릴 수 있으니, 숫자로 시작하는 변수들 앞에 '_'만 추가하여 column name을 수정해주도록 하겠습니다!
Column name을 수정한 다음,
(1stFlrSF → _1stFlrSF / 2ndFlrSF → _2ndFlrSF / 3SsnPorch → _3SsnPorch)
Finish 버튼을 누르니,
Data Load가 성공적으로 마무리 되었는데요,
총 81개의 열과 1460개의 행으로 이루어져 있는 것을 확인할 수 있었습니다!
2. Null값 확인 및 제거
그 다음은 Statistic Summary 함수를 통해 데이터의 결측치를 확인해보겠습니다.
요약 통계량을 확인할 수 있는 Statistic Summary를 불러온 후,
Input Columns: 38개의 모든 Column
Target Statistic: Null Count
를 지정한 후, Run을 누르면
위와 같이 null_count변수가 생성됩니다. 확인해보니,
Lotfrontage변수에 259개,
MasVnrArea변수에 8개,
GarageYrBlt변수에 81개의 null값이 존재하고 있네요!
MasVnrArea와 GarageYrblt변수는 생각보다 결측치의 값이 많지 않아서, null값이 있는 행을 제거하고,
Lotfrontage변수는 mean값으로 대체해주도록 하겠습니다.
Delete Missing Data 함수를 불러와 null값이 있는 것으로 확인된 MasVnrArea, GarageYrBlt변수의 결측값이 포함된 행을 제거해주었습니다!
Input Columns: MasVnrArea, GarageYtBlt
Delete row or column: Row
를 지정해주세요.
그 다음, Replace Missing Number함수를 불러와 Lotfrontage변수의 결측값을 평균값으로 대체해주었습니다!
Input Columns: Lotfrontage
Fill Value: Mean
를 지정해주세요.
그 다음은 이상치를 탐색하고 제거해주려고 했으나..
이전에 먼저 Tukey방법을 활용해서 outlier제거를 해주었는데, 절반 가량의 너무 많은 값들이 소실되어 후에 유의성판단을 진행한 후, 다른 적합한 방법을 찾아 제거하는 것이 맞다고 판단했습니다..!
3. "Na" → "None" Column명 대체
앞서 언급했듯이 house price 데이터의 변수는 굉장히 많은 편인데요, 변수를 살펴보다보니, 범주형 변수의 값 중 'NA'값이 상당부분 있는 것으로 확인되었습니다.
처음에는 결측치라고 생각했으나, 자세히보니 해당부분의 값이 '0'값인 관측치였습니다!
(예: Basement - Nan: No basement → 다른 basement 변수는 값이 있는데 이 변수에만 값이 없는 경우)
[House price Data Description 일부]
LotFrontage: Linear feet of street connected to property
LotArea: Lot size in square feet
Street: Type of road access to property
Grvl Gravel
Pave Paved
Alley: Type of alley access to property
Grvl Gravel
Pave Paved
NA No alley access
LotShape: General shape of property
Reg Regular
IR1 Slightly irregular
IR2 Moderately Irregular
IR3 Irregular
.
.
.
data description.txt file에서 Ctrl+F를 눌러
찾을 내용에 NA를 입력하고, 대/소문자를 구분하여 모든 NA값을 확인해보니, 모두 해당 시설이 없는 경우 ‘시설 없음’이라는 카테고리가 있는 변수들이었습니다.
Column name으로 관측치를 헷갈리는 경우를 방지하기 위해, Replace String Variable 함수를 사용하여 'NA'로 표기된 값을 모두 '없음'을 뜻하는 'None'값으로 변경해주도록 하겠습니다!
Input Columns: 모든 column
Target String: NA
Replace String: None
으로 parameter을 지정해주고 Run을 눌러주시면,
모든 NA로 표기된 값이 'None'으로 변수명이 변경된 것을 확인할 수 있습니다.
4. 반응변수의 왜도 및 첨도 확인
그 다음은, Target Value인 Saleprice의 왜도와 첨도를 확인해보겠습니다.
Statistic Summary함수를 불러와
Input Columns에 Saleprice 변수를 넣고,
Target Statistic 중 Skewness of sample과 Kurtosis를 선택하여
Run 버튼을 눌러주었습니다!
Column name: SalePrice
Skewness: 1.934
Kurtosis: 6.752
결과를 보니, 타겟 변수의 왜도와 첨도가 상당히 높게 나온 것을 확인할 수 있었습니다.
Histogram을 통해 다시한번 왜도를 확인해보겠습니다.
타겟변수의 데이터 분포가 right-skewed되었음을 그래프로 다시 확인해볼 수 있었습니다.
데이터의 이러한 비대칭성을 해결하기 위해 추후 로그 변환과정이 필요할 것 같네요!
우선, 팀분석 프로젝트 1주차는 이렇게 마무리하려고합니다!
다음주는 남은 전처리과정을 진행해보도록 하겠습니다:)
다음 포스팅에서 만나요!

본 게시물은 Brightics 서포터즈 활동의 일환으로 작성된 포스팅 입니다.