# Tag Info

8

The are some techniques to choose the number of clusters K. The most common ones are The Elbow Method and The Silhouette Method. Elbow Method In this method, you calculate a score function with different values for K. You can use the Hamming distance like you proposed, or other scores, like dispersion. Then, you plot them and where the function creates "...

4

In my opinion there are two ways: Ask a few experts to assess the quality of the clusters based on a sample (after the clustering has been done, much easier than pre-annotating the whole data especially in the case of clustering) If the clustering is done in the perspective of using the result in another task, the performance of this other task will reflect ...

4

They won't necessarily be the same. Consider observations equally distributed over a circle (radius = 1). Depending on the initial centroids, the algorithm will converge on different solutions. For instance, consider the case where two centroids are initially located on each side of one of the circle's diameters. Those can be any pair of points, and the ...

4

You have two options: 1) Let the K-means algorithm run for a large number of iterations (if on sklearn, change the max_iter parameter value for sklearn.cluster.KMeans). It will eventually converge to a good result (but it will take more time) 2) Make and "educated guess" for the initial starting point. One way to do that is to transform your data in a ...

4

You are describing incremental learning, input data is continuously used to extend the existing model's knowledge. There is a Python implementation of incremental DBSCAN. There is no current Python implementation of incremental HDBSCAN.

3

Finally I just implemented solution as I planned and described it in Medium post. This is "K-Means for solid polygons". I made a playground on my github.io. A bit more details of solid clustering approach. K-Means complexity is O(nkdi) or O(nk) per iteration without d, n is the number of d-dimensional vectors (to be clustered) k the number of clusters i ...

3

If you have outliers, the best way is to use a clustering algorithm that can handle them. For example DBSCAN clustering is robust against outliers when you choose minpts large enough. Don't use k-means: the squared error approach is sensitive to outliers. But there are variants such as k-means-- for handling outliers.

3

Always use a supervised algorithm when you have labeled data for your problem. Why would you ignore the labels, your most valuable bit of information? To improve quality, you most likely need to improve your features.

3

Looking at your different steps, the important thing to do is check which step would be affected by outliers. Removing missing values is not affected because this step is not dependent on other data points present (or not) in the dataset. However, normalizing your data is. Indeed, let's say your outliers contain extreme values, this will affect the ...

3

Neither, there is not enough discriminatory information in data (yet) Dont squeeze the data until it tells you the truth. You can change the metric (malahobian distance for example) and the algo but you cant expect it to show miracles. Using elbow method, as you increase the number of clusters it will always become more homogenous. You dont have a "kink" ...

3

A Silhouette score close to 0 says the clustering is not reliable. And the Elbow method is crap. On random data the curve would drop roughly like 1/(k-1); so it's largely undefined wh em they is an elbow and when not. In your case, what troubles me most is that the values appear to stagnate to a cake much larger than zero. Maybe there is an error in your ...

3

K-Medoids It would be possible with an adapted semi-supervised K-Means, also known as K-Medoids. The tricky part with K-Means is that you do not know the centroids. However, you could hot start by assuming that some of your data points are centroids. Then, when figuring the new centroid at each iteration, instead of figuring out the "imaginary" central ...

3

I'd suggest looking at hierarchical clustering: It's simple so you could implement and tune your own version It lets you decide at which level you want to stop grouping elements together, so you could have a maximum distance. Be careful however that this approach can sometimes lead to unexpected/non-intuitive clusters.

3

I would try DBSCAN algorithm first: fairly easy to tune (with, in particular, a notion of distance as you requested), and does not need to know the number of clusters. There are a few other algorithms that can help you decide the number of clusters: Bayesian Gaussian Mixtures (see sklearn implementation) for instance, but it requires a bit more knowledge ...

3

It's a matter of data quality so it depends how the dataset was built: Either these instances are meaningful, i.e. it makes sense that an observation would have zeros for all the features and that it would happen that often. Or these are the result of an error, typically the complete absence of measurement for these observations. Naturally one wants to ...

3

If you expect that all zeros is a result of error in the measuring of the features (i.e. the observations should not be all 0s but they are), then I would say: Keep all the data, but increase k (from k-means) by 1. This extra one will hopefully become the class of all these wrong observations. If you expect that all zeros is correct (i.e. these observations ...

3

There cannot be a unique answer to your question. There is a discrepancy in your question though - I am aware that this is a classification problem on which I am working on. Could you please help me with the right step by step guide that I should follow in order to achieve an efficient clustering at the end? However, I am assuming that you are trying to do ...

2

Independent of the number of features, you will obviously need much more than 3 * 100.000 * 100.000 * 8 bytes of ram (with double precision floats). That is 240.000.000.000 or about 240 GB. Not only is this a lot of RAM to have, but AP will have to do many passes over this RAM, so this will take forever, even after computing the distance matrix. So ...

2

Dont try to visually confirm it. You are plotting your clustering resutls in ONLY two dimensions and you expect that all of the information is in these two dimesnions. That is very unlikely. If you plot 3 dimensions you will see even more seperability and it will make a bit more sense. In any case you need a metric for example Silhouette that tells you how ...

2

First, please note that spectral clustering is very sensitive to the affinity kernel. With the standard RBF kernel, my experience is that spectral clustering often isolates outliers (in the spectral space), leaving clusters with numerous observations which can be separated by great distances. This is a major difference with direct k-means: there is no notion ...

2

You can, as an example, create a binned field for the measure. The value range can be specified in the tooltip. I used a single color based continuous palette since (population) total is a continuous field. [Edited] Based on your comment, I tested with a fixed dimension based binned field for the continuous measure. At least in my example file, the values ...

2

Since they are categorical variables, I would cluster them using the k-medoids clustering method. Before applying this method, one-hot encode all the predictors. See a tutorial here: https://towardsdatascience.com/k-medoids-clustering-on-iris-data-set-1931bf781e05 Sklearn has an implementation: https://scikit-learn-extra.readthedocs.io/en/latest/generated/...

2

Not very familiar with k-medoids, but i guess it's something like k-means, right? If so, the most time-consuming part of the entire model is updating the medoids. We randomly select initial start and update the center of mass to have better cluster results. I suggest you to pickle final_medoids. When you have new data, compute the pca, pass it to kmedoids ...

2

K-means don't modify the underlying structure of your data. K-means will just provide the 'color' part of your graph. To answer the question about why do you get a cuboid, it's because your underlying data are a cuboid. Not necessarily by construction, but that's what happen when you cap your data. As an exemple, look at the following code : X1 = c(rnorm(...

2

Either do unsupervised learning with something like k-means clustering or DBScan where you attempt to segment students into groups and see if you can discern any insights based on the cluster generated or pick a threshold for certain categories, create a class column and label each student, and do a classification model.

2

I think these time complexities are optimistic cases, but apart from that I think the reason is that in hierarchical clustering you consider the distances between many, if not all pairs of data points. The number of pairs scales quadratically with the number of points. For k-means you somewhat cheat your way around considering all pairs by looking at the ...

2

Very interesting question! I try my best: It depends a bit on the number of clusters and number of restaurant but in general I explain a bit. If the number of restaurants and clusters are the same, then, theoretically, your question has just one trivial answer: "each restaurant is a cluster". You even don't need any algorithm. I go a bit deeper on it. ...

2

If your definition of points belonging to a cluster is simply the points closest the cluster centroid, then the boundaries cannot overlap. The point assignments are a Voronoi map like: (Source: https://www.quora.com/What-is-the-difference-between-K-Means-and-Voronoi/answer/Ethan-Brooks-3) The closest centroid, and thus assignment, is unambiguous.

2

Seems to be pretty straight-forward thanks to your "well-behaving" data. Simplest The naive approach is to check histogram! As you see, the OFF state has generally a low magnitude. Knowing that level of magnitude from the labeld data you have above, you can threshold the histogram. Why is it naive? : because you see false positives (see the plot between ...

2

Each of those selected clustering algorithms can be fit using cosine distances in scikit-learn: from sklearn.cluster import DBSCAN, MeanShift, OPTICS from sklearn.metrics.pairwise import cosine_distances # Define clustering algorithms algorithms = [DBSCAN, MeanShift, OPTICS] # Placeholder for results results = dict.fromkeys((a.__name__ for a in algorithms)...

Only top voted, non community-wiki answers of a minimum length are eligible