天天看點

ML之RF:利用Pipeline(客戶年齡/職業/婚姻/教育/違約/餘額/住房等)預測客戶是否購買該銀行的産品二分類(預測、推理)

利用Pipeline(客戶年齡/職業/婚姻/教育/違約/餘額/住房等)預測客戶是否購買該銀行的産品二分類(預測、推理)

資料說明

       該資料集是葡萄牙銀行機構進行營銷活動所得。這些營銷活動一般以電話為基礎,銀行的客服人員至少聯系客戶一次,以确認客戶是否有意願購買該銀行的産品(定期存款)。目标是預測客戶是否購買該銀行的産品。

ML之RF:利用Pipeline(客戶年齡/職業/婚姻/教育/違約/餘額/住房等)預測客戶是否購買該銀行的産品二分類(預測、推理)

NO 字段名稱 資料類型 字段描述

1 ID Int 客戶唯一辨別

2 age Int 客戶年齡

3 job String 客戶的職業

4 marital String 婚姻狀況

5 education String 受教育水準

6 default String 是否有違約記錄

7 balance Int 每年賬戶的平均餘額

8 housing String 是否有住房貸款

9 loan String 是否有個人貸款

10 contact String 與客戶聯系的溝通方式

11 day Int 最後一次聯系的時間(幾号)

12 month String 最後一次聯系的時間(月份)

13 duration Int 最後一次聯系的交流時長

14 campaign Int 在本次活動中,與該客戶交流過的次數

15 pdays Int 距離上次活動最後一次聯系該客戶,過去了多久(999表示沒有聯系過)

16 previous Int 在本次活動之前,與該客戶交流過的次數

17 poutcome String 上一次活動的結果

18 y Int 預測客戶是否會訂購定期存款業務

資料參考:Citation: [Moro et al., 2014] S. Moro, P. Cortez and P. Rita. A Data-Driven Approach to Predict the Success of Bank Telemarketing. Decision Support Systems, Elsevier, 62:22-31, June 2014

輸出結果

檢視資料分布

ML之RF:利用Pipeline(客戶年齡/職業/婚姻/教育/違約/餘額/住房等)預測客戶是否購買該銀行的産品二分類(預測、推理)

分析資料

#   Column     Non-Null Count  Dtype

---  ------     --------------  -----

0   ID         25317 non-null  int64

1   age        25317 non-null  int64

2   job        25317 non-null  object

3   marital    25317 non-null  object

4   education  25317 non-null  object

5   default    25317 non-null  object

6   balance    25317 non-null  int64

7   housing    25317 non-null  object

8   loan       25317 non-null  object

9   contact    25317 non-null  object

10  day        25317 non-null  int64

11  month      25317 non-null  object

12  duration   25317 non-null  int64

13  campaign   25317 non-null  int64

14  pdays      25317 non-null  int64

15  previous   25317 non-null  int64

16  poutcome   25317 non-null  object

17  y          25317 non-null  int64

dtypes: int64(9), object(9)

memory usage: 3.5+ MB

訓練集計算相關系數:

y           1.000000

ID          0.556627

duration    0.394746

pdays       0.107565

previous    0.088337

campaign    0.075173

balance     0.057564

day         0.031886

age         0.029916

訓練集 y标簽的比例: 0.11695698542481336

依次檢視訓練集、測試集中,類别型字段的細分類

job ['admin.', 'blue-collar', 'entrepreneur', 'housemaid', 'management', 'retired', 'self-employed', 'services', 'student', 'technician', 'unemployed', 'unknown']

marital ['divorced', 'married', 'single']

education ['primary', 'secondary', 'tertiary', 'unknown']

default ['no', 'yes']

housing ['no', 'yes']

loan ['no', 'yes']

contact ['cellular', 'telephone', 'unknown']

month ['apr', 'aug', 'dec', 'feb', 'jan', 'jul', 'jun', 'mar', 'may', 'nov', 'oct', 'sep']

poutcome ['failure', 'other', 'success', 'unknown']

輸出訓練過程

Fitting 7 folds for each of 32 candidates, totalling 224 fits

[Parallel(n_jobs=-1)]: Using backend LokyBackend with 4 concurrent workers.

[CV] forst_reg__max_features=45, forst_reg__n_estimators=50 ..........

[CV]  forst_reg__max_features=45, forst_reg__n_estimators=50, total=  31.1s

[CV]  forst_reg__max_features=45, forst_reg__n_estimators=50, total=  31.0s

[CV]  forst_reg__max_features=45, forst_reg__n_estimators=50, total=  31.7s

[CV]  forst_reg__max_features=45, forst_reg__n_estimators=50, total=  32.2s

[CV] forst_reg__max_features=45, forst_reg__n_estimators=100 .........

[CV]  forst_reg__max_features=45, forst_reg__n_estimators=50, total=  27.1s

[CV]  forst_reg__max_features=45, forst_reg__n_estimators=50, total=  26.6s

導出推理結果

ML之RF:利用Pipeline(客戶年齡/職業/婚姻/教育/違約/餘額/住房等)預測客戶是否購買該銀行的産品二分類(預測、推理)

繼續閱讀