Adding attribute queries is crucial to building a successful model - this is your way to enrich the model with relevant data that it can use to base its predictions upon.
A good model includes multiple attributes, so feel free to add as many as you think are relevant to your predicted question.
In this article, we will walk through the steps required to add an attribute to our model successfully.
How to add an attribute query
To add data attributes, start by navigating to the "Queries" section and clicking on "Add attribute query."
How to configure our new attribute
Let's explore each table and option to understand how we can set up our attributes most effectively.
As you fill out the fields, Pecan will generate SQL code on the right, displaying it in read-only mode.
After clicking "Save query," you will have the option to edit and modify the code if needed.
Query name
Provide a brief and descriptive title for your attribute.
This title will be displayed alongside all the other attributes on the side menu in the Editor. We recommend using a simple and clear name that you can easily recognize in the future.
You can always rename the query after saving it.
Attribute table
Select the table from which you want to generate a query.
If a table is missing, ensure that you have imported all the relevant data to Pecan. To learn more about how to connect your data, click here.
Attribute columns
Select all the columns that you want Pecan to use in your model.
Join Column
Select the column by which the Entity Table and Attribute Table will be joined.
Typically, the selected column serves as a user identification or some form of unique identifier that can be used to "merge" data with the Entity table.
If this attribute contains only one record per entity, you can proceed to click "Save query" and refer to the "Saving and Validating Our Attribute" section below.
However, if the attribute contains multiple records per entity (like a transactional table), refer to the section titled "Multiple Rows Per Entity" below for guidance on handling such cases.
Multiple rows per entity
Multiple rows per entity
When we have multiple records per entity - for example, when the same user performed more than one action on different dates - we will toggle this option on.
Enabling this option will present us with two additional fields to fill in before we can save the query.
Let's go over these fields.
Date column
Select the date column that will be used to join the Attribute and Entity tables.
This will provide a time-based reference to support multiple Attribute rows per entity so that Pecan will be able to understand the order of events and the entity’s journey.
Historical period
Here, we need to specify the number of days before each marker date from which we want to collect historical data.
Note:
This is a view-only mode, and after clicking "Save query," you will be able to modify the time format. You have the flexibility to use various units of time, such as MONTH, YEAR, HOUR, MINUTE, SECOND, etc., instead of "DAY" to define intervals in different units. For instance, using "INTERVAL 1 MONTH" would represent a one-month time interval.
Saving and validating our attribute
After clicking "Save query", your new attribute will appear on the left side under the Entity and Target query sections.
If you wish to rename, duplicate or remove the attribute, hover over it and click the three dots on the right.
It's essential to verify that the attribute we added is valid and provides the expected results.
Click "Validate" to ensure the attribute is set up correctly, and click "Run" to preview the attribute results under the "Results Preview" tab.
To validate more than one attribute at once, click "Validate all".
Ensure that all attributes have been successfully validated before proceeding to train your model:
Now that we have covered how to add an attribute, handle multiple records per entity, and validate them before training our model, feel free to perform these actions on your end as much as needed.
Don't hesitate to experiment and explore the options thoroughly to achieve the desired results.
Happy modeling!