Free Trial

Alteryx Designer Desktop Discussions

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

How to make confusion Matrix, sklearn style in Alteryx

Hagar-Usama
8 - Asteroid

 

Hi,

 

I have a confusion matrix like this 

 
 

 

confusion_matrix.PNG

 

And I wish to make it like the following image (from w3schools) in Alteryx, is that possible

 

https://www.w3schools.com/python/img_ml_confusion_matrix.png 

 

Thanks!

7 REPLIES 7
OllieClarke
15 - Aurora
15 - Aurora

Hey @Hagar-Usama 

If you reshape your data using a transpose and a formula tool to parse the Result and Type of result:
image.png

 

Then you can take this into the interactive chart tool.

You'll want to use a Heatmap layer with Result as your X, Type of Result as your Y and Value as your Z

 

image.png

Under Layer, you'll want to choose your colourscale, set the Display Range to auto (if you want different ranges per input row, or you can set it to custom to set your own across all input rows) and ensure the colour bar is visible

image.png

Finally under batch, ensure you're batching your charts by the Row to get 2 separate charts with an independent colour scale

image.png

 

I couldn't figure out how to label the squares unfortunately though

 

image.png

 

image.png

 

Hope that helps,

 

Ollie

 

Hagar-Usama
8 - Asteroid

Thanks @OllieClarke, seems perfect to me

 

However, I followed the same steps but got different output. And how I got 'row' column

confusion_matrix_heatmap.PNGconfusion_matrix_heatmap_tools.PNG

OllieClarke
15 - Aurora
15 - Aurora

@Hagar-Usama I added a row because in your input you had 2 rows of data. You can use a recordID tool before the transpose tool, use ReocrdID as a key field, and the other 4 as data fields, thenceforth replace all my references to row with RecordID (or change the name of the column created in the RecordID tool to be row).
Ensure you run the workflow before you input the interactive chart tool

 

Hope that helps,

 

Ollie

caltang
17 - Castor
17 - Castor

Great stuff @OllieClarke ! 

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
Hagar-Usama
8 - Asteroid

@OllieClarke 

 

Great, thank you it works. Can I make value present inside each square?

 

Thanks!

OOIWJ
7 - Meteor

Hi how do you create your confusion matrix in that current form?

Hagar-Usama
8 - Asteroid

Do you mean the table I attached in my post?

Labels
Top Solution Authors