Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Error: Model Comparison: Tool #3: Error in names(scores) <- paste(score.field, "_", y.leve

AngelaLilan
7 - Meteor

Hi, I am Angela. I have been working on developing a logistic regression model and using the model comparison tool to compare models. I have been troubled by errors in the model comparison tool. I have tried to change the variables and punctuations but it doesn't help to solve the errors.

The error: Model Comparison: Tool #3: Error in names(scores) <- paste(score.field, "_", y.levels, sep = "") :

Any help would be appreciated!

Please find attached the workflow and input file. Thanks.

32 REPLIES 32
CristonS
Alteryx Alumni (Retired)

hi @AngelaLilan you forgot to include your input file, which the Community will need to help troubleshoot. The easiest way is to package your workflow as a yxzp (Options> Export workflow). Thanks!

AngelaLilan
7 - Meteor

Sorry that I forgot to include the input file. 

 

I really appreciate any help as I am clueless now. Millions of Thanks!

apathetichell
18 - Pollux

Hi,

 

Your workflow doesn't seem to be generating model crushing errors on my system - but for model compare you need to join the models in the same workflow to feed into the model comparison tool. I used a union tool and ran it as below:

2021-06-07 (4).png

 Is this what you re trying to do?

apathetichell
18 - Pollux

Also AFAIK the Create Samples tool in Alteryx is perplexingly not-field specific - ie it doesn't split the  dependent variable at the same rate- so you have slightly over 50% in your train set and slightly below 50% in your test set. I use R directly to make samples since it's relatively straight forward.

AngelaLilan
7 - Meteor

Hi, thank you for your help. 

 

But after adding the 'union' tool, both of the 'model comparison' and 'score' are still having the same errors. 

I have tried to change the predictor variables but it does not help. 

Also, if I would like to change the target variable from 'responded to email campaign' to downloaded discount voucher for purchase', there will be the same errors for 'stepwise' and 'score'.

Could you help me to check again? 

 

Furthermore, may I ask how can I use R directly to make samples? 

 

Sorry as I am new to Alteryx, the questions may sound silly. 


Thanks.

apathetichell
18 - Pollux

Yeah I got your workflow to run perfectly with the original variable but changing the target variable isn't working for me. I'll come back to it later today and see if I can get it to work. I've seen scenarios where you need to change the tools out to get them to work... for sample split with continuity for the dependent variable you can just this in an an R tool:

 

change "DependentVariable" to whatever column you are using. This assumes that you are feeding in data with static "setseed" information and "sampleratio" information (on my system this is in a not ready for primetime macro which adds/adjust these) so just hardcode them if you don't have as variables. As you can see r tool out 1 will be your train/evaluation data and r tool out 2 will be your test/evaluation data.

 

library(caTools)

data<-read.Alteryx("#1", mode="data.frame")
set.seed(data$setseed[1])

data$sampleratio[1]

spl=sample.split(data$DepedentVariable,SplitRatio=data$sampleratio[1])
data_train <-subset(data,spl==TRUE)
data_test <-subset(data,spl==FALSE)

data_train = subset(data_tran, select = -c(setseed,sampleratio) )
data_test = subset(data_test, select = -c(setseed,sampleratio) )


write.Alteryx(data_train,1)
write.Alteryx(data_test,2)

AngelaLilan
7 - Meteor

Thank you. 

 

I have tried to add an R tool but I guess something is missing so that the data is not run successfully. I have tried to add the below code as yours in R tool but is it that I just copy and paste? Or I have to change something? 

 

library(caTools)

data<-read.Alteryx("#1", mode="data.frame")
set.seed(data$setseed[1])

data$sampleratio[1]

spl=sample.split(data$DepedentVariable,SplitRatio=data$sampleratio[1])
data_train <-subset(data,spl==TRUE)
data_test <-subset(data,spl==FALSE)

data_train = subset(data_tran, select = -c(setseed,sampleratio) )
data_test = subset(data_test, select = -c(setseed,sampleratio) )


write.Alteryx(data_train,1)
write.Alteryx(data_test,2)

 

Thanks.

 

apathetichell
18 - Pollux

sorry let me clean it up:

 

library(caTools)

data<-read.Alteryx("#1", mode="data.frame")
set.seed(YOUR SET SEED HERE)

 

spl=sample.split(data$(NAME OF YOUR DEPENDENT VARIABLE HERE), SplitRatio=(SAMPLE SPLIT RATIO HERE)
data_train <-subset(data,spl==TRUE)
data_test <-subset(data,spl==FALSE)


write.Alteryx(data_train,1)
write.Alteryx(data_test,2)

 

Try that. I'm carrying over values in columns  in a set format which obviously your data won't have.

AngelaLilan
7 - Meteor

I received the following error after filling it up:

Error: R (20): Error: unexpected '(' in "spl=sample.split(data$("

 

library(caTools)
data<-read.Alteryx("#1", mode="data.frame")
set.seed(12)

spl=sample.split(data$("Responded to Email Campaign(Missing)"), SplitRatio=(0.7)
data_train <-subset(data,spl==TRUE)
data_test <-subset(data,spl==FALSE)

write.Alteryx(data_train,1)
write.Alteryx(data_test,2)

 

Has anything gone wrong? Thanks.

Labels