Example gallery/Why do customers purchase?
Example level
Medium
Endpoints
Dataset

Why do customers purchase?

To understand the example better, please read what data the Generated Ecommerce dataset contains

The dataset contains products, impressions (analytics data), and users. Let's investigate what features of products or users correlate with users puchasing products. This is quite easy task because the schema has appropriate links between tables.

The best way to investigate correlations like this is using Relate query.

What features of products correlate with purchase?

This can be done with the query below. You can copy-paste the command to your terminal and test it out!

curl -X POST \
  https://aito-generated-ecom.api.aito.ai/api/v1/_relate \
  -H 'content-type: application/json' \
  -H 'x-api-key: iIZThrosrFaIV1wYCBYRM1rtluY9ZIIY19P6VOTP' \
  -d '
  {
    "from": "impressions",
    "where": {
      "purchase": true
    },
    "relate": "product",
    "orderBy": "info.miTrue"
  }'

Response should look like:

{
  "offset" : 0,
  "total" : 127,
  "hits" : [ {
    "related" : "product.description: ",
    "lift" : 1.875672152851555,
    "condition" : "purchase:true",
    "fs" : {
      "f" : 2084,
      "fOnCondition" : 1186,
      "fOnNotCondition" : 898,
      "fCondition" : 26611,
      "n" : 87778
    },
    "ps" : {
      "p" : 0.023741191542332583,
      "pOnCondition" : 0.04453069185146809,
      "pOnNotCondition" : 0.014697363875302103,
      "pCondition" : 0.3031625316805918
    },
    "info" : {
      "h" : 0.16195994145068188,
      "mi" : 0.010736224763802007,
      "miTrue" : 0.040407491890540444,
      "miFalse" : -0.029671267126738437
    },
    "relation" : {
      "n" : 87778,
      "varFs" : [ 26611, 2084 ],
      "stateFs" : [ 60269, 25425, 898, 1186 ],
      "mi" : 0.005303233615439051
    }
  }, {
    "related" : "product.brand:Nike",
    "lift" : 1.4192799972855341,
    "condition" : "purchase:true",
    "fs" : {
      "f" : 1527,
      "fOnCondition" : 658,
      "fOnNotCondition" : 869,
      "fCondition" : 26611,
      "n" : 87778
    },
    "ps" : {
      "p" : 0.017395805796535043,
      "pOnCondition" : 0.024689519203685936,
      "pOnNotCondition" : 0.014223143638818556,
      "pCondition" : 0.30316254633415574

  ...

The response contains a lot of statistical properties for different analysis, but the commonly important ones are:

  • "related" : "product.brand:Nike" the correlating feature.
  • "lift" : 1.4192799972855341 Nike brand sells 1.42x more likely compared to the average (base probability).
  • info.miTrue the mutual information factor, which indicates how strong the correlation is.

From the response, we can notice that empty description correlates highly with purchase. This is a bit unfortunate insight because it means the data quality is lacking. The second most correlating factor seems to be when product.brand is "Nike". While you could pick this up from your sales metricts, the power of Aito is that you can feed any data to it and it'll find what statistically correlates – even the nontrivial correlations you might not think of.

What features of users correlate with purchase?

The query is exactly same as before, but we just change what link Aito should follow. In this case we want to look into user field in impressions, which links users table.

curl -X POST \
  https://aito-generated-ecom.api.aito.ai/api/v1/_relate \
  -H 'content-type: application/json' \
  -H 'x-api-key: iIZThrosrFaIV1wYCBYRM1rtluY9ZIIY19P6VOTP' \
  -d '
  {
    "from": "impressions",
    "where": {
      "purchase": true
    },
    "relate": "user",
    "orderBy": "info.miTrue"
  }'

You can try the query yourself but the results were not that useful as they tell which individual users are most likely to purchase. Because we're dealing with fake data, the patterns are not very interesting (as we know them already).

Relate offers great possibilities to explore and understand your data. Check out our API docs for a few other examples.

Visit us

Annankatu 34 B

00100 Helsinki

Finland

See map

26 Underwood Street

N1 7JQ

London, UK

See map

Contact info

We'd love to hear from you.

hello@aito.ai

Follow us