Git Product home page Git Product logo

credit_default's Introduction

credit_default

信用卡违约率分析:

针对**某银行信用卡的数据,构建一个分析信用卡违约率的分类器。采用Random Forest算法,信用卡违约率识别率在80%左右。

这个数据集是**某银行 2005 年 4 月到 9 月的信用卡数据,数据集一共包括 25 个字段,具体含义如下:

image

现在我们的目标是要针对这个数据集构建一个分析信用卡违约率的分类器。具体选择哪个分类器,以及分类器的参数如何优化,我们可以用 GridSearchCV 这个工具跑一遍。 先梳理下整个项目的流程:

image

  1. 加载数据;
  2. 准备阶段:探索数据,采用数据可视化方式可以让我们对数据有更直观的了解,比如我们想要了解信用卡违约率和不违约率的人数。因为数据集没有专门的测试集,我们还需要使用train_test_split 划分数据集。
  3. 分类阶段:之所以把数据规范化放到这个阶段,是因为我们可以使用 Pipeline 管道机制,将数据规范化设置为第一步,分类为第二步。因为我们不知道采用哪个分类器效果好,所以我们需要多用几个分类器,比如 SVM、决策树、随机森林和 KNN。然后通过 GridSearchCV 工具,找到每个分类器的最优参数和最优分数,最终找到最适合这个项目的分类器和该分类器的参数。 基于上面的流程,具体代码如下:

image image

运行结果:

image image image image image image

从结果中,我们能看到 SVM 分类器的准确率最高,测试准确率为 0.8172。

在决策树分类中,我设置了 3 种最大深度,当最大深度 =6 时结果最优,测试准确率为0.8113;

在随机森林分类中,我设置了 3 个决策树个数的取值,取值为 6 时结果最优,测试准确率为 0.7994;

在 KNN 分类中,我设置了 3 个 n 的取值,取值为 8 时结果最优,测试准确率为 0.8036。

credit_default's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.