Answers.Body: <p>The average transaction is a central measure, while the minimum and maximum transactions together give an idea of dispersion. However, these can be very sensitive to individual purchases that might not be representative of the personal behaviour of a customer.</p>
  <p>For instance, the year a consumer changes their fridge or washing machine an outlier purchase happens. You may want to filter that out of your analysis -or not!</p>
  <p>Robust alternatives to explore include the <a href="https://en.wikipedia.org/wiki/Median" rel="nofollow noreferrer">median</a> for location and the <a href="https://en.wikipedia.org/wiki/Interquartile_range" rel="nofollow noreferrer">interquartile range</a> for spread.</p>
  <p>A <strong>log transformation</strong> of the transaction_ammount may be useful as well. This would transform your arithmetic mean into a geometric mean, thus reducing the impact of large purchases.</p>
  <p>The table does not display a date column. That can also help modeling. You may have customers buying small quantities on random days and weekend customers going to your stores mainly on Saturday, or even once a month.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-24T05:33:35.857Z
Answers.LastActivityDate: 2022-08-24T05:55:45.260Z
Answers.LastEditDate: 2022-08-24T05:55:45.260Z
Answers.UserDisplayName: Jaume Oliver Lafont
Body: <p>I have a data set with transactions details from different business (roughly 1 thousand business entities). Each row is a transaction. The structure of the dataset is as follows:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>client_id</th>
  <th>Sex</th>
  <th>Age</th>
  <th>transaction_ammount</th>
  <th>business_entity</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>123</td>
  <td>M</td>
  <td>88</td>
  <td>4829</td>
  <td>storeA</td>
  </tr>
  <tr>
  <td>123</td>
  <td>M</td>
  <td>88</td>
  <td>1049</td>
  <td>storeB</td>
  </tr>
  <tr>
  <td>255</td>
  <td>F</td>
  <td>25</td>
  <td>1122</td>
  <td>storeH</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>My goal is to cluster the clients depending on their consuming habits, age and sex.</p>
  <p>I am having a hard time on deciding on the best features to feed this dataset into a clustering algorithm (probably K-means as a starter).</p>
  <p>Some of the things I am planning to do are:</p>
  <ul>
  <li>One hot encoding on: sex</li>
  <li>Make each store be a column and each row value be the amount of transactions a certain user did pay to that store (for example, if user1 made two transactions to storeB, there will be a 2 in the user1 row on the storeB column).</li>
  </ul>
  <p>One of the main things I am struggling with right now is how to sum the transactions' data per user. I would need to run an aggregated operation on them, but don't know which one would be better. Some of the ones I have in my mind:</p>
  <ul>
  <li>Average transaction amount per user</li>
  <li>Min transaction amount per user</li>
  <li>Max transaction amount per user</li>
  <li>The above 3 but for each store per user (which would mean that, if I have 1000 stores, I would have to add 3000 thousand columns). This makes sense since each store have a wide range of product prices and running an operation among all the transactions of a user will be misleading.</li>
  </ul>
  <p>What feature engineering technique would you recommend me? Is there any additional data wrangling I should do?</p>
  
Tags: <datasets><data-preprocessing><clustering><feature-selection><feature-engineering>
Title: Feature Engineering on transactional dataset clustering
UserDisplayName: Juan Ignacio Rojo
ThreadText: # Feature Engineering on transactional dataset clustering
  
  (Asked by: username_0 on 2022-08-23)
  
  I have a data set with transactions details from different business (roughly 1 thousand business entities). Each row is a transaction. The structure of the dataset is as follows:
  
  | client\_id | Sex | Age | transaction\_ammount | business\_entity |
  | --- | --- | --- | --- | --- |
  | 123 | M | 88 | 4829 | storeA |
  | 123 | M | 88 | 1049 | storeB |
  | 255 | F | 25 | 1122 | storeH |
  
  My goal is to cluster the clients depending on their consuming habits, age and sex.
  
  I am having a hard time on deciding on the best features to feed this dataset into a clustering algorithm (probably K-means as a starter).
  
  Some of the things I am planning to do are:
  
  * One hot encoding on: sex
  * Make each store be a column and each row value be the amount of transactions a certain user did pay to that store (for example, if user1 made two transactions to storeB, there will be a 2 in the user1 row on the storeB column).
  
  One of the main things I am struggling with right now is how to sum the transactions' data per user. I would need to run an aggregated operation on them, but don't know which one would be better. Some of the ones I have in my mind:
  
  * Average transaction amount per user
  * Min transaction amount per user
  * Max transaction amount per user
  * The above 3 but for each store per user (which would mean that, if I have 1000 stores, I would have to add 3000 thousand columns). This makes sense since each store have a wide range of product prices and running an operation among all the transactions of a user will be misleading.
  
  What feature engineering technique would you recommend me? Is there any additional data wrangling I should do?
  
  **Tags:** datasets, data-preprocessing, clustering, feature-selection, feature-engineering
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-08-24. Score: 1
  
  The average transaction is a central measure, while the minimum and maximum transactions together give an idea of dispersion. However, these can be very sensitive to individual purchases that might not be representative of the personal behaviour of a customer.
  
  For instance, the year a consumer changes their fridge or washing machine an outlier purchase happens. You may want to filter that out of your analysis -or not!
  
  Robust alternatives to explore include the [median](https://en.wikipedia.org/wiki/Median) for location and the [interquartile range](https://en.wikipedia.org/wiki/Interquartile_range) for spread.
  
  A **log transformation** of the transaction\_ammount may be useful as well. This would transform your arithmetic mean into a geometric mean, thus reducing the impact of large purchases.
  
  The table does not display a date column. That can also help modeling. You may have customers buying small quantities on random days and weekend customers going to your stores mainly on Saturday, or even once a month.
  
  
  ---
  
  