0

I am working on churn prediction model in tableau. I have written script as given below but getting error as "Error in eval(family$initialize) : y values must be 0 <= y <= 1". Grateful if anybody could help

STR(SCRIPT_REAL('
    data_churn<-data.frame(Churn <- .arg1, Account_Length <- .arg2, VMail_Message <- .arg3, Day_Mins <- .arg4, Eve_Mins <- .arg5,
    Night_Mins <- .arg6, Intl_Mins <- .arg7, CustServ_Calls <- .arg8, Int_l_Plan <- .arg9, VMail_Plan <- .arg10, Day_Calls <- .arg11,
    Day_Charge <- .arg12, Eve_Calls <- .arg13, Eve_Charge <- .arg14, Night_Calls <- .arg15, Night_Charge <- .arg16,
    Intl_Calls <- .arg17, Intl_Charge <- .arg18);

    fit_data <- glm(Churn~., data=data_churn, family= binomial(link = "logit"));

    new_data < - data.frame(Account_Length <- .arg19, VMail_Message <- .arg20, Day_Mins <- .arg21, Eve_Mins <- .arg22,
    Night_Mins <- .arg23, Intl_Mins <- .arg24, CustServ_Calls <- .arg25, Int_l_Plan <- .arg26, VMail_Plan <- .arg27, Day_Calls <- .arg28,
    Day_Charge <- .arg29, Eve_Calls <- .arg30, Eve_Charge <- .arg31, Night_Calls <- .arg32, Night_Charge <- .arg33,
    Intl_Calls <- .arg34, Intl_Charge <- .arg35);
library(rpart)
    pred_val<- predict(fit_data)
    pred_val<-ifelse((pred_val)>.5,1,0)
    pred_val',
sum([Churn]), sum([Account Length]), sum([VMail Message]), sum([Day Mins]), sum([Eve Mins]), sum([Night Mins]), 
sum([Intl Mins]), sum([CustServ Calls]), sum([Int'l Plan]),sum([VMail Plan]), sum([Day Calls]),
sum([Day Charge]), sum([Eve Calls]), sum([Eve Charge]), sum([Night Calls]), sum([Night Charge]),
sum([Intl Calls]), sum([Intl Charge])))
smci
  • 32,567
  • 20
  • 113
  • 146
  • The error has nothing to do with Tableau and everything to do with glm. If you had included the full error message with its stack trace and line number, you'd see that. It's irrelevant which IDE you're running under: Tableau, RStudio, Jupyter, Eclipse... – smci May 01 '18 at 01:05

1 Answers1

1

Sounds like Error in eval(family$initialize) : y values must be 0 <= y <= 1

i.e your churn variable isn't a 0 and 1, or factors.

khhc
  • 93
  • 2
  • 11