最近在kaggle參加了一個叫PetFinder的比賽,也是我第一次參加比賽
參賽者必須用機器學習的模型去預測出寵物從進收容所到被領養走的速度有多快
也就是"AdoptionSpeed"
0 - 當日
1 - 1-7天
2 - 8-30天
3 - 31-90天
4 - 90-100天
那給的Data Fields有
PetID
AdoptionSpeed
Type - Type of animal (1 = Dog, 2 = Cat)
Name - Name of pet
Age - Age of pet when listed, in months
Breed1 - Primary breed of pet
Breed2 - Secondary breed of pet, if pet is of mixed breed
Gender - Gender of pet
Color1 - Color 1 of pet
Color2 - Color 2 of pet
Color3 - Color 3 of pet
MaturitySize - Size at maturity
FurLength - Fur length
Vaccinated - Pet has been vaccinated
Dewormed - Pet has been dewormed
Sterilized - Pet has been spayed / neutered
Health - Health Condition
Quantity - Number of pets represented in profile
Fee - Adoption fee (0 = Free)
State - State location in Malaysia (Refer to StateLabels dictionary)
RescuerID - Unique hash ID of rescuer
VideoAmt - Total uploaded videos for this pet
PhotoAmt - Total uploaded photos for this pet
Description - Profile write-up for this pet. The primary language used is English, with some in Malay or Chinese.
有了這些欄位我們可以從中篩選出特徵(feature)和要預測的目標值(target)
首先特徵(feature)我就去除一些不能量化的欄位,剩下可以量化的欄位來當特徵
預測的目標值(target)當然就是主辦單位要求的"AdoptionSpeed"
其實主辦單位還給了一大包貓貓狗狗的照片集供我們下載
不過目前我還沒真正把這些照片用在我的預測上
分幾個部分來做
第一部分就是
資料清洗,資料探勘,特徵工程,特徵選擇
第二部分就是
填補缺失值,比較不同的機器學習模型, 參數調整和交叉驗證, 評估模型
第三部分就是
最後把測試集資料讀進來丟給訓練好的模型去預測,結果保存,上傳提交
首先資料讀進是長這樣子的
檢查資料型態看看是否有無法量化的type
注意到object是不能量化的所以就把他drop掉
剩下的特徵看一下他們跟預測值間的重要度
那這裡我用的分類模型是
rf=RandomForestClassifier(n_estimators=100,max_features='log2')
分數有達到0.41
rf.score(x_valid,y_valid)
其實算蠻低的,不過因為這個比賽才剛開沒多久,大家都不太高
最後測試集讀進來預測看看
目前排行榜競爭激烈
小妹排在153的位置><
比賽持續到明年3月28日
希望努力慢慢改善讓名次有辦法上去