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

Python说明名誉卡反诓骗!骗我措施员,不存在的

发布时间:2019-10-13 08:02:53 所属栏目:教程 来源:一枚程序媛呀
导读:媒介: 本文研究的是大数据量(284807条数据)下模子选择的题目,也参考了一些文献,但大多不足清楚,因此吐血清算本文,但愿对各人有辅佐; 本文试着从数据说明师的角度,假想拿到数据该怎样探求纪律、选哪种模子来构建反诓骗模子?的角度来说明,以营业导向

6.2 随机丛林模子

  1. from sklearn.ensemble import RandomForestClassifier 
  2. rfmodel=RandomForestClassifier() 
  3. rfmodel.fit(x_train,y_train) 
  4. #查察模子 
  5. print('rfmodel') 
  6. rfmodel 
  7. rfmodel 
  8. RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini', 
  9.  max_depth=None, max_features='auto', max_leaf_nodes=None, 
  10.  min_impurity_decrease=0.0, min_impurity_split=None, 
  11.  min_samples_leaf=1, min_samples_split=2, 
  12.  min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1, 
  13.  oob_score=False, random_state=None, verbose=0, 
  14.  warm_start=False) 
  15. #查察夹杂矩阵 
  16. ypred_rf=rfmodel.predict(x_test) 
  17. print('confusion_matrix') 
  18. print(metrics.confusion_matrix(y_test,ypred_rf)) 
  19. confusion_matrix 
  20. [[85291 4] 
  21.  [ 34 114]] 
  22. #查察分类陈诉 
  23. print('classification_report') 
  24. print(metrics.classification_report(y_test,ypred_rf)) 
  25. classification_report 
  26.  precision recall f1-score support 
  27.  0 1.00 1.00 1.00 85295 
  28.  1 0.97 0.77 0.86 148 
  29. avg / total 1.00 1.00 1.00 85443 
  30. #查察猜测精度与决定包围面 
  31. print('Accuracy:%f'%(metrics.accuracy_score(y_test,ypred_rf))) 
  32. print('Area under the curve:%f'%(metrics.roc_auc_score(y_test,ypred_rf))) 
  33. Accuracy:0.999625 
  34. Area under the curve:0.902009 

6.3支持向量机SVM

  1. # SVM分类 
  2. from sklearn.svm import SVC 
  3. svcmodel=SVC(kernel='sigmoid') 
  4. svcmodel.fit(x_train,y_train) 
  5. #查察模子 
  6. print('svcmodel') 
  7. svcmodel 
  8. SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, 
  9.  decision_function_shape='ovr', degree=3, gamma='auto', kernel='sigmoid', 
  10.  max_iter=-1, probability=False, random_state=None, shrinking=True, 
  11.  tol=0.001, verbose=False) 
  12. #查察夹杂矩阵 
  13. ypred_svc=svcmodel.predict(x_test) 
  14. print('confusion_matrix') 
  15. print(metrics.confusion_matrix(y_test,ypred_svc)) 
  16. confusion_matrix 
  17. [[85197 98] 
  18.  [ 142 6]] 
  19. #查察分类陈诉 
  20. print('classification_report') 
  21. print(metrics.classification_report(y_test,ypred_svc)) 
  22. classification_report 
  23.  precision recall f1-score support 
  24.  0 1.00 1.00 1.00 85295 
  25.  1 0.06 0.04 0.05 148 
  26. avg / total 1.00 1.00 1.00 85443 
  27. #查察猜测精度与决定包围面 
  28. print('Accuracy:%f'%(metrics.accuracy_score(y_test,ypred_svc))) 
  29. print('Area under the curve:%f'%(metrics.roc_auc_score(y_test,ypred_svc))) 
  30. Accuracy:0.997191 
  31. Area under the curve:0.519696 

7、小结

  1. 通过三种模子的示意可知,随机丛林的误杀率最低;
  2. 不该只盯着精度,偶然辰模子的精度高并不能声名模子就好,出格是像本项目中这样的数据严峻不服衡的环境。举个例子,我们拿到有1000条病人的数据集,个中990工钱康健,10个有癌症,我们要通过建模找出这10个癌症病人,假如一个模子猜测到了所有康健的990人,而10个病人一个都没找到,此时其正确率如故有99%,但这个模子是无用的,并没有到达我们探求病人的目标;
  3. 建模说明时,碰着像本例这样的十分不服衡数据集,因采纳下采样、过采样等步伐,使数据均衡,这样的猜测才故意义,下一篇文章将针对这个题目举办改造;
  4. 模子、算法并没有坎坷、优劣之分,只是在差异的环境下有差异的施展而已,这点应正确的对待。

(编辑:湖南网)

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

热点阅读