-1
$\begingroup$

I am completely new to data science and this is a homework assignment so apologies beforehand. I have some raw data on restaurants that contain their categories (e.g. "Pizza", "Italian") and their coordinates. I'm to cluster them based on their coordinates for closeness and their categories for similarity using K-means. So far I've decided to vectorize the data from dictionary format into a NumPy/SciPy representation used by scikit-learn estimators. Something of this format:

['category=Pizza', 'category=Bars', 'cateogry=Italian', 'latitude', 'longitude']

However I'm having trouble scaling the vectors, since spatial coordinates and restaurant categories have different units of scale and there may be 20 different categories for a restaurant and only two features for latitude and longitude. I've attempted to use the skilearn preprocessing library but it is not providing meaningful clusters.

Any help is greatly appreciated.

$\endgroup$
  • $\begingroup$ Are you being asked to use both the categories and the coordinates in the same clustering procedure, or as separate exercises? If they're separate exercises, your different data types are immaterial. $\endgroup$ – R Hill Oct 12 '16 at 21:02
  • $\begingroup$ They are being used in the same clustering procedure. $\endgroup$ – user3538161 Oct 12 '16 at 21:12
  • $\begingroup$ I would ask the person setting the assignment for clarification on that point, as this sounds like a very strange thing to do with k-means. $\endgroup$ – R Hill Oct 12 '16 at 21:22
  • $\begingroup$ Extensions to k-means can be used for both categorical and numerical data. $\endgroup$ – SmallChess Oct 12 '16 at 22:15
  • $\begingroup$ It seems unlikely that someone completely new to data science would be being asked to apply those extensions as a homework assignment. $\endgroup$ – R Hill Oct 13 '16 at 9:57
0
$\begingroup$

k-means - as the name means suggeyts - needs to be able to compile meaningful centers using the mean. Now this only works for continuous numerical variables. The mean minimizes squared deviations, but not geographics distance. So in short:

Do not use k-means on latitude,longitude,category data!

The results will be nonsense. Earth is a sphere (not a plane), and 1 degree north is not 1 degree east, and not 1 pizza or 1 "chinese food". Do not do this.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.