I am currently solving a problem where I have to use Cosine distance as the similarity measure for k-means clustering. However, the standard k-means clustering package (from Sklearn package) uses Euclidean distance as standard, and does not allow you to change this.  Therefore it is my understanding that by normalising my original dataset through the code below. I can then run kmeans package (using Euclidean distance); will it be the same as if I had changed the distance metric to Cosine distance?  from sklearn import preprocessing  # to normalise existing X X_Norm = preprocessing.normalize(X)  km2 = cluster.KMeans(n_clusters=5,init='random').fit(X_Norm)   Please let me know if my mathematical understanding of this is incorrect.
Is there a specific purpose in terms of efficiency or functionality why the k-means algorithm does not use for example cosine (dis)similarity as a distance metric, but can only use the Euclidean norm? In general, will K-means method comply and be correct when other distances than Euclidean are considered or used?  [Addition by @ttnphns. The question is two-fold. "(Non)Euclidean distance" may concern distance between two data points or distance between a data point and a cluster centre. Both ways have been attempted to address in the answers so far.]
How can I add a "C" wire to my thermostat? Some examples include:     We fear the damned.   He honored our fallen.   This is a given.   You are the chosen.   The lost were among us.   They obey the venerated.   My beloved kissed me. (TIL “beloved” is a verb thanks to RegDwight АΑA)   Is there a word to describe the past participle used as a noun? I’m hesitant to refer to it as a gerund, since it doesn’t end in -ing. Another possibility is adjectival noun, if you originally treat the word as a participle (e.g. “the damned man”) that has given up its modified noun.  Also, why does English tend to preface such nouns with the? Is $\sin^2(z) + \cos^2(z)=1$ still true for $z \in \Bbb{C}$? Is $$\sin^2(z) + \cos^2(z)=1$$ still true for all $z \in \Bbb{C}$? I've tried rewriting it using complex definitions of $\sin$ and $\cos$, and I don't see why it wouldn't, but the text I'm reading asks this question as if it shouldn't hold? This was Problem 3 (first day) of the 1990 IMO. A full solution can be found      How many rationals of the form $\large \frac{2^n+1}{n^2},$ $(n \in \mathbb{N} )$ are integers?   The possible values of $n$ that i am able to  find is $n=1$ and $n=3$, so there are two solutions and this seems to be the answer to this problem.  But now we have to prove that no more of such $n$ exists, and thus the proof reduces to: Proving that $n^2$ does not divides $2^n+1$ for any $n \gt 3$.  Does anybody know how to prove this? "Where will you go" vs. "Where you will go" Which sentence is correct between these?      Where will you go?     Where you will go? How do I remove 'Places' entries from the Nautilus sidebar? transforming ordinary generating function into exponential generating function How do I split a string with multiple separators in JavaScript? I'm trying to split on both commas and spaces, but AFAIK JavaScript's split() function only supports one separator. Why enums require an explicit cast to int type? I know that, whenever I want to see how some control sequence, say \mycontrolsequence, is defined, I can use \show\mycontrolsequence  then compile my code and look up the .log file. However, robust commands seem impervious to \show. For instance, if I compile the following code, \documentclass{article}  \newcommand\mycommand{foo} \show\mycommand  \DeclareRobustCommand{\myrobustcommand}{bar} \show\myrobustcommand  \begin{document} hello \end{document}  my log file contains  \mycommand=\long macro: -&gt;foo. l.4 \show\mycommand  \myrobustcommand=macro: -&gt;\protect \myrobustcommand  . l.7 \show\myrobustcommand   Note that, whereas the definition of \mycommand is exposed (foo), nothing transpires of \myrobustcommand's definition. Of course, in practice, I could always identify in which file a given robust command is defined and look up its definition there. However, finding the file in question may not be obvious. Hence my question: Is there an alternative way of peering into the definition of a robust command? How to use "text" as a verb Using SQL Server, how do I split a string so I can access item x?  Take a string "Hello John Smith". How can I split the string by space and access the item at index 1 which should return "John"? From the :   -exec command ;     There are unavoidable security problems     surrounding use of the -exec action; you should use the     -execdir option instead.  -execdir command {} +     Like -exec, but the specified command is run from the     subdirectory containing the matched file, which is not     normally the directory in which you started find.  This a much     more secure method for invoking commands, as it avoids race     conditions during resolution of the paths to the matched     files.    What does this mean? Why are there race conditions with running it from the starting directory? And how are these security risks? Rootspaces are $\mathop{ad}$ nilpotent For $a,b,c&gt;0$, Find $$ \lim_{n \to \infty}\left(\frac{a^{1/n}+b^{1/n}+c^{1/n}}{3}\right)^n$$  how can I find the limit of sequence above?  Provide me a hint or full solution. thanks ^^ Italics/roman in BibTeX I use a BibTeX style which automatically italicises booktitles (using \emph). I have certain entries which contain italicised words in the title. I would like these to appear non-italicised (in roman) in the final PDF output. Using any of \emph or \textit or \textrm on these items doesn't seem to make any difference -- the whole title still appears in italics.  Minimal .bib entry  @PHDTHESIS{klein1974, author = {Klein, Jared S.}, title = {The Particle \emph{u} in the {R}igveda}, school = {Yale}, year = {1974}, address = {New Haven, CT}, timestamp = {2009.12.04} }   Minimal .bbl entry generated by sp.bst:  \bibitem[{Klein(1974)}]{klein1974} Klein, Jared~S. 1974. \newblock \emph{The particle \emph{u} in the {R}igveda}. \newblock New Haven, CT: Yale dissertation. Is a "split plot" ANOVA with two factors the same as two-way ANOVA with repeated measures in one factor? Is a "split plot" ANOVA with two factors identical to two-way ANOVA with repeated measures in one factor? if not, what is the distinction? Could the Olympians use modern celestial weapons? Instead of using short range celestial bronze (CB) weapons like swords and arrows why not make advanced weapons like machine guns or grenades with CB shrapnel in it? How can multithreading speed up an application (when threads can't run concurrently)? How do I view all available HDD's/partitions?