Alteryx Designer Desktop Discussions

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

Permutations and Combinations

mw42
5 - Atom

Hi all - Super new here - but tried a bunch of googling around permutations, cluster and combinations, and I'm not sure I'm using the correct vocabulary, so I apologize in advance.

 

Here's my sample:

 

A, B, E, F

A, B, G, R

A, R, G, E, B, G, L

A, B, R

A, B

A, Q, B, L, R, Z

 

I want to find what all the combinations (or is it permutations?) of a set of codes is, so that ultimately, If I find something that matches in every time I see it, I can do something else.  In the above example, I've got A and B happening every time I see code A, or 100%.  I'm not ready to discard the stuff that doesn't match 100% of the time, but it's nice to see them in case I ever want to say, "I see the combination of A, B and R happening 75% of the time"

 

I have to do this for every code, so while the sample I gave above was for A, I'd want to see this for B, C, etc.  I'm totally fine if I come up with a code G that never matches.  I just need to know all this.

 

Any help is greatly appreciated.


Thank you.

 

Mike

 

6 REPLIES 6
mceleavey
17 - Castor
17 - Castor

Hi @mw42 ,

 

I think what you're looking for is Apriori modelling. This is available in MB tools available in the Predictive Grouping section.

Apriori modelling essentially creates the associations between elements and combinations of elements, treating the elements as sub-sets.

 

Sorry I can't be more helpful here, but it's a big area and I suggest having a look at the MB Rules, Principal Components and MB Affinity tools.

 

M.



Bulien

damc
11 - Bolide

Hello @mw42 

 

As mentioned by @mceleavey , I believe the MB tools may be really useful to conduct your analysis.

 

For instance, considering your sample set I´ve configured the MB Rules tool to calculate the hyperedgesets using a support of 0.2. In other words, it returns all the combinations of codes that happen at least 20% of the time. Then you can inspect the generated sets.

 

Here´s the output format:

 

output.JPG

Hope it helps.

 

Regards

mw42
5 - Atom

Oh my gosh this is so helpful.  I'm literally one step away at this point.

 

So if my sample was for this:

 

A, B, E, F

A, B, G, R

A, R, G, E, B, G, L

A, B, R

A, B

A, Q, B, L, R, Z

 

What if my sample was actually

 

A, B, E, F

A, B, G, R

A, R, G, E, B, G, L

A, B, R

A, B

A, Q, B, L, R, Z

C, X, Y, G

C, B, R L

C, B

D, U, W

D, M, X, G

D, E

D, U, P

 

Noting that it's the combinations with A that I'm interested in.  Then the combinations with C, and also the combinations with D.  This is literally me trying to figure out what happens to patients inside a hospital.  So patients come in for stuff that's similar (they all have A and some other stuff).  But different patients come in for C (and some other stuff), which is totally unrelated to C - let's say A is arm.  and C is leg - trying to show you that the two are different and therefore not related.  So I'd want support for the A group to be calculated.  But i also need support for the C group to be calculated with just the C group.  Make sense?  Do I do this iteratively?  So, do it for A, then do it for B, etc?

 

Thanks!

 

So the support I'm looking for is based on the outer grouping - or to take it one step further - If each of those rows are patients, then you could say, some patients get A, B, E, F, some like patients get A, B, G, R.  There are different patients that get C, X, Y, G which

 

damc
11 - Bolide

Hello @mw42 ,

 

Not sure if I got your question right this time…So, given the list of patients and a given symptom you need to filter all the patients with this symptom, then calculate the combinations considering this subset. Adittionaly, you need to repeat this operation for each other symptom… Did I get it?

 

If so, this is possible using an iterative macro. I´ve attached a package with a macro for this purpose.

 

Hope it helps

 

Regards

 

Note: in case you´re new to iterative macros,  I believe this video will be handy (thanks for the video @carlosteixeira  😉)

https://www.youtube.com/watch?v=0AGpVm9H1I4&feature=emb_logo

 

 

Have you been building macros already and want to take it to the next level? This session will cover more options for making robust macros. Learn how iterative macros allow a macro to run repeatedly until the desired result is achieved. You'll learn how to: Create an iterative macro Navigate the ...
mw42
5 - Atom

My brain will not wrap itself around iterative macros (for that matter, batch macros) and how to incorporate sql.

 

mw42_0-1602963384103.png

So this workflow i think should be iterative.  I'm simply creating some concatenated strings to throw through the market basket.  I just need to do it one section of data at a time.  The above example throws everything through at once, which doesn't give me the answer I need.

 

The problem is, my input file contains all the records I want to process.  But, I want to process them through the market basket in groups, or using the data - one "code" at a time, and I want my output to be unioned for each code.

 

Hope that better explains this.

 

 

cgoodman3
14 - Magnetar
14 - Magnetar

It sounds like you might need a batch macro instead of an iterative one.

 

For example, if you want to do it for all the combinations that start with A and then C then a batch macro is the way to go.

 

If you put a filter tool at the start and put a condition that is Left([String],1) = "A" then connect a control parameter to the filter with an action tool set to replace the A, with the input of the combination of letters (e.g. next batch would be "C"). Then after this do you market basket analysis.

 

 

 

 

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
Labels