Answers.Body: <p>I would recommend a <a href="https://en.wikipedia.org/wiki/Hierarchical_clustering" rel="nofollow noreferrer">hierarchical cluster algorithm</a>, after normalising your numbers into proportions. Then the clustering should be able to identify similar patterns. Depending at which level you make the cut, you can decide how many clusters you want.</p>
  
  <p>A great resource on this topic is Kaufman, L., &amp; Roussew, P. J. (1990). "Finding Groups in Data - An Introduction to Cluster Analysis". John Wiley &amp; Sons</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-16T13:33:13.567Z
Answers.LastActivityDate: 2019-05-16T13:33:13.567Z
Answers.UserDisplayName: Oliver Mason
Answers.Body: <p>If I understand correctly you want to find companies with similar patterns to yours. </p>
  
  <p>I would start with measuring <code>cosine similarity</code> between your company and others. </p>
  
  <p>It is really easy with Python, for example:</p>
  
  <pre><code>In [21]: from sklearn.metrics.pairwise import cosine_similarity
  
  In [22]: cosine_similarity([[1,4,2,6], [1,9,5,4]])
  Out[22]:
  array([[1.        , 0.84794633],
         [0.84794633, 1.        ]])
  </code></pre>
  
  <p>Note that if size of sale matters to you, this is not the right approach, as cosine similarity is magnitude invariant:</p>
  
  <pre><code>In [23]: from sklearn.metrics.pairwise import cosine_similarity
  
  In [24]: cosine_similarity([[1,4,2,6], [10,90,50,40]])
  Out[24]:
  array([[1.        , 0.84794633],
         [0.84794633, 1.        ]])
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-17T17:20:40.760Z
Answers.LastActivityDate: 2019-09-18T11:35:32.653Z
Answers.LastEditDate: 2019-09-18T11:35:32.653Z
Answers.UserDisplayName: Akavall
Body: <p>I have a dataset as follows</p>
  
  <p><a href="https://i.sstatic.net/pJIKM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pJIKM.png" alt="enter image description here"></a></p>
  
  <p>(and the table extends to include an extra 146 columns for companies 4-149)</p>
  
  <p>Is there an algorithm I could use effectively to find similar patterns in sales from the other companies when compared to my company? </p>
  
  <p>I thought of using k-means clustering, but as I'm dealing with 150 companies here it would likely become a bit of a mess, and I don't think linear regression would work here.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-16T11:41:30.907Z
Comments.Text: Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the [CC BY-SA 3.0 license](https://creativecommons.org/licenses/by-sa/3.0) for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: [How does deleting work](https://meta.stackexchange.com/q/5221/295232)?
Comments.UserDisplayName: Glorfindel
Tags: <machine-learning><unsupervised-learning><linear-regression><pattern-recognition><k-means>
Title: Is there a machine learning algorithm to find similar sales patterns?
UserDisplayName: Anonymous
ThreadText: # Is there a machine learning algorithm to find similar sales patterns?
  
  (Asked by: username_0 on 2019-05-16)
  
  I have a dataset as follows
  
  [![enter image description here](https://i.sstatic.net/pJIKM.png)](https://i.sstatic.net/pJIKM.png)
  
  (and the table extends to include an extra 146 columns for companies 4-149)
  
  Is there an algorithm I could use effectively to find similar patterns in sales from the other companies when compared to my company?
  
  I thought of using k-means clustering, but as I'm dealing with 150 companies here it would likely become a bit of a mess, and I don't think linear regression would work here.
  
  **Tags:** machine-learning, unsupervised-learning, linear-regression, pattern-recognition, k-means
  
  > **Comments:**
  > **username_1**: Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the [CC BY-SA 3.0 license](https://creativecommons.org/licenses/by-sa/3.0) for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: [How does deleting work](https://meta.stackexchange.com/q/5221/295232)?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2019-05-17. Score: 3 | Accepted answer
  
  If I understand correctly you want to find companies with similar patterns to yours.
  
  I would start with measuring `cosine similarity` between your company and others.
  
  It is really easy with Python, for example:
  
  ```
  In [21]: from sklearn.metrics.pairwise import cosine_similarity
  
  In [22]: cosine_similarity([[1,4,2,6], [1,9,5,4]])
  Out[22]:
  array([[1.        , 0.84794633],
         [0.84794633, 1.        ]])
  
  ```
  
  Note that if size of sale matters to you, this is not the right approach, as cosine similarity is magnitude invariant:
  
  ```
  In [23]: from sklearn.metrics.pairwise import cosine_similarity
  
  In [24]: cosine_similarity([[1,4,2,6], [10,90,50,40]])
  Out[24]:
  array([[1.        , 0.84794633],
         [0.84794633, 1.        ]])
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2019-05-16. Score: 2
  
  I would recommend a [hierarchical cluster algorithm](https://en.wikipedia.org/wiki/Hierarchical_clustering), after normalising your numbers into proportions. Then the clustering should be able to identify similar patterns. Depending at which level you make the cut, you can decide how many clusters you want.
  
  A great resource on this topic is Kaufman, L., & Roussew, P. J. (1990). "Finding Groups in Data - An Introduction to Cluster Analysis". John Wiley & Sons
  
  
  ---
  
  