3 Replies Latest reply on Jan 24, 2017 5:21 PM by Bora Beran

    Error in Churn Prediction Model Using Tableau & R

    Shivi Bhatia

      HI Team,

      I am using R script in Tableau to visualize the churn model.

       

      The script used below is :

      STR(SCRIPT_REAL('

        churn <- .arg1

        month_charges <- .arg2

        total_charges <- .arg3

        avg_tenure <- .arg4

        data_churn <- data.frame(churn, month_charges, total_charges, avg_tenure)

        fit_data <- glm(formula = churn ~ . ,data = data_churn, family = "binomial")

        pred_val <- ifelse(predict(fit_data, newdata = data_churn, type = "response")>.3, 1, 0)

        pred_val

      ',ATTR([Churn_Transformed]),SUM([Monthly Charges]),SUM([Total Charges]), AVG([Tenure])))

       

      However i am getting this error:

      Error in model.matrix.default(mt, mf, contrasts) : variable 1 has no levels. This was working fine however as i have added a few variable i get this error.

       

      Please suggest.