加入收藏 | 设为首页 | 会员中心 | 我要投稿 西安站长网 (https://www.029zz.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

Python分析信用卡反欺诈!骗我程序员,不存在的

发布时间:2019-10-14 19:31:54 所属栏目:教程 来源:一枚程序媛呀
导读:副标题#e# 前言: 本文研究的是大数据量(284807条数据)下模型选择的问题,也参考了一些文献,但大多不够清晰,因此吐血整理本文,希望对大家有帮助; 本文试着从数据分析师的角度,设想拿到数据该如何寻找规律、选哪种模型来构建反欺诈模型?的角度来分析,以

3、欺诈与时间序列分布关系

  1. # 查看二者的描述性统计,与时间的序列分布关系 
  2. print('Normal') 
  3. print(crecreditcard_data. 
  4.  Time[crecreditcard_data.Class == 0].describe()) 
  5. print('-'*25) 
  6. print('Fraud') 
  7. print(crecreditcard_data. 
  8.  Time[crecreditcard_data.Class == 1].describe()) 
  9. Normal 
  10. count 284315.000000 
  11. mean 94838.202258 
  12. std 47484.015786 
  13. min 0.000000 
  14. 25% 54230.000000 
  15. 50% 84711.000000 
  16. 75% 139333.000000 
  17. max 172792.000000 
  18. Name: Time, dtype: float64 
  19. ------------------------- 
  20. Fraud 
  21. count 492.000000 
  22. mean 80746.806911 
  23. std 47835.365138 
  24. min 406.000000 
  25. 25% 41241.500000 
  26. 50% 75568.500000 
  27. 75% 128483.000000 
  28. max 170348.000000 
  29. Name: Time, dtype: float64 
  30. f,(ax1,ax2)=plt.subplots(2,1,sharex=True,figsize=(12,6)) 
  31. bins=50 
  32. ax1.hist(crecreditcard_data.Time[crecreditcard_data.Class == 1],bins=bins) 
  33. ax1.set_title('欺诈(Fraud))',fontsize=22) 
  34. ax1.set_ylabel('交易量',fontsize=15) 
  35. ax2.hist(crecreditcard_data.Time[crecreditcard_data.Class == 0],bins=bins) 
  36. ax2.set_title('正常(Normal',fontsize=22) 
  37. plt.xlabel('时间(单位:秒)',fontsize=15) 
  38. plt.xticks(fontsize=15) 
  39. plt.ylabel('交易量',fontsize=15) 
  40. # plt.yticks(fontsize=22) 
  41. plt.show() 
Python分析信用卡反欺诈!骗我程序员,不存在的

欺诈与时间并没有必然联系,不存在周期性;

正常交易有明显的周期性,有类似双峰这样的趋势。

4、欺诈与金额的关系和分布情况

  1. print('欺诈') 
  2. print(crecreditcard_data.Amount[crecreditcard_data.Class ==1].describe()) 
  3. print('-'*25) 
  4. print('正常交易') 
  5. print(crecreditcard_data.Amount[crecreditcard_data.Class==0].describe()) 
  6. 欺诈 
  7. count 492.000000 
  8. mean 122.211321 
  9. std 256.683288 
  10. min 0.000000 
  11. 25% 1.000000 
  12. 50% 9.250000 
  13. 75% 105.890000 
  14. max 2125.870000 
  15. Name: Amount, dtype: float64 
  16. ------------------------- 
  17. 正常交易 
  18. count 284315.000000 
  19. mean 88.291022 
  20. std 250.105092 
  21. min 0.000000 
  22. 25% 5.650000 
  23. 50% 22.000000 
  24. 75% 77.050000 
  25. max 25691.160000 
  26. Name: Amount, dtype: float64 
  27. f,(ax1,ax2)=plt.subplots(2,1,sharex=True,figsize=(12,6)) 
  28. bins=30 
  29. ax1.hist(crecreditcard_data.Amount[crecreditcard_data.Class == 1],bins=bins) 
  30. ax1.set_title('欺诈(Fraud)',fontsize=22) 
  31. ax1.set_ylabel('交易量',fontsize=15) 
  32. ax2.hist(crecreditcard_data.Amount[crecreditcard_data.Class == 0],bins=bins) 
  33. ax2.set_title('正常(Normal)',fontsize=22) 
  34. plt.xlabel('金额($)',fontsize=15) 
  35. plt.xticks(fontsize=15) 
  36. plt.ylabel('交易量',fontsize=15) 
  37. plt.yscale('log') 
  38. plt.show() 
Python分析信用卡反欺诈!骗我程序员,不存在的

金额普遍较低,可见金额这一列的数据对分析的参考价值不大。

5、查看各个自变量(V1-V29)与因变量的关系

(编辑:西安站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读