<p>Any clustering algorithm should work -- the main issue is the similarity or distance metric that determines how similar (or different) two elements are. This is often something like Euclidean distance, but that won't work well with binary data.</p>
<p>I would suggest using the <a href="https://en.wikipedia.org/wiki/Jaccard_index" rel="nofollow noreferrer">Jaccard Index</a> or <a href="https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient" rel="nofollow noreferrer">Dice Coefficient</a>. These will be suitable for use as a metric when clustering such data.</p>

CC BY-SA 4.0
2022-05-17T05:47:01.247Z
Hey Oliver, thanks a lot! I'll try and experiment with using these distance metrics.
user199590
CC BY-SA 4.0
2022-05-16T08:06:47.407Z
2022-05-16T08:06:47.407Z
Oliver Mason
<p>I have a dataset with a lot of binary categorical features and a single continuous target value. I would like to cluster them, but I am not quite sure what to use.</p>
<p>In the past, I have used DBSCAN for something similar and it worked well, but that dataset also had lots of continuous features.</p>
<p>Do you have any tips and suggestions?</p>
<p>Would you suggest matrix factorization and then cluster?</p>

CC BY-SA 4.0
2022-05-15T15:59:04.240Z
By "binary categorical (one-hot encoded)", do you mean that you have $n$ features, and, for each input, only one of them is $1$ and all the others are $0$?
nbro
CC BY-SA 4.0
2022-05-15T16:02:34.250Z
@nbro thanks for the comment! No, I have n features and any combination of 0, 1s among them is possible.
i.e. if n = 3, I may have, 000 or 010, or 111, etc.
user199590
CC BY-SA 4.0
2022-05-15T16:07:36.710Z
Ok, then I don't think that's called one-hot encoded. 1-hot encoded is what I described, I think.
nbro
CC BY-SA 4.0
2022-05-15T16:08:30.443Z
@nbro ah, apologies, I meant to convey that the individual features can only be either 0 or 1. I'll edit.
user199590
<unsupervised-learning><algorithm-request><clustering>
What clustering algorithms work best for datasets with only binary categorical features?
user199590
# What clustering algorithms work best for datasets with only binary categorical features?

(Asked by: username_0 on 2022-05-15)

I have a dataset with a lot of binary categorical features and a single continuous target value. I would like to cluster them, but I am not quite sure what to use.

In the past, I have used DBSCAN for something similar and it worked well, but that dataset also had lots of continuous features.

Do you have any tips and suggestions?

Would you suggest matrix factorization and then cluster?

**Tags:** unsupervised-learning, algorithm-request, clustering

> **Comments:**
> **username_1**: By "binary categorical (one-hot encoded)", do you mean that you have $n$ features, and, for each input, only one of them is $1$ and all the others are $0$?  
> **username_0**: @username_1 thanks for the comment! No, I have n features and any combination of 0, 1s among them is possible. i.e. if n = 3, I may have, 000 or 010, or 111, etc.  
> **username_1**: Ok, then I don't think that's called one-hot encoded. 1-hot encoded is what I described, I think.  
> **username_0**: @username_1 ah, apologies, I meant to convey that the individual features can only be either 0 or 1. I'll edit.  

---

## 1 answers

### Answer by username_2 on 2022-05-16. Score: 1 | Accepted answer

Any clustering algorithm should work -- the main issue is the similarity or distance metric that determines how similar (or different) two elements are. This is often something like Euclidean distance, but that won't work well with binary data.

I would suggest using the [Jaccard Index](https://en.wikipedia.org/wiki/Jaccard_index) or [Dice Coefficient](https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient). These will be suitable for use as a metric when clustering such data.

> **Comments:**
> **username_0**: Hey Oliver, thanks a lot! I'll try and experiment with using these distance metrics.  

---

