community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
New Data Science Blog

Check out the latest post: All Models Are Wrong

READ MORE
Announcement | We'll be doing maintenance between pm 4- 6pm MT, which may impact your experience. Thanks for your patience as we work on improving the community!

Integrating Keras Neural Network with R or Python

Highlighted
Alteryx Partner

I am currently working on a project that requires heavy duty predictive capabilities and would like to incorporate the Keras Deep Learning library in my Alteryx workflow. My problem requires that I predict a continuous variable so essentially this neural network will be a very robust linear regression. I haven't decided whether I want to use recurrent layers such as the RNN or LSTM keras layers in my network but these are provided with Keras and so they shouldn't affect my inquiry.

 

I am familiar with using Keras in Python and the capabilities for the R version of the library seem to be about the same so I am trying to decide which language I would like to use to implement a keras neural network in Alteryx.

 

My initial thought was to stick with python since I have used it extensively. I can run a python script containing my deep learning code within my Alteryx workflow using the run command tool. In this case, the script will take the write source from the run command, train the model and write output predictions to a file that is read back into Alteryx  through the read results. In this case, all of the machine learning and predictions will be done in Python.

 

When I found out about the R implementation of Keras, it crossed my mind that I may be able to implement everything within Alteryx using the R Tool. However I have no experience using R, and although I am very interested to learn it, since I already know keras with python, I am debating whether it will be worth putting the time and effort to learn a new language to make my neural net purely in Alteryx using R.

 

While doing research I came up with a couple questions that will help me decide whether I want to use R or Python for my keras network.

 

 

First of all, I am curious as to what the format of the 'R Model Object' outputted by the Alteryx Predictive tools are in (linear regression, decision tree, neural network, etc..).

If I were to create my keras model in python, what format would my python script have to return my model in for Alteryx to be able to read it in as an R model object that can then be passed in to the score or cross validation tool?

Similarly, if I were to create my keras model using R in the R tool, what would I need to do to my keras model so Alteryx will read the model as an 'R Model Object' that can be used with the score or cross validation tool?

I also read somewhere that for the R tool, outputs have to be written to Alteryx as 'dataframes' and I would like to know more about this.

 

If anyone has experience integrating a keras deep neural net into an Alteryx workflow I would be grateful for any guidance.

Community Content Engineer
Community Content Engineer

Hi @Pianalyst,

 

I came across this post today, and I know that you may have already worked through this or are no longer working on it, but I wanted to make sure there was a response to some of your questions in case someone has a similar question or you still need help.

 

The R Model Objects generated by the Alteryx Predictive Tools are serialized R models in a Blob format, (i.e., R code objects converted to a format that can be safely passed through the Alteryx Engine). The Score tool and the Cross Validation tool (as well as most predictive tools) are R-based macros, meaning that the core function of these tools comes from a script within an R tool. At this time the Alteryx Predictive tools are all entirely R-based, and they will not work with any models that have been generated in Python.

 

Additionally, the Score tool will only work for certain model types. These types are: glm, svyglm, negbin, randomForest.formula, rpart, gbm, lm, rxLogit, rxGlm, rxLinMod, rxDTree, rxDForest, earth, naiveBayes, svm.formula, nnet.formula, coxph, elnet, glmnet, cv.glmnet, and C5.0. If the model you have built in with R is not one of these types, you will receive an error when attempting to pass your model to the Score tool. To create estimates with your model in Alteryx, you will likely need to create your own Score tool with custom code and an R Tool. The same will be true for the Cross Validation tool, the Model Comparison tool, or any other R tools that come with the Predictive Tools install. 

 

Outputs of the R tool (excluding model object) do need to be in an R data.frame format. This is the expected format for conversion back into the Alteryx data stream. For additional help reading in and writing out of an R tool, please see this Community post: A Cheat Sheet of Functions to Use in the R tool.

 

For this type of project, you can explore the Python SDK, the Python tool, or the R tool. At this point, the R tool is the most established and will have the most documentation and fully fleshed-out features for developing a complex predictive model. All three tools would allow you to download the Keras package in their respective language. For additional assistance integrating your model into Alteryx, I would consider exploring and posting to our Developer's Community, which is more geared for code questions. 

 

If you have had success in this project, please consider posting back how you approached it. I am sure there are many users like you that would be very interested to learn about your process. 

Labels