[R] K mean clustering with extra constraints

Ranjan Maitra maitra.mbox.ignored at inbox.com
Thu Mar 24 23:31:44 CET 2016


Hannah,

Let me see if I can understand your question. 

You have 10 observations of a single variable (perhaps some sort of price?).

You also have an equivalence matrix between these observations (which you possibly called nodes) which stipulates if they are connected together or not. Given that you have this matrix, it is not clear to me why you want further (k-means or other) clustering.

The only thing that seems to me to be reasonable to check is whether two or more of the groups can be merged. But that has nothing to do with clustering.

I may have misunderstood the problem, so sorry. 

Btw, no, the k-means function in R can not handle constraints. 

Ranjan



On Thu, 24 Mar 2016 19:08:51 +0100 Tsai Rainbow <rainbowafmb at gmail.com> wrote:

> Hi, I am a new R user. I have seen the use of kmeans in clustering.
> However, I would like to ask how I can add more constraints to the kmeans.
> For example, I have a set of data for a 10 nodes network,
> 
> price = c(84, 96, 57, 53, 90, 94, 81, 66, 93, 54)
> 
> I want to use K mean to to group this set of data into two group. However,
> nodes in the same group should be in the same group. they are connected as
> below.
> 
>  mymatrix <- rbind(
> +      c(1,1,2,3,3,3,2,1,1,1),
> +      c(1,1,1,2,2,2,1,1,1,1),
> +      c(2,1,1,1,1,1,1,1,2,2),
> +      c(3,2,1,1,1,1,1,2,3,3),
> +      c(3,2,1,1,1,1,1,2,3,3),
> +      c(3,2,1,1,1,1,1,2,2,2),
> +      c(2,1,1,1,1,1,1,1,2,2),
> +      c(1,1,1,2,2,2,1,1,1,1),
> +      c(1,1,2,3,3,2,2,1,1,1),
> +      c(1,1,2,3,3,2,2,1,1,1))
> 
> How can I do it in R. I greatly appreciate your help. I wish a happy
> Easter.
> 
> Hanna
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


-- 
Important Notice: This mailbox is ignored: e-mails are set to be deleted on receipt. Please respond to the mailing list if appropriate. For those needing to send personal or professional e-mail, please use appropriate addresses.

____________________________________________________________
Send any screenshot to your friends in seconds...
Works in all emails, instant messengers, blogs, forums and social networks.
TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE



More information about the R-help mailing list