GithubHelp home page GithubHelp logo

churnprediction's Introduction

Churn Prediction

Introduction

Churn Prediction is a collection of python scripts to explore how to create churn prediction models using the BG/NBG Pareto models.

Most importantly, churn prediction and training the above mentioned models is used as a playground to investigate the integration between python Pandas and database systems.

The idea is that the database system can be used to do the heavy lifting of feature generation when the volume of the data is large, extracting only the final feature table that is going to be used for training.

As raw data, events that are generated by RudderStack and correspond to the customer behavior are considered.

๐Ÿ’ฃ Implementations

What you will find in this repo

๐Ÿ‘‰ csv2parquet is a small utility script that takes a csv as input and turns it into a parquet file. It uses the arrow python library for parsing and generating the parquet file.

๐Ÿ‘‰ train_model This script attempts to train a model assuming event data are stored into a parquet file. To make it scalable we are using duckdb to query the data on Parquet. Duckdb exploits the parquet format to execute the queries. After the features have been generated the model is trained and saved.

๐Ÿ‘‰ train_model_snow This script is doing the exact same thing as the previous one but this time we assume the data to live on Snowflake. The feature generation happens on snowflake and data is returned to the script to be used for training the model which is then saved.

The Snowflake python connector supports Arrow as a serialization format, this has the benefit of reducing the ser/des that have to happen and hopefully increasing the performance. The data is returned back into a panda's dataframe so no conversion needs to happen there.

In a similar way, Duckdb returns the data into a dataframe format that again is used directly for training the model. Duckdb is still not as mature as snowflake when it comes to data manipulation functions that are supported and there's where the conversion to a dataframe really helped. Some of the manipulation happened after the data was loaded in memory.

BigQuery also offers arrow serialization over their APIs, as a next step I'll look into it and see how it works. Then we can run some tests around performance and scalability.

Keep in mind that the model training is single threaded, when I'm talking about performance and scalability here I'm talking only about shaping the data and calculating the features that we need.

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.