In week nine, we had our third client project. The client was Data School itself and we had to help coaches to manage DS applicants throughout the stages of the application process. Out of several stages of the application process, I was assigned the analysis of the gender distribution in different cohorts and also analyzing the channel through which they heard about the Data school program.

As they had not been asked about their gender in the application form, I tried to build a batch macro to determine the gender of applicants by their first name with high probability. The technique that I want to share in this blog. I used gender APIs from this website.  https://genderize.io/ which has a large database of female and male names around the world.

So let’s start to build a batch macro step by step, But before that, let’s see

What is a batch Macro?           

Batch Macro is a special kind of macro typically needed to process a group of records based on a control parameter. A Batch macro runs multiple times in a workflow and creates an output after each run. Batch macros are configured with an Interface tool known as a Control Parameter.

Here is the Control Parameter tool icon :

Building a Batch Macro:

Text Input Tool

Open a new workflow and drag the “Text Input” tool then manually enter the first name as a column name and enter any first name you like.

2-Formula Tool

Drag Formula tool into workflow and add a new column and name it “URL” then add the following API address as depicted in this  picture:

API Address: https://api.genderize.io?name=peter

3-Download tool

Drag the “Download” tool into the workflow and configure it as illustrated below (Do not forget to choose “URL” from the drop-down list for the URL field.)

4-Jason Parse

Drag the “Jason Parse” tool to the workflow exactly after the “Download” tool and configure it like below. Remember to choose” download data” on “Jason filed “ on the configuration part.

And on result window, you will see this,

to transfer the “Jason_Name” column to rows, we have to use the “Cross Tab” tool and configure it like this:

 

And there you go: Here is our initial workflow:

And result window will be like this:

Now we need to change this workflow to a batch macro. To do that, we have to add the “Controller Parameter” tool and connect it to the text input tool. After connecting this tool,” Action Tool” will be added automatically to your workflow.

Remember to choose a label for your controller parameter tool, something like “Enter the First Name”.

And then choose the “Update Cell(Default) ” for the Action type on the “Action” tool.

Finally, convert the “Browser” tool to a Macro output by right-clicking on the ‘Browser” tool.

And our final workflow will be like this:

 

 

 

 

A quick Tip:

To Customize Your Alteryx Macro icon, you need to go to view> interface Designer.  Then click on the properties icon on the bottom-left. You can customize the macro icon  by clicking on either standard icon (and choosing from the drop down list on the right) or by choosing custom icon to choose your own icon.

 

After selecting your icon, you have to save your current workflow and open a new workflow.

 

New Workflow:

Add your first name list as an input tool, then right-click on the workflow, choose insert >macro> choose your macro!

Then add the browser tool,  click the “Run” button!

so the workflow would be like this:

And finally the Result window:

 

In the Result window, you are able to see columns of the First name, Gender, and probability of accuracy in determining the gender. Do not worry, this API works with around 90% accuracy.

Final note:

This API has a Rate limitation! If you need to predict more than 1000 names/day, you must obtain an API key from the website and purchase it as a service from this website.

Hope this blog helps you to build your own batch macros!!

 

 

Azin Fakour
Author: Azin Fakour