Skip to content
TheChatArchiveThe Chat Archive
o1-mini-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

TELECOM CUSTOMER CHURN PREDICTION 📈 Did you know that attracting a new customer costs…

  1. User

    TELECOM CUSTOMER CHURN PREDICTION 📈 Did you know that attracting a new customer costs five times as much as keeping an existing one?

    linkcode Content Introduction What is Customer Churn? How can customer churn be reducded? Objectives Loading libraries and data Undertanding the data Visualize missing values Data Manipulation Data Visualization Data Preprocessing Standardizing numeric attributes Machine Learning Model Evaluations and Predictions KNN SVC Random Forest Logistic Regression Decision Tree Classifier AdaBoost Classifier Gradient Boosting Classifier Voting Classifier Q- and this my Code here

    import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns

    path="data/raw/data.csv" df=pd.read_csv(path)

    Next

    Dataset Information

    The dataset includes the following key details:

    • Customers who left within the last month:

      • Column: Churn
    • Services that each customer has signed up for:

      • Phone
      • Multiple lines
      • Internet
      • Online security
      • Online backup
      • Device protection
      • Tech support
      • Streaming TV and movies
    • Customer account information:

      • How long they’ve been a customer
      • Contract type
      • Payment method
      • Paperless billing
      • Monthly charges
      • Total charges
    • Demographic information about customers:

      • Gender
      • Age range
      • Whether they have partners
      • Whether they have dependents

    Next

    Df.shape ((7043, 21)

    Next

    df.info()

    <class 'pandas.core.frame.DataFrame'> RangeIndex: 7043 entries, 0 to 7042 Data columns (total 21 columns):

    Column Non-Null Count Dtype


    0 customerID 7043 non-null object 1 gender 7043 non-null object 2 SeniorCitizen 7043 non-null int64
    3 Partner 7043 non-null object 4 Dependents 7043 non-null object 5 tenure 7043 non-null int64
    6 PhoneService 7043 non-null object 7 MultipleLines 7043 non-null object 8 InternetService 7043 non-null object 9 OnlineSecurity 7043 non-null object 10 OnlineBackup 7043 non-null object 11 DeviceProtection 7043 non-null object 12 TechSupport 7043 non-null object 13 StreamingTV 7043 non-null object 14 StreamingMovies 7043 non-null object 15 Contract 7043 non-null object 16 PaperlessBilling 7043 non-null object 17 PaymentMethod 7043 non-null object 18 MonthlyCharges 7043 non-null float64 19 TotalCharges 7043 non-null object 20 Churn 7043 non-null object dtypes: float64(1), int64(2), object(18) memory usage: 1.1+ MB Here’s a table that classifies the features of the DataFrame into numerical and categorical:

    FeatureTypeCategory
    customerIDObjectCategorical
    genderObjectCategorical
    SeniorCitizenInt64Numerical
    PartnerObjectCategorical
    DependentsObjectCategorical
    tenureInt64Numerical
    PhoneServiceObjectCategorical
    MultipleLinesObjectCategorical
    InternetServiceObjectCategorical
    OnlineSecurityObjectCategorical
    OnlineBackupObjectCategorical
    DeviceProtectionObjectCategorical
    TechSupportObjectCategorical
    StreamingTVObjectCategorical
    StreamingMoviesObjectCategorical
    ContractObjectCategorical
    PaperlessBillingObjectCategorical
    PaymentMethodObjectCategorical
    MonthlyChargesFloat64Numerical
    TotalChargesObjectCategorical (should be numerical, but likely has non-numeric values)
    ChurnObjectCategorical

    Notes:

    • Numerical features: These are the ones that contain numeric data types (int64, float64).
    • Categorical features: These are object types that generally represent categories.
    • The TotalCharges column is an object, but it might need conversion to numeric (after cleaning) since it's likely a numeric field stored as a string due to potential non-numeric values. in percentage how % mnay categoricla vs nurmerical here
  2. Assistant

    Certainly! Let's break down the distribution of categorical versus numerical features in your dataset.

    Dataset Overview

    • Total Features (Columns): 21

    Feature Classification

    FeatureTypeCategory
    customerIDObjectCategorical
    genderObjectCategorical
    SeniorCitizenInt64Numerical
    PartnerObjectCategorical
    DependentsObjectCategorical
    tenureInt64Numerical
    PhoneServiceObjectCategorical
    MultipleLinesObjectCategorical
    InternetServiceObjectCategorical
    OnlineSecurityObjectCategorical
    OnlineBackupObjectCategorical
    DeviceProtectionObjectCategorical
    TechSupportObjectCategorical
    StreamingTVObjectCategorical
    StreamingMoviesObjectCategorical
    ContractObjectCategorical
    PaperlessBillingObjectCategorical
    PaymentMethodObjectCategorical
    MonthlyChargesFloat64Numerical
    TotalChargesObjectCategorical (should be Numerical)
    ChurnObjectCategorical

    Percentage Breakdown

    • Numerical Features:

      • SeniorCitizen
      • tenure
      • MonthlyCharges

      Count: 3

    • Categorical Features:

      • customerID, gender, Partner, Dependents, PhoneService, MultipleLines, InternetService, OnlineSecurity, OnlineBackup, DeviceProtection, TechSupport, StreamingTV, StreamingMovies, Contract, PaperlessBilling, PaymentMethod, TotalCharges, Churn

      Count: 18

    Calculations

    • Percentage of Categorical Features:

      [ \left( \frac{18}{21} \right) \times 100 \approx 85.71% ]

    • Percentage of Numerical Features:

      [ \left( \frac{3}{21} \right) \times 100 \approx 14.29% ]

    Summary

    • 85.71% of the features are Categorical.
    • 14.29% of the features are Numerical.

    Recommendation

    • TotalCharges: Although currently classified as Categorical due to its object data type, this feature is inherently numerical. It's advisable to clean and convert this column to a numeric type (e.g., float64) to leverage its quantitative information effectively in your machine learning models.

      # Convert 'TotalCharges' to numeric, coercing errors to NaN
      df['TotalCharges'] = pd.to_numeric(df['TotalCharges'], errors='coerce')
      
      # Handle missing values if any after conversion
      df['TotalCharges'].fillna(df['TotalCharges'].median(), inplace=True)
      

      After conversion, you can reclassify TotalCharges as a Numerical feature, adjusting the percentages accordingly.


    Feel free to ask if you need further assistance with data preprocessing or model building!