python信用評(píng)分卡建模(附代碼)-基于German Credit德國(guó)信用數(shù)據(jù)集

在全球數(shù)字經(jīng)濟(jì)時(shí)代,有一種金融優(yōu)勢(shì),那就是基于消費(fèi)者大數(shù)據(jù)的純信用!

我們不妨稱之為數(shù)據(jù)信用,它比抵押更靠譜,它比擔(dān)保更保險(xiǎn),它是一種面向未來(lái)的財(cái)產(chǎn)權(quán),它是數(shù)字貨幣背后核心的抵押資產(chǎn),它決定了數(shù)字貨幣時(shí)代信用創(chuàng)造的方向、速度和規(guī)模。數(shù)據(jù)信用判斷依靠的就是金融風(fēng)控模型。
風(fēng)控模型是怎么搭建的?風(fēng)控模型應(yīng)該采用什么算法?風(fēng)控模型是互聯(lián)網(wǎng)大咖描述的那么無(wú)所不能嗎?模型有哪些坑?模型質(zhì)量一定可靠嗎?




?

?

?

?


?
歡迎各位朋友了解《python信用評(píng)分卡建模視頻系列教程(附代碼)》?:
騰訊課堂
https://ke.qq.com/course/3063615?tuin=dcbf0ba
網(wǎng)易云課堂
https://study.163.com/course/introduction.htm?courseId=1005214003&_trace_c_p_k2_=d97c968a3c1942168f1ba0328f29c0ed
課程目錄
章節(jié)1前言
章節(jié)1Python環(huán)境搭建
課時(shí)1 建評(píng)分卡模型,python,R,SAS誰(shuí)最好?
課時(shí)2 Anaconda快速入門指南
課時(shí)3 Anaconda下載和安裝
課時(shí)4 canopy下載和安裝
課時(shí)5 Anaconda Navigato導(dǎo)航器
課時(shí)6 python安裝第三方包:pip和conda install
課時(shí)7 Python非官方擴(kuò)展包下載地址
課時(shí)8 Anaconda安裝不同版本python
課時(shí)9 jupyter1_為什么使用jupyter notebook?
課時(shí)10 jupyter2_jupyter基本文本編輯操作
課時(shí)11 如何用jupyter notebook打開指定文件夾內(nèi)容?
課時(shí)12 jupyter4_jupyter轉(zhuǎn)換PPT實(shí)操
課時(shí)13 jupyter notebook用matplotlib不顯示圖片解決方案
章節(jié)2 python編程基礎(chǔ)知識(shí)
課時(shí)14 Python文件基本操作
課時(shí)15 變量_表達(dá)式_運(yùn)算符_值
課時(shí)16 字符串string
課時(shí)17 列表list
課時(shí)18 程序的基本構(gòu)架(條件,循環(huán))
課時(shí)19 數(shù)據(jù)類型_函數(shù)_面向?qū)ο缶幊?br>課時(shí)20 python2和3的區(qū)別
課時(shí)21 編程技巧和學(xué)習(xí)方法
章節(jié)3 python機(jī)器學(xué)習(xí)基礎(chǔ)
課時(shí)22 UCI機(jī)器學(xué)習(xí)常用數(shù)據(jù)庫(kù)介紹
課時(shí)23 機(jī)器學(xué)習(xí)書籍推薦
課時(shí)24 如何選擇算法
課時(shí)25 機(jī)器學(xué)習(xí)語(yǔ)法速查表
課時(shí)26 python數(shù)據(jù)科學(xué)常用的庫(kù)
課時(shí)27 python數(shù)據(jù)科學(xué)入門介紹(選修)
章節(jié)4 德國(guó)信用評(píng)分?jǐn)?shù)據(jù)下載和介紹
課時(shí)28 35德國(guó)信用評(píng)分?jǐn)?shù)據(jù)下載和介紹
章節(jié)5信用評(píng)分卡開發(fā)流程(上)
課時(shí)29 評(píng)分卡開發(fā)流程概述
課時(shí)30 第一步:數(shù)據(jù)收集
課時(shí)31 第二步:數(shù)據(jù)準(zhǔn)備
課時(shí)32 變量可視化分析
課時(shí)33 樣本量需要多少?
課時(shí)34 壞客戶定義
課時(shí)35 第三步:變量篩選
課時(shí)36 變量重要性評(píng)估_iv和信息增益混合方法
課時(shí)37 衍生變量05:01
課時(shí)38 第四步:變量分箱01:38
章節(jié)6信用評(píng)分卡開發(fā)流程(下)
課時(shí)39 第五步:建立邏輯回歸模型
課時(shí)40 odds賠率
課時(shí)41 woe計(jì)算
課時(shí)42 變量系數(shù)
課時(shí)43 A和B計(jì)算
課時(shí)44 Excel手動(dòng)計(jì)算壞客戶概率
課時(shí)45 Python腳本計(jì)算壞客戶概率
課時(shí)46 客戶評(píng)分
課時(shí)47 評(píng)分卡誕生-變量分?jǐn)?shù)計(jì)算
課時(shí)48 拒絕演繹reject inference
課時(shí)49 第六步:模型驗(yàn)證
課時(shí)50 第七步:模型部署
課時(shí)51 常見(jiàn)模型部署問(wèn)題
章節(jié)7 Python信用評(píng)分卡-邏輯回歸腳本
課時(shí)52 Python信用評(píng)分卡腳本運(yùn)行演示
課時(shí)53 描述性統(tǒng)計(jì)腳本_缺失率和共線性分析
課時(shí)54 woe腳本(kmean分箱)
課時(shí)55 iv計(jì)算獨(dú)家腳本
課時(shí)56 Excel手動(dòng)推導(dǎo)變量woe和iv值
課時(shí)57 評(píng)分卡腳本1(sklearn)
課時(shí)58 評(píng)分卡腳本2(statsmodel)
課時(shí)59 生成評(píng)分卡腳本
課時(shí)60 模型驗(yàn)證腳本
章節(jié)8PSI(population stability index)穩(wěn)定指標(biāo)
課時(shí)61 拿破侖遠(yuǎn)征歐洲失敗/華爾街股災(zāi)真兇-PSI模型穩(wěn)定指標(biāo)揭秘
課時(shí)62 excel推導(dǎo)PSI的計(jì)算公式
課時(shí)63 PSI計(jì)算公式原理_獨(dú)家秘密
課時(shí)64 PSI的python腳本講解
章節(jié)9難點(diǎn)1_壞客戶定義
課時(shí)65 壞客戶定義錯(cuò)誤,全盤皆輸
課時(shí)66 不同場(chǎng)景壞客戶定義不一樣,壞客戶定義具有反復(fù)性
課時(shí)67 壞客戶占比不能太低
課時(shí)68 vintage源于葡萄酒釀造
課時(shí)69 vintage用于授信策略優(yōu)化
章節(jié)10難點(diǎn)2_woe分箱
課時(shí)70 ln對(duì)數(shù)函數(shù)
課時(shí)71 excel手動(dòng)計(jì)算woe值
課時(shí)72 python計(jì)算woe腳本
課時(shí)73 Iv計(jì)算推導(dǎo)
課時(shí)74 woe正負(fù)符號(hào)意義
課時(shí)75 WOE計(jì)算就這么簡(jiǎn)單?你想多了
課時(shí)76 Kmean算法原理
課時(shí)77 python kmean實(shí)現(xiàn)粗分箱腳本
課時(shí)78 自動(dòng)化比較變量不同分箱的iv值
課時(shí)79 woe分箱第三方包腳本
章節(jié)11難點(diǎn)3_邏輯回歸是最佳算法嗎?
課時(shí)80 邏輯回歸是最優(yōu)算法嗎?No
課時(shí)81 xgboost_支持腳本下載
課時(shí)82 隨機(jī)森林randomForest_支持腳本下載
課時(shí)83 支持向量SVM_支持腳本下載
課時(shí)84 神經(jīng)網(wǎng)絡(luò)neural network_支持腳本下載
課時(shí)85 多算法比較重要性_模型競(jìng)賽,百萬(wàn)獎(jiǎng)金任你拿
章節(jié)12難點(diǎn)4_變量缺失數(shù)據(jù)處理
課時(shí)86 imputer-缺失數(shù)據(jù)處理
課時(shí)87 xgboost簡(jiǎn)單處理缺失數(shù)據(jù)
課時(shí)88 catboost處理缺失數(shù)據(jù)最簡(jiǎn)單
章節(jié)13難點(diǎn)5.模型驗(yàn)證
課時(shí)89 模型需要驗(yàn)證碼?
課時(shí)90 商業(yè)銀行資本管理辦法(試行)
課時(shí)91 模型驗(yàn)證_信用風(fēng)險(xiǎn)內(nèi)部評(píng)級(jí)體系要求
課時(shí)92 模型驗(yàn)證主要指標(biāo)概述
課時(shí)93 交叉驗(yàn)證cross validation
課時(shí)94 groupby分類統(tǒng)計(jì)函數(shù)
課時(shí)95 KS_模型區(qū)分能力指標(biāo)
課時(shí)96 混淆矩陣(accuracy,precision,recall,f1 score)
新增課時(shí)? ?模型排序能力-lift提升圖
章節(jié)14難點(diǎn)6.邏輯回歸調(diào)參
課時(shí)97 菜鳥也能輕松調(diào)參
課時(shí)98 調(diào)參1_Penalty正則化選擇參數(shù)
課時(shí)99 調(diào)參2_classWeight類別權(quán)重
課時(shí)100 調(diào)參3_solver優(yōu)化算法選擇參數(shù)
課時(shí)101 調(diào)參4_n_jobs
課時(shí)102 L-BFGS算法演化歷史
課時(shí)103 次要參數(shù)一覽
章節(jié)16 風(fēng)控管理和詐騙中介(選修)
課時(shí)104 網(wǎng)絡(luò)信貸發(fā)展史
課時(shí)105 詐騙中介
課時(shí)106 風(fēng)控管理
課時(shí)107 告別套路貸,高利貸,選擇正確貸款方式
章節(jié)17 2018-2019消費(fèi)金融市場(chǎng)行情
課時(shí)108 揭秘:近年消費(fèi)金融火爆發(fā)展根本原因
課時(shí)109 持牌照消費(fèi)金融公司盈利排行榜
課時(shí)110 消費(fèi)金融,風(fēng)控技術(shù)是瓶頸
課時(shí)111 誰(shuí)能笑到最后:2018-2019消費(fèi)金融公司注冊(cè)資本
課時(shí)112 蘿卜加大棒:中央政策趨勢(shì)獨(dú)家預(yù)測(cè)
課時(shí)113 信用是金融交易的基石_P2P倒閉潮秘密
章節(jié)18 2018-2019年全球宏觀經(jīng)濟(jì)
課時(shí)114 專家不會(huì)告訴你的秘密:美元和黃金真實(shí)關(guān)系
課時(shí)115 宏觀經(jīng)濟(jì)主要指標(biāo):債務(wù)率和失業(yè)率
課時(shí)116 2019年中國(guó)宏觀經(jīng)濟(jì)分析_贈(zèng)人民銀行發(fā)布2018n年中國(guó)金融穩(wěn)定報(bào)告
課時(shí)117 2019年G20國(guó)家宏觀經(jīng)濟(jì)信息匯總_供下載
課時(shí)118 全球系統(tǒng)金融風(fēng)險(xiǎn)
課時(shí)119 基尼系數(shù)_貧富差異指標(biāo)
課時(shí)120 GDP_利率_通貨膨脹
課時(shí)121 失業(yè)率_債務(wù)率
課時(shí)122 貿(mào)易差額_中美貿(mào)易戰(zhàn)根本原因
課時(shí)123 信用評(píng)級(jí)_阿根廷金融危機(jī)獨(dú)家解讀
?
?為什么需要風(fēng)控模型?
風(fēng)控模型目的將銀行風(fēng)險(xiǎn)最小化并將利潤(rùn)最大化。貸款有風(fēng)險(xiǎn),如果用戶借錢不還或故意騙貸,銀行就會(huì)有損失。風(fēng)控模型作用就是識(shí)別這些借錢不還用戶,然后過(guò)濾掉這些壞用戶。這樣銀行放款對(duì)象基本是優(yōu)質(zhì)客戶,可以從中賺取利息,從而達(dá)到利潤(rùn)最大化,風(fēng)險(xiǎn)最小化。
為了從銀行的角度將損失降到最低,銀行需要制定決策規(guī)則,確定誰(shuí)批準(zhǔn)貸款,誰(shuí)不批準(zhǔn)。 在決定貸款申請(qǐng)之前,貸款經(jīng)理會(huì)考慮申請(qǐng)人的人口統(tǒng)計(jì)和社會(huì)經(jīng)濟(jì)概況。
德國(guó)信貸數(shù)據(jù)包含有關(guān)20個(gè)變量的數(shù)據(jù),以及1000個(gè)貸款申請(qǐng)者被認(rèn)為是好信用風(fēng)險(xiǎn)還是壞信用風(fēng)險(xiǎn)的分類。 這是指向德國(guó)信用數(shù)據(jù)的鏈接(右鍵單擊并另存為)。 預(yù)期基于此數(shù)據(jù)開發(fā)的預(yù)測(cè)模型將為銀行經(jīng)理提供指導(dǎo),以根據(jù)他/她的個(gè)人資料來(lái)決定是否批準(zhǔn)準(zhǔn)申請(qǐng)人的貸款。
風(fēng)控歷史
世界上最早的銀行出現(xiàn)在意大利。 最早的銀行是意大利1407年在威尼斯成立的銀行。當(dāng)然類似于銀行的機(jī)構(gòu)可能存更早存在。只要有銀行,就會(huì)有風(fēng)險(xiǎn)控制和管理,即風(fēng)控。早期風(fēng)控包括對(duì)借貸人資質(zhì)審核和賬戶核實(shí)。

隨著金融業(yè)發(fā)展,貸款流程逐漸完善,包括下圖流程

2000-2008后,全球逐步進(jìn)入大數(shù)據(jù)時(shí)代,隨著用戶數(shù)據(jù)整合,誕生央行征信,公安人臉數(shù)據(jù),芝麻信用分,同盾分,聚信立蜜罐分,百度黑中介分等參考數(shù)據(jù)。銀行,消費(fèi)金融公司,小額貸公司可以利用大數(shù)據(jù)建模,利用機(jī)器智能決策代替絕大部分人工審核,縮短信貸流程,減少貸款風(fēng)險(xiǎn),實(shí)現(xiàn)利潤(rùn)最大化。

現(xiàn)代大數(shù)據(jù)時(shí)代的風(fēng)控部門主要分為貸前,貸中和貸后管理三個(gè)板塊。

信用危機(jī)時(shí)代的信用評(píng)分卡
20世紀(jì)后,銀行業(yè)飛速發(fā)展。隨著我國(guó)居民消費(fèi)心理發(fā)生改變和各大商家誘導(dǎo)性消費(fèi),不少朋友越來(lái)越依賴超前消費(fèi)了。我國(guó)14億人口,消費(fèi)群體龐大,各類產(chǎn)品也有著很大的市場(chǎng),于是現(xiàn)在的消費(fèi)信貸市場(chǎng)成了很多銀行或者其他機(jī)構(gòu)發(fā)力的方向。根據(jù)央行公布的數(shù)據(jù)來(lái)看,商業(yè)銀行發(fā)行的信用卡數(shù)量繼續(xù)擴(kuò)張,但在“濫發(fā)”信用卡的背后,逾期壞賬不斷增加也成了銀行頭疼問(wèn)題。
信用卡逾期半年以上壞賬突破900億
近日,央行公布了三季度支付體系的運(yùn)行報(bào)告,從央行公布的數(shù)據(jù)來(lái)看,我國(guó)商業(yè)銀行發(fā)行的信用卡數(shù)量、授信總額以及壞賬總額均在保持增長(zhǎng)。
數(shù)據(jù)顯示,截至今年三季度末,我國(guó)商業(yè)銀行發(fā)行的信用卡(包括借貸合一卡)的數(shù)量達(dá)到了7.66億張,環(huán)比增加1.29%。總授信額度達(dá)到了18.59萬(wàn)億元,環(huán)比增加3.80%。
下卡量在增加,加上授信總額在不斷增長(zhǎng),說(shuō)明銀行依舊非常重視信用卡市場(chǎng),但同時(shí)這也給銀行帶來(lái)了不小的麻煩。因?yàn)榻刂两衲耆径饶庞每ㄓ馄诎肽暌陨系膲馁~來(lái)到了906.63億元,環(huán)比大漲6.13%。
信用卡下卡數(shù)量不斷增加,說(shuō)明在初審階段銀行并沒(méi)有管理的太嚴(yán)格,因此壞賬增加是客觀會(huì)存在的問(wèn)題。

之前銀行是當(dāng)鋪思想,把錢借給有償還能力的人。這些人群算是優(yōu)質(zhì)客群。更糟糕的是但隨著量化寬松,財(cái)政貨幣刺激,M2激增,銀行,消費(fèi)金融公司,小額貸公司紛紛把市場(chǎng)目標(biāo)擴(kuò)大到次級(jí)客戶,即償還能力不足或沒(méi)有工作的人,這些人還錢風(fēng)險(xiǎn)很高,因此借錢利息也很高。作為小額貸,助貸,消費(fèi)金融公司的貸前審批人員,是否經(jīng)歷過(guò)下圖的場(chǎng)景?騙貸,黑中介,灰色產(chǎn)業(yè)鏈,他們無(wú)孔不入,搞得你們暈頭轉(zhuǎn)向,不好判斷用戶還要領(lǐng)導(dǎo)拍腦殼決定是否放貸。

國(guó)內(nèi)黑產(chǎn),灰產(chǎn)已經(jīng)形成龐大產(chǎn)業(yè)鏈條。根據(jù)之前同盾公司統(tǒng)計(jì),黑產(chǎn)團(tuán)隊(duì)至少上千個(gè),多大為3人左右小團(tuán)隊(duì),100人以上大團(tuán)隊(duì)也有幾十上百個(gè)。這些黑產(chǎn)團(tuán)隊(duì)天天測(cè)試各大現(xiàn)金貸平臺(tái)漏洞,可謂專業(yè)產(chǎn)品經(jīng)理。下圖是生產(chǎn)虛假號(hào)碼的手機(jī)卡,來(lái)自東南亞,國(guó)內(nèi)可用,可最大程度規(guī)避國(guó)內(nèi)安全監(jiān)控,專門為線上平臺(tái)現(xiàn)金貸詐騙用戶準(zhǔn)備。,如果沒(méi)有風(fēng)控能力,就不要玩現(xiàn)金貸這行了。放款猶如肉包子打狗有去無(wú)回。

舉個(gè)身邊熟悉例子,作者在之前某寶關(guān)鍵詞搜索中,可以發(fā)現(xiàn)黑產(chǎn)和灰產(chǎn)身影。
?關(guān)鍵詞:
注冊(cè)機(jī),短信服務(wù),短信接收,短信驗(yàn)證,app下單,智能終端代接m
?



?黑產(chǎn)市場(chǎng)風(fēng)起云涌,銀行風(fēng)控負(fù)責(zé)人改如何應(yīng)對(duì)持續(xù)上升信用卡壞賬?作者認(rèn)為識(shí)別壞客戶(騙貸和還款能力不足人群)是關(guān)鍵。只有銀行精準(zhǔn)識(shí)別了壞客戶,才能顯著降低逾期和壞賬率。如何精準(zhǔn)識(shí)別壞客戶,改課程會(huì)手把手教你大家Python信用評(píng)分卡模型,精準(zhǔn)捕捉壞客戶,此乃風(fēng)控守護(hù)神。
信用評(píng)分卡可以成為貸款人和借款人計(jì)算借款人償債能力的絕佳工具。對(duì)于貸方而言,評(píng)分卡可以幫助他們?cè)u(píng)估借款人的風(fēng)險(xiǎn),識(shí)別是否是騙貸用戶或還款能力不足用戶,并幫公司維持健康的投資組合 - 這最終將影響整個(gè)經(jīng)濟(jì)。
模型就像一個(gè)黑箱,當(dāng)用戶申請(qǐng)貸款時(shí),模型會(huì)根據(jù)用戶信息,例如年齡,工作,職位,還款記錄,借貸次數(shù)等維度自動(dòng)計(jì)算客戶壞客戶概率。業(yè)務(wù)線如果用模型計(jì)算出某用戶壞客戶概率較高,例如0.8,就會(huì)拒絕改客戶貸款申請(qǐng)。
因此風(fēng)控模型就像信貸守護(hù)神,保護(hù)公司資產(chǎn),免受黑產(chǎn)吞噬。評(píng)分卡模型自動(dòng)化評(píng)分,1秒之內(nèi)決定客戶是否通過(guò),貸前人員工作輕松多了!這樣,大數(shù)據(jù)時(shí)代下的風(fēng)控模型就此誕生。

(評(píng)分卡模型自動(dòng)批量識(shí)別壞客戶)
?
信用評(píng)分卡建模數(shù)據(jù)
http://archive.ics.uci.edu/ml/datasets/Statlog+(German+Credit+Data)

?
account balance 賬戶余額
duration of credit

建模數(shù)據(jù)信息Data Set Information:
Two
datasets are provided. the original dataset, in the form provided by
Prof. Hofmann, contains categorical/symbolic attributes and is in the
file "german.data".?
For algorithms that need numerical
attributes, Strathclyde University produced the file
"german.data-numeric". This file has been edited and several indicator
variables added to make it suitable for algorithms which cannot cope
with categorical variables. Several attributes that are ordered
categorical (such as attribute 17) have been coded as integer. This was
the form used by StatLog.?
This dataset requires use of a cost matrix (see below)?
提供了兩個(gè)數(shù)據(jù)集。 原始數(shù)據(jù)集以Hofmann教授提供的形式包含類別/符號(hào)屬性,并且位于文件“ german.data”中。
對(duì)于需要數(shù)字屬性的算法,斯特拉斯克萊德大學(xué)產(chǎn)生了文件“ german.data-numeric”。 該文件已經(jīng)過(guò)編輯,并添加了一些指標(biāo)變量,以使其適用于無(wú)法處理分類變量的算法。 幾個(gè)按類別排序的屬性(例如屬性17)已編碼為整數(shù)。 這是StatLog使用的形式。
該數(shù)據(jù)集需要使用成本矩陣(請(qǐng)參見(jiàn)下文)
..... 1 2?
----------------------------?
1 0 1?
-----------------------?
2 5 0?
(1 = Good, 2 = Bad)?
The rows represent the actual classification and the columns the predicted classification.?
It is worse to class a customer as good when they are bad (5), than it is to class a customer as bad when they are good (1).?
?
Attribute Information:
Attribute 1: (qualitative)?
Status of existing checking account?
A11 : ... < 0 DM?
A12 : 0 <= ... < 200 DM?
A13 : ... >= 200 DM / salary assignments for at least 1 year?
A14 : no checking account?
Attribute 2: (numerical)?
Duration in month?
Attribute 3: (qualitative)?
Credit history?
A30 : no credits taken/ all credits paid back duly?
A31 : all credits at this bank paid back duly?
A32 : existing credits paid back duly till now?
A33 : delay in paying off in the past?
A34 : critical account/ other credits existing (not at this bank)?
Attribute 4: (qualitative)?
Purpose?
A40 : car (new)?
A41 : car (used)?
A42 : furniture/equipment?
A43 : radio/television?
A44 : domestic appliances?
A45 : repairs?
A46 : education?
A47 : (vacation - does not exist?)?
A48 : retraining?
A49 : business?
A410 : others?
Attribute 5: (numerical)?
Credit amount?
Attibute 6: (qualitative)?
Savings account/bonds?
A61 : ... < 100 DM?
A62 : 100 <= ... < 500 DM?
A63 : 500 <= ... < 1000 DM?
A64 : .. >= 1000 DM?
A65 : unknown/ no savings account?
Attribute 7: (qualitative)?
Present employment since?
A71 : unemployed?
A72 : ... < 1 year?
A73 : 1 <= ... < 4 years?
A74 : 4 <= ... < 7 years?
A75 : .. >= 7 years?
Attribute 8: (numerical)?
Installment rate in percentage of disposable income?
Attribute 9: (qualitative)?
Personal status and sex?
A91 : male : divorced/separated?
A92 : female : divorced/separated/married?
A93 : male : single?
A94 : male : married/widowed?
A95 : female : single?
Attribute 10: (qualitative)?
Other debtors / guarantors?
A101 : none?
A102 : co-applicant?
A103 : guarantor?
Attribute 11: (numerical)?
Present residence since?
Attribute 12: (qualitative)?
Property?
A121 : real estate?
A122 : if not A121 : building society savings agreement/ life insurance?
A123 : if not A121/A122 : car or other, not in attribute 6?
A124 : unknown / no property?
Attribute 13: (numerical)?
Age in years?
Attribute 14: (qualitative)?
Other installment plans?
A141 : bank?
A142 : stores?
A143 : none?
Attribute 15: (qualitative)?
Housing?
A151 : rent?
A152 : own?
A153 : for free?
Attribute 16: (numerical)?
Number of existing credits at this bank?
Attribute 17: (qualitative)?
Job?
A171 : unemployed/ unskilled - non-resident?
A172 : unskilled - resident?
A173 : skilled employee / official?
A174 : management/ self-employed/?
highly qualified employee/ officer?
Attribute 18: (numerical)?
Number of people being liable to provide maintenance for?
Attribute 19: (qualitative)?
Telephone?
A191 : none?
A192 : yes, registered under the customers name?
Attribute 20: (qualitative)?
foreign worker?
A201 : yes?
A202 : no?
?
It is worse to class a customer as good when they are bad (5),
than it is to class a customer as bad when they are good (1).
評(píng)分卡開發(fā)流程
本課程通俗易懂,深度解析評(píng)分卡模型的各個(gè)細(xì)節(jié),猶如庖丁解牛,各個(gè)擊破。

課程會(huì)橫向講解評(píng)分卡模型是如何一步一步搭建的。

?
?數(shù)學(xué)原理
課程還會(huì)講述邏輯回歸的信用評(píng)分卡搭建背后的算法原理,數(shù)學(xué)公式。

?
取數(shù)
課程教會(huì)學(xué)員如何取數(shù),什么是vintage?什么是樣本窗口期?
?

?
變量篩選
課程教授如何篩選變量,如何構(gòu)建衍生變量。

模型變量重要性排序結(jié)果
通過(guò)變量重要性排序,我們可以觀察到下圖中條狀越長(zhǎng)的變量,重要性越高,反之亦然。例如credit amount信用額度在下圖是最長(zhǎng)的,因此是最重要的變量。信用額度是指銀行承諾提供貸款人的最高額度。一般情況下借貸人信譽(yù)越好,違約記錄越少,信用額度越高;如果用戶經(jīng)常借錢不還,信譽(yù)差,信用額度越低。銀行喜歡把錢借給信用額度高的用戶,從而賺取利息。反正,銀行不喜歡把錢借給信用額度低用戶,這些用戶本金可能還不上,銀行不僅賺不到利息,而且虧損。


?
課程提供python腳本和數(shù)據(jù)下載
課程提供視頻中展示腳本和建模數(shù)據(jù),并定期更新優(yōu)化。學(xué)員可以下載后跟著視頻一起演練。

模型運(yùn)行后輸出詳細(xì)信息,包括變量的統(tǒng)計(jì)分析。

?
評(píng)分卡生成(score card)
python腳本可以生成一個(gè)評(píng)分卡模塊(score card),詳細(xì)保存每個(gè)變量有哪些分箱,每個(gè)分箱如何計(jì)分。這方便業(yè)務(wù)方和領(lǐng)導(dǎo)參考決策。


?
拒絕推斷reject reference
課程講述了拒絕推斷reject reference重要概念

?
?
模型驗(yàn)證
課程還講述模型驗(yàn)證的概念,建模數(shù)據(jù)需要分為train訓(xùn)練數(shù)據(jù),test測(cè)試數(shù)據(jù),oot更遠(yuǎn)時(shí)間段驗(yàn)證數(shù)據(jù)。此教程是市面上最全面講述評(píng)分卡教程。


?

?????????????????????????????????????????????????????????????????????????????
?
模型部署和監(jiān)控
此教程還概述模型部署和監(jiān)控知識(shí)。模型部署是存在眾多問(wèn)題的,模型具有操作風(fēng)險(xiǎn),經(jīng)常會(huì)遇到模型線上線下數(shù)據(jù)不一致情況,變量映射錯(cuò)誤,數(shù)據(jù)傳輸丟包,腳本漏寫等等各種復(fù)雜情況。
從模型訓(xùn)練,模型打包,模型驗(yàn)證,模型部署,模型監(jiān)控,重新訓(xùn)練模型,最終形成了一個(gè)模型開發(fā)周期閉環(huán)。

python部分建模腳本展示
randomForest.py
random forest with 1000 trees:
accuracy on the training subset:1.000
accuracy on the test subset:0.772
準(zhǔn)確性高于決策樹
# -*- coding: utf-8 -*-
"""
博主python金融風(fēng)控評(píng)分卡模型和數(shù)據(jù)分析微專業(yè)課:https://ke.qq.com/course/package/31250?tuin=dcbf0ba
博主微信公眾號(hào):pythonEducation
@author: 231469242@qq.com
隨機(jī)森林不需要預(yù)處理數(shù)據(jù)
"""
import
?pandas as pd
import
?numpy as np
import
?matplotlib.pyplot as plt
from
?sklearn.ensemble?
import
?RandomForestClassifier
from
?sklearn.model_selection?
import
?train_test_split
?
trees
=
1000
#讀取文件
readFileName
=
"German_credit.xlsx"
#讀取excel
df
=
pd.read_excel(readFileName)
list_columns
=
list
(df.columns[:
-
1
])
X
=
df.ix[:,:
-
1
]
y
=
df.ix[:,
-
1
]
names
=
X.columns
x_train,x_test,y_train,y_test
=
train_test_split(X,y,random_state
=
0
)
#n_estimators表示樹的個(gè)數(shù),測(cè)試中100顆樹足夠
forest
=
RandomForestClassifier(n_estimators
=
trees,random_state
=
0
)
forest.fit(x_train,y_train)
print
(
"random forest with %d trees:"
%
trees)?
print
(
"accuracy on the training subset:{:.3f}"
.
format
(forest.score(x_train,y_train)))
print
(
"accuracy on the test subset:{:.3f}"
.
format
(forest.score(x_test,y_test)))
print
(
'Feature importances:{}'
.
format
(forest.feature_importances_))
n_features
=
X.shape[
1
]
plt.barh(
range
(n_features),forest.feature_importances_,align
=
'center'
)
plt.yticks(np.arange(n_features),names)
plt.title(
"random forest with %d trees:"
%
trees)
plt.xlabel(
'Feature Importance'
)
plt.ylabel(
'Feature'
)
plt.show()

比較之前

決策樹可視化

?
準(zhǔn)確率不高,且嚴(yán)重過(guò)度擬合
accuracy on the training subset:
0.991
accuracy on the test subset:
0.680
import
?pandas as pd
import
?numpy as np
import
?matplotlib.pyplot as plt
from
?sklearn.ensemble?
import
?RandomForestClassifier
import
?matplotlib.pyplot as plt
import
?numpy as np
import
?pydotplus
from
?IPython.display?
import
?Image
import
?graphviz
from
?sklearn.tree?
import
?export_graphviz
from
?sklearn.datasets?
import
?load_breast_cancer
from
?sklearn.tree?
import
?DecisionTreeClassifier
from
?sklearn.model_selection?
import
?train_test_split
?
trees
=
1000
#讀取文件
readFileName
=
"German_credit.xlsx"
#讀取excel
df
=
pd.read_excel(readFileName)
list_columns
=
list
(df.columns[:
-
1
])
x
=
df.ix[:,:
-
1
]
y
=
df.ix[:,
-
1
]
names
=
x.columns
x_train,x_test,y_train,y_test
=
train_test_split(x,y,random_state
=
0
)
#調(diào)參
list_average_accuracy
=
[]
depth
=
range
(
1
,
30
)
for
?i?
in
?depth:
????
#max_depth=4限制決策樹深度可以降低算法復(fù)雜度,獲取更精確值
????
tree
=
?DecisionTreeClassifier(max_depth
=
i,random_state
=
0
)
????
tree.fit(x_train,y_train)
????
accuracy_training
=
tree.score(x_train,y_train)
????
accuracy_test
=
tree.score(x_test,y_test)
????
average_accuracy
=
(accuracy_training
+
accuracy_test)
/
2.0
????
#print("average_accuracy:",average_accuracy)
????
list_average_accuracy.append(average_accuracy)
????
?
max_value
=
max
(list_average_accuracy)
#索引是0開頭,結(jié)果要加1
best_depth
=
list_average_accuracy.index(max_value)
+
1
print
(
"best_depth:"
,best_depth)
best_tree
=
?DecisionTreeClassifier(max_depth
=
best_depth,random_state
=
0
)
best_tree.fit(x_train,y_train)
accuracy_training
=
best_tree.score(x_train,y_train)
accuracy_test
=
best_tree.score(x_test,y_test)
print
(
"decision tree:"
)???
print
(
"accuracy on the training subset:{:.3f}"
.
format
(best_tree.score(x_train,y_train)))
print
(
"accuracy on the test subset:{:.3f}"
.
format
(best_tree.score(x_test,y_test)))
?
n_features
=
x.shape[
1
]
plt.barh(
range
(n_features),best_tree.feature_importances_,align
=
'center'
)
plt.yticks(np.arange(n_features),names)
plt.title(
"Decision Tree:"
)
plt.xlabel(
'Feature Importance'
)
plt.ylabel(
'Feature'
)
plt.show()
?
#生成一個(gè)dot文件,以后用cmd形式生成圖片
export_graphviz(best_tree,out_file
=
"creditTree.dot"
,class_names
=
[
'bad'
,
'good'
],feature_names
=
names,impurity
=
False
,filled
=
True
)
'''
best_depth: 12
decision tree:
accuracy on the training subset:0.991
accuracy on the test subset:0.680
'''