客戶流失預測 —— 資源彙總

Table of Contents

0. 題目簡介

1. 資源收集和整理

2. 相關學習資料

2.1 相似比賽思路

2.2 數據處理+特徵工程

2.2.1 數據處理:

2.2.2 特徵工程:

2.3 模型和參數調優

3. 一些筆記

3.1 《結合Scikit-learn介紹幾種常用的特徵選擇方法》

3.2 《[機器學習實戰]使用 scikit-learn 預測用戶流失》

3.3 《天池數據挖掘比賽技術與套路總結》

3.4 《LogisticRegression用戶流失預測模型初探【推薦】》

3.5 《基於Python的邏輯迴歸實現及數據挖掘應用案例講解》

3.6 《大數據競賽技術分享》

3.7 Xgboost參數說明

Control overfitting:

Handle imbalanced dataset

Xgboost 參數說明


之前參加了一次公司舉辦的客戶流失預測比賽,當時是機器學習小白(雖然現在也是),爲了這場比賽收集整理了不少資料,在此稍微做一個簡單的總結,和大家分享一下。

0. 題目簡介

  • 問題:預測客戶未來三個月續訂訂單的概率
  • 數據源:包括Product、ProductFamily、Service、Service Family、Partner、Customer、Order、Order Line、Offer、Customer’s Company、Usage、Revenue、Bill等多個維度在內的數據
  • 評判標準:Score Set的交叉熵
  • 模型選擇:最後使用了XGBoost和GBDT融合

1. 資源收集和整理

因爲之前沒有接觸過機器學習相關的工作,是個純小白,所以我們首先手機資料,瞭解相關比賽所採用的思路和方法。通過學習瞭解到通用的機器學習流程如下:

  • 數據分析和預處理
  • 特徵工程(特徵選擇)
  • 模型選擇(分類問題/迴歸問題)
  • 訓練和調優

接下來,針對這些步驟,我們對其進行更細緻的強化學習。

2. 相關學習資料

2.1 相似比賽思路

通過閱讀下面的博客,瞭解到這種類型的比賽通用的解題流程,對機器學習解決問題的流程有了初步的概念。

2.2 數據處理+特徵工程

2.2.1 數據處理:

2.2.2 特徵工程:

2.3 模型和參數調優

3. 一些筆記

3.1 《結合Scikit-learn介紹幾種常用的特徵選擇方法

如何用迴歸模型的係數來選擇特徵。越是重要的特徵在模型中對應的係數就會越大,而跟輸出變量越是無關的特徵對應的係數就會越接近於0。在噪音不多的數據上,或者是數據量遠遠大於特徵數的數據上,如果特徵之間相對來說是比較獨立的,那麼即便是運用最簡單的線性迴歸模型也一樣能取得非常好的效果。

在很多實際的數據當中,往往存在多個互相關聯的特徵,這時候模型就會變得不穩定,數據中細微的變化就可能導致模型的巨大變化(模型的變化本質上是係數,或者叫參數,可以理解成W),這會讓模型的預測變得困難,這種現象也稱爲多重共線性。

3.2 《[機器學習實戰]使用 scikit-learn 預測用戶流失

流程:數據預處理 (char --> bool,  delete less useful columns,  歸一化)--> 模型:KNN, SVM, RF(交叉驗證)

3.3 《天池數據挖掘比賽技術與套路總結

流程:數據可視化 ----》數據預處理---》 特徵工程 ---》模型融合

3.4 《LogisticRegression用戶流失預測模型初探【推薦】

  • 邏輯迴歸:

    • Logistic regression 是二項分佈,比較常用來進行二分類

    • Logistic迴歸的主要用途:

      • 尋找危險因素:尋找某一疾病的危險因素等;
      • 預測:根據模型,預測在不同的自變量情況下,發生某病或某種情況的概率有多大;
      • 判別:實際上跟預測有些類似,也是根據模型,判斷某人屬於某病或屬於某種情況的概率有多大,也就是看一下這個人有多大的可能性是屬於某病。
  • 解決問題:

根據自己工作中的一個產品作爲主題,預測其用戶流失與留存。

流失=上個月有消費,本月無消費表流失(其實也是消費流失啦)。

數據週期使用的是一兩個月來做分析,什麼情況下用戶會消費流失?

於是挑選了一些指標特徵來做分析,比如上個月的消費次數、最近的消費時間(可量化),消費金額,rmf這個原理還是有一個分析依據的。當然還有其他特徵如,用戶觀看總時長、用戶活躍天數、停留時長、啓動次數等。

  • 用戶流失分析中的關鍵技術:

分類模型:決策樹  (ID3,C4.5 , C50)

流程:  準備工作(明確自變量和因變量,確定信息度量的方式(熵,信息增益),確定最終的終止條件(純度,記錄條數,循環次數)) ---》選擇特徵  ---》創建分支 ----》是否終止----》結果生成

3.5 《基於Python的邏輯迴歸實現及數據挖掘應用案例講解

  • Step1:數據庫提取數據:結合106個指標
  • Step2:數據查看及處理
  • Step3:LR模型訓練
  • Step4:模型預測及評估
  • Step5:模型優化: 交叉驗證+grid search重新訓練,

注意:模型的查全率recall和查準率precision那個更重要。 判斷那個度量指標最重要!!  本次比賽中precision更重要

3.6 《大數據競賽技術分享

3.7 Xgboost參數說明

參數說明文檔: https://xgboost.readthedocs.io/en/latest/parameter.html

Control overfitting:

  • First way: directly control model complexity
    • Include max_depth, min_child_weight, gamma
  • Second way: add randomness to make training robust to noise
    • Subsample, colsample_bytree
    • Reduce step_size eta, but needs to remember to increase num_round when you do so\

Handle imbalanced dataset

訓練樣本中,類別之間的樣本數據量比例超過4:1,可以認爲樣本存在不均衡的問題

  • If you care only about the ranking order (AUC) of your prediction
    • Balance the positive and negative weights, via scale_pos_weight
    • Use AUC for evaluation
  • If you care about predicting the right probability
    • In such a case ,you cannot rebalance the dataset
    • In such a case, set parameter max_delta_step to finite  (say 1) will help convergence

Xgboost 參數說明

  • Before running xgboost, set three types of parameters: general, booster and learning task parameters
    • General parameters: relates to which booster we are using to do boosting, commonly tree and linear model
    • Booster parameters: depends on which booster you have chosen
    • Learning task parameters that decides on the learning scenario, for example, regress tasks may use different parameters with ranking tasks
  • General parameters:
    • Booster [default=gbtree]
      • Which booster to use, can be gbtree, gblinear or dart. Gbtree and dart based on tree model, which gblinear uses linear function
    • Silent [default=0]
      • 0 means printing running message; 1 means silent mode
    • Nthread [default to maximum number of thread availiable if not set]
    • Num_pbuffer[set automatically by xgboost]
    • Num_feature[set automatically by xgboost]
  • Parameters for tree booster
    • Eta[default=0.3, alias: learning_rate]
      • Step size shrinkage used in update to prevents overfitting.
      • Range:  [0,]
      • The larger, the more conservative
    • Gamma[default=0, alias: min_split_loss]
      • Minimum loss reduction required to make a further partition on a leaf node of a tree.
      • The larger, the more conservative the algorithm will be.
      • range: [0,∞]
    • max_depth [default=6]
      • maximum depth of a tree, increase this value will make the model more complex / likely to be overfitting. 0 indicates no limit, limit is required for depth-wise grow policy.
      • range: [0,∞]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章