所有數(shù)據(jù)均由kaggle獲取
1)數(shù)據(jù)清洗:
1.通過熱力圖觀察特征值之間的關(guān)系
? 在圖中拂蝎,我們定義了下面的特征:
Index(['Id', 'MSSubClass', 'MSZoning', 'LotFrontage', 'LotArea', 'Street',
? ? ? 'Alley', 'LotShape', 'LandContour', 'Utilities', 'LotConfig',
? ? ? 'LandSlope', 'Neighborhood', 'Condition1', 'Condition2', 'BldgType',
? ? ? 'HouseStyle', 'OverallQual', 'OverallCond', 'YearBuilt', 'YearRemodAdd',
? ? ? 'RoofStyle', 'RoofMatl', 'Exterior1st', 'Exterior2nd', 'MasVnrType',
? ? ? 'MasVnrArea', 'ExterQual', 'ExterCond', 'Foundation', 'BsmtQual',
? ? ? 'BsmtCond', 'BsmtExposure', 'BsmtFinType1', 'BsmtFinSF1',
? ? ? 'BsmtFinType2', 'BsmtFinSF2', 'BsmtUnfSF', 'TotalBsmtSF', 'Heating',
? ? ? 'HeatingQC', 'CentralAir', 'Electrical', '1stFlrSF', '2ndFlrSF',
? ? ? 'LowQualFinSF', 'GrLivArea', 'BsmtFullBath', 'BsmtHalfBath', 'FullBath',
? ? ? 'HalfBath', 'BedroomAbvGr', 'KitchenAbvGr', 'KitchenQual',
? ? ? 'TotRmsAbvGrd', 'Functional', 'Fireplaces', 'FireplaceQu', 'GarageType',
? ? ? 'GarageYrBlt', 'GarageFinish', 'GarageCars', 'GarageArea', 'GarageQual',
? ? ? 'GarageCond', 'PavedDrive', 'WoodDeckSF', 'OpenPorchSF',
? ? ? 'EnclosedPorch', '3SsnPorch', 'ScreenPorch', 'PoolArea', 'PoolQC',
? ? ? 'Fence', 'MiscFeature', 'MiscVal', 'MoSold', 'YrSold', 'SaleType',
? ? ? 'SaleCondition', 'SalePrice'],
? ? ? dtype='object')思灌。
2.當某些特征比較相似且無法分別時坤次,可以刪除相對來說比較弱的特征
3.因為大部分的統(tǒng)計原理和參數(shù)檢驗都是基于正態(tài)分布推得的。所以當數(shù)據(jù)不符合正態(tài)分布時幌绍,就需要將數(shù)據(jù)進行數(shù)據(jù)轉(zhuǎn)換(對數(shù)據(jù)取log邑贴,可以解決大部分問題)
? ? ? ? ? ? 如圖下圖恬吕,數(shù)據(jù)在初始時蜂林,數(shù)值分散大遥诉,二圖數(shù)值分散多:
? ? ? ? 對數(shù)值取log后:
2)數(shù)據(jù)丟失:
1.丟失數(shù)據(jù)操作,當特征內(nèi)的數(shù)據(jù)丟失大于某個百分比噪叙,可以刪除一些比較偏遠的數(shù)值
? ? eg:在預測某個地方的房價時矮锈,某些features的數(shù)據(jù)可能會產(chǎn)生一些奇怪的數(shù)值,如下圖所示睁蕾,圖中的右邊有兩顆數(shù)據(jù)點離整體極遠苞笨,且無法分析原因時候,則可以把這兩個數(shù)據(jù)定義為離群值,并進行刪除操作
2.當是偏態(tài)且有相當?shù)挠^察值為0時猫缭,無法進行對數(shù)操作葱弟。為了在這里應用一個log轉(zhuǎn)換壹店,我們將創(chuàng)建一個變量猜丹,該變量可以獲得擁有或沒有地下室(二進制變量)的效果。然后硅卢,我們將對所有非零的觀測做一個對數(shù)變換射窒,忽略那些值為0的觀測值。這樣我們就可以轉(zhuǎn)換數(shù)據(jù)将塑,而不會失去地下室的影響脉顿。
3.對兩個變量進行方差檢驗的最佳方法是將其圖形化顯示出來