Alteryx Designer Desktop Discussions

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

Calculate score using R code

wmacooper4
7 - Meteor

This is my issue.  My databases are getting larger, and it bogs down our model runs on SPSS.

What we're looking to do is to do as much as we can using R.  I would use Alteryx to come up with the validation sample and data to input into my model.

 

When I run logistic regression, I have the code to do stepwise to reduce the number of predictor variables, and then the code to run logistic with binary target variable.  Now, when it comes to the Score tool, is there a way to see the actual code that calculates the score_y & score_n?

 

If what I propose is not possible, can I copy and paste the logistic output from R into an Alteryx tool and then connect that to the Score tool on my module to calculate score?

 

Thanks in advance.

10 REPLIES 10
NeilR
Alteryx Alumni (Retired)

It sounds like you are training your model outside of Alteryx in R, and then wanting to score new data in Alteryx using the model you created in R. Is this correct?

wmacooper4
7 - Meteor

Sorry for the delay.  I was expecting an email alerting me that someone had responded.  

That is correct, I am typing the code for logistic regression in R.

Then, score it in Alteryx using the output from R

NeilR
Alteryx Alumni (Retired)

Then I would suggest using the R tool to run your scoring in Alteryx. Within this tool you can run arbitrary R code, so you'd need to read in your model object and then score the data coming into the R tool, and output the scored results. You can open the Alteryx Score tool by right-clicking on it and selecting "Open Macro" to see how Alteryx does it. See here.

wmacooper4
7 - Meteor

The only part I don't understand is what file extension should I have for the output that is produced by R.

Or do I need to copy and paste it onto something?  If so, what is that extension.

I was trying to use the Text Input tool.  I selected File Input and clicked Configure.  I'm stuck as to what file extension it should be.

 

Thanks.

NeilR
Alteryx Alumni (Retired)

I think you want to save the model to a RData file. There are examples at the bottom of this page...

https://stat.ethz.ch/R-manual/R-devel/library/base/html/save.html

 

wmacooper4
7 - Meteor

Thanks.  I'll have to look at it at home because this site won't get past my employer's firewall.

wmacooper4
7 - Meteor

I attached a screenshot of my module.  How do I input the Rdata file that I created?

 

NeilR
Alteryx Alumni (Retired)

I'd do it in the code in the R tool. So the inverse of what you did to save the model (try load). This is more of an R issue at this point than an Alteryx one.

wmacooper4
7 - Meteor

Thanks fr trying.  I guess I really can't do what I envisioned.

Labels