Icon

ProgettoLDD_​Scarpa S

Training a Churn Predictor - Solution

Solution to exercise 13 for the KNIME Analytics Platform for Data Wranglers course
- Join data from different sources
- Apply color formatting using the Color Manager node
- Create a train and test set partitioning the data
- Train a decision tree model and evaluate the performance
- Calculate feature using the Math Formula node
- Group data into bins
- Pivot and visualize data

URL: Churn Prediction https://www.knime.org/knime-applications/churn-prediction
URL: Slides (KNIME Analytics Platform for Data Wranglers) https://www.knime.com/form/material-download-registration

Data Reading Importazione dei dataset CallsData (Excel) e ContractData (CSV) e verifica preliminare della struttura dati per comprendere il contenuto e preparare le successive fasi di trasfromazione e analisi Optional: Which customers are happier with their contract? Frequent phone users or infrequent users? 1. Use the Math Formula node to calculate the total number of minutes Recommended settings: use the following expression in the Math Formula node and append a new column with the column name Mins Total $Day Mins$+$Eve Mins$+$Night Mins$+$Intl Mins$ 2. Use the Auto-Binner node to create 10 Bins Recommended settings: Include only the column “Min Total”, set the Number of bins to 10, and select Midpoints for the Bin Naming option 3. Use the Pivoting node to find out how many customers in a bin churned. Recommended settings: - Groups: Include Min Total [Binned] - Pivots: Include Churn - Manuel Aggregation: Any Column with aggregation method count 4. Plot your results in a percentage area chart using the Stacked Area Chart node Recommended settings: - Column for x-axis: Mins Total [Binned] - Include all columns - Select Percentage-Area-Chart in the second tab (General Plot Options) Dal grafico risultante emerge che i clienti con basso e medio utilizzo tendono a rimanere, mentre all’ aumentare dell’utilizzo cresce significativamente la percentuale di churn. DDO Laboratory - Churn Prediction H ow to train a basic machine learning model for a churn prediction task, using a Decision Tree algorithm. Pre-Processing I dataset vengono integrati tramite il nodo Joiner utilizzando come chiavi comuni AreaCode e Phone. Successivamente, le variabili numeriche Churn e AreaCode vengono convertite in stringhe ed alla tabella risultante viene poi applicata una colorazione (rosso/verde) in base ai valori della variabile Churn, per facilitarne la lettura. Infine, per una migliore organizzazione del workflow, il tutto viene racchiuso all’interno di un metanodo. Model Training and Evaluation Tramite apposito nodo divido il dataset in una parte di training (80%) e una di test (20%), mantenendo la proporzione tra clienti che fanno churn e quelli che non lo fanno. Utilizzando il training set ho "allenato" il decision tree per prevedere i churn, successivamente ho applicato tale modello ai dati di test. Infine ho valutato le prestazioni utilizzando l’accuracy e la ROC curve per avere una visione più completa della qualità del modello. Valutazione Finale Per valutare il modello ho utilizzato sia lo Scorer che la ROC Curve. Dallo Scorer risulta un’accuracy del 92%, quindi il modello riesce a classificare correttamente la maggior parte dei clienti. Per avere una valutazione più completa viene considerata anche la ROC Curve la quale indica indica che il modello è abbastanza efficace nel distinguere tra clienti che abbandonano e clienti che restano. In generale, il modello mostra buone prestazioni, anche se non è perfetto e potrebbe essere ulteriormente migliorato. CallsData.xls ContractData.csv Split data (train/test) Metanode Pre-Processing Train Model Make predictions Evaluate accuracy Roc curve creation Compute total minutes Create usage bins Roc curve visualization and evaluation Count churn per bin Plot churn distribution Excel Reader CSV Reader Partitioning Pre-Processing Decision Tree Learner Decision Tree Predictor Scorer ROC Curve Math Formula Auto-Binner Image to Report (BIRT) Pivot Stacked Area Chart (JavaScript) Data Reading Importazione dei dataset CallsData (Excel) e ContractData (CSV) e verifica preliminare della struttura dati per comprendere il contenuto e preparare le successive fasi di trasfromazione e analisi Optional: Which customers are happier with their contract? Frequent phone users or infrequent users? 1. Use the Math Formula node to calculate the total number of minutes Recommended settings: use the following expression in the Math Formula node and append a new column with the column name Mins Total $Day Mins$+$Eve Mins$+$Night Mins$+$Intl Mins$ 2. Use the Auto-Binner node to create 10 Bins Recommended settings: Include only the column “Min Total”, set the Number of bins to 10, and select Midpoints for the Bin Naming option 3. Use the Pivoting node to find out how many customers in a bin churned. Recommended settings: - Groups: Include Min Total [Binned] - Pivots: Include Churn - Manuel Aggregation: Any Column with aggregation method count 4. Plot your results in a percentage area chart using the Stacked Area Chart node Recommended settings: - Column for x-axis: Mins Total [Binned] - Include all columns - Select Percentage-Area-Chart in the second tab (General Plot Options) Dal grafico risultante emerge che i clienti con basso e medio utilizzo tendono a rimanere, mentre all’ aumentare dell’utilizzo cresce significativamente la percentuale di churn. DDO Laboratory - Churn Prediction H ow to train a basic machine learning model for a churn prediction task, using a Decision Tree algorithm. Pre-Processing I dataset vengono integrati tramite il nodo Joiner utilizzando come chiavi comuni AreaCode e Phone. Successivamente, le variabili numeriche Churn e AreaCode vengono convertite in stringhe ed alla tabella risultante viene poi applicata una colorazione (rosso/verde) in base ai valori della variabile Churn, per facilitarne la lettura. Infine, per una migliore organizzazione del workflow, il tutto viene racchiuso all’interno di un metanodo. Model Training and Evaluation Tramite apposito nodo divido il dataset in una parte di training (80%) e una di test (20%), mantenendo la proporzione tra clienti che fanno churn e quelli che non lo fanno. Utilizzando il training set ho "allenato" il decision tree per prevedere i churn, successivamente ho applicato tale modello ai dati di test. Infine ho valutato le prestazioni utilizzando l’accuracy e la ROC curve per avere una visione più completa della qualità del modello. Valutazione Finale Per valutare il modello ho utilizzato sia lo Scorer che la ROC Curve. Dallo Scorer risulta un’accuracy del 92%, quindi il modello riesce a classificare correttamente la maggior parte dei clienti. Per avere una valutazione più completa viene considerata anche la ROC Curve la quale indica indica che il modello è abbastanza efficace nel distinguere tra clienti che abbandonano e clienti che restano. In generale, il modello mostra buone prestazioni, anche se non è perfetto e potrebbe essere ulteriormente migliorato. CallsData.xls ContractData.csv Split data (train/test) Metanode Pre-Processing Train Model Make predictions Evaluate accuracy Roc curve creation Compute total minutes Create usage bins Roc curve visualization and evaluation Count churn per bin Plot churn distribution Excel Reader CSV Reader Partitioning Pre-Processing Decision Tree Learner Decision Tree Predictor Scorer ROC Curve Math Formula Auto-Binner Image to Report (BIRT) Pivot Stacked Area Chart (JavaScript)

Nodes

Extensions

Links