Alteryx Designer Desktop Discussions

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

model parameters using sum square difference minimization

Josh_Metro
メテオール

I'm new to Alteryx, and I'm trying to replicate something that takes me only a few seconds to do in Excel. 

 

I'm try to fit a dataset to a model. In Excel, I do it this way.

 

This is the model (coefficients in bold): C = (Co-D) * e^(-k*t)

 

I set the starting values from the parameters

D1
k1

 

These are are my observations and my calculated C.

 

CotC - observedC -calculated
031.52
0.531.251.213
231.160.271
530.790.013
1030.459E-05
3030.022E-13
6030.062E-26

 

I then calculate the sum square difference between the observed and calculated C values using the SUMXMY2 formula in Excel

 

SSD
1.85167928

 

Then I use the Solver to minimize the SSD by changing D and k. That literally takes seconds to do, and I get the best fit parameters for my dataset. How can this be done in Alteryx. I uploaded an example.

10件の返信10
Qiu
20 - Arcturus
20 - Arcturus

@Josh_Metro 
The difficult part is the GRG Non-linear solver. 😁

danilang
19 - Altair
19 - Altair

Hi @Josh_Metro 

 

As @Qiu alluded to, it's easy to do in Excel, because all the complexity is hidden from you by being wrapped up in the  Solver add-in.    

 

The closest tool equivalent in Alteryx is the Optimization tool.  Unfortunately, I don't know enough about the GRG algorithm to be able to say if any of the available Optimizer options will produce the same output that you see in Excel.

 

Dan

 

 

Josh_Metro
メテオール

Thanks, Dan. I played around with the optimization tool, but I couldn't make it do the same thing. It's possible I just don't know how to use it.

danilang
19 - Altair
19 - Altair

@Josh_Metro 

 

There's a very thorough example here

 

Dan  

Josh_Metro
メテオール

Thanks, again, Dan. I did read that previously, but I couldn't figure out how to apply it to my use case.

Qiu
20 - Arcturus
20 - Arcturus

@Josh_Metro 

Agree with @danilang , we have to choose a mathmatical model first, then apply it to Alteryx.

It may not be difficult but just time-consuming.

What is the major challenge stopping you from just using Excel?

Or do you accept to call the Excel VBA and Altery will just to call the VBA if your calculation of sum square difference minimization is part of big workflow?

Josh_Metro
メテオール

Hi Qui - the reason I was hoping to migrate the workflow to Alteryx is because I want to be able to apply this model to live dataset in Pi Asset Framework. I would schedule to workflow to run at a frequent interval, pull the parameters, and use them in a predictive model to inform operations of a wastewater plant. We are currently using Alteryx to read and write to our Pi database to perform calculations on live data that are too cumbersome to be done inside Pi AF. Working with my internal team, we were able to write a custom R script to do it (using the nlsLM function), but I was hoping for a more transparent solution. 

Josh_Metro
メテオール

Just wanted to close the loop on this case. I ended up inserting an R script to achieve this objective.  I would have preferred native tools, but could not figure out how. This is the relevant part:

 

# Define function
f <- function(CT,b,kp,kd) {-log10((1-b)*exp(-kp*CT)+b*exp(-kd*CT))}
# Fit nonlinear model
fm <- nlsLM(Ratio ~ f(CT,b,kp,kd), data=data, start=c(b=0.9,kp=0.005,kd=0.05))
print(fm)

rajdaiya
メテオロイド

Hi @Josh_Metro :

 

I am looking for a solution for EXACTLY the same problem. Would you be able to share your workaround alteryx workflow solution (including where u placed the R script) with me? Would really appreciate any help I can get on this

ラベル