Skip to content

Final project of the Udacity Nanodegree Data Scientist. Goal of the project is to predict churn with a machine learning model using Spark for a music streaming service.

Notifications You must be signed in to change notification settings

LeopoldWalther/spark-ml-churn-prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SparkBigData_ChurnDetection

In this project I analysed user interactions of a streaming service using Spark and created a machine learning model to predict user churn. The full description of the project can be found in a blog post on Medium.

Table of Contents

  1. Installation
  2. Project Motivation
  3. File Descriptions
  4. Results
  5. Licensing, Authors, and Acknowledgements

Installation

The project was created with Python 3.7.16. Install the virtual environment using the requirements.txt of the project. The follwing packages are mainly used:

  • pyspark
  • pandas
  • matplotlib
  • seaborn
  • numpy
  • re, time, datetime

Project Motivation

This is my capstone project of the Udactiy Nanodegree Data Scientist.

In this project I analysed user interactions of a streaming service using Spark. After understanding the business importance of churn, I explored a small subset of data to get a comprehension of the data and its quality. Then, I cleaned the data from missing values and created features which allow a machine learning model to find differences in the behaviour of users who stay with the service versus those who churn. With the prepared data I trained different classifiers and evaluated their performance with a suitable metric for imbalanced data. The result of the project is a Gradient-Boosted Tree Classifier which can identify users who will churn with high precision and high recall.

File Descriptions

The

SparkBigData_ChurnDetection/
│
├── README.md
├── requirements.txt
├── Sparkify.ipynb --> jupyter notebook with code for small local data subset
├── Sparkify.html
├── Sparkify_aws.ipynb --> jupyter notebook with code for aws cluster
├── Sparkify_aws.html
├── img/ --> png's created in jupyter notebook
├── models/ --> trained ML models
├── data/ --> input data JSON file

Results

The main findings of the code can be found at the post available here.

In this project I analyze user interactions of a streaming service using Spark. After understanding the business importance of churn, I explore a small subset of data to get a comprehension of the data and its quality. Then, I clean the data from missing values and create features which allow a machine learning model to find differences in the behaviour of users who stay with the service versus those who churn. With the prepared data I train different classifiers and evaluated their performance with a suitable metric for imbalanced data. The result of the project is a Gradient-Boosted Tree Classifier which can identify users who will churn with high precision and high recall:

+--------------+---------------+ |Metric | Gradient Boost| +--------------+---------------+ |F1-score | 71% | |Area under ROC| 58% | +--------------+---------------+

Licensing, Authors, Acknowledgements

I give credit to Udacity for the data (user_log).

Feel free to use my code as you please:

Copyright 2020 Leopold Walther

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Final project of the Udacity Nanodegree Data Scientist. Goal of the project is to predict churn with a machine learning model using Spark for a music streaming service.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published