Git Product home page Git Product logo

demo-bank-customer-churn's Introduction

Predicting Churn for Bank Customers

Dataset source

https://www.kaggle.com/adammaus/predicting-churn-for-bank-customers

Description

This dataset contains 10,000 records, each of it corresponds to a different bank's user. The target is ExitedTask, a binary variable that describes whether the user decided to leave the bank. There are row and customer identifiers, four columns describing personal information about the user (surname, location, gender and age), and some other columns containing information related to the loan (such as credit score, current balance in the user's account and whether they are an active member among others).

Use Case

The objective is to train a ML model that returns the probability of a customer to churn. This is a binary classification task, therefore F1-score is a good metric to evaluate the performance of this dataset as itweights recall and precision equally, and a good retrieval algorithm will maximize both precision and recall simultaneously.

Installation

Python 3.7+ is required to run code from this repo.

$ git clone https://github.com/iterative/demo-bank-customer-churn
$ cd demo-bank-customer-churn

Now let's install the requirements. But before we do that, we strongly recommend creating a virtual environment with a tool such as virtualenv:

$ virtualenv -p python3 .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt

Running in your environment

This DVC project comes with a preconfigured DVC remote storage that holds raw data (input), intermediate, and final results that are produced. This is a read-only HTTP remote.

$ dvc remote list
storage https://remote.dvc.org/demo-bank-customer-churn

You can run dvc pull to download the data:

$ dvc pull

Now you can start a Jupyter Notebook server and execute the notebook notebook/TrainChurnModel.ipynb top to bottom to train a model

$ jupyter notebook

If you'd like to test commands like dvc push, that require write access to the remote storage, the easiest way would be to set up a "local remote" on your file system:

This kind of remote is located in the local file system, but is external to the DVC project.

$ mkdir -p /tmp/dvc-storage
$ dvc remote add local /tmp/dvc-storage

You should now be able to run:

$ dvc push -r local

Running DVC pipeline

Set PYTHONPATH to the project's path:

$ export PYTHONPATH=$PWD

Execute DVC pipeline

$ dvc repro

Running web server with MLEM

To start up FastAPI server run:

$ mlem serve clf fastapi
โณ๏ธ Loading model from .mlem/model/clf.mlem
Starting fastapi server...
๐Ÿ’… Adding route for /predict
๐Ÿ’… Adding route for /predict_proba
๐Ÿ’… Adding route for /sklearn_predict
๐Ÿ’… Adding route for /sklearn_predict_proba
Checkout openapi docs at <http://0.0.0.0:8080/docs>

To test the API:

curl -X 'POST' 'http://0.0.0.0:8080/predict_proba' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{
  "data": {
    "values": [
      {
        "": 0,
        "CreditScore": 619,
        "Age": 42,
        "Tenure": 2,
        "Balance": 0,
        "NumOfProducts": 1,
        "HasCrCard": 1,
        "IsActiveMember": 1,
        "EstimatedSalary": 101348.88
      }
    ]
  }
}'
[[0.8074799482954296,0.19252005170457026]]

demo-bank-customer-churn's People

Contributors

alex000kim 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.