[R] clustering fuzzy
pete
pieroleone at hotmail.it
Sat Jan 22 16:19:22 CET 2011
I must get an index (fuzzy silhouette), a weighted average. A average the
crisp silhouette for every row (i) s and the weight of each term is
determined by the difference between the membership degrees of corrisponding
object to its first and second best matching fuzzy clusters.
i need the difference between values the first and second coloumns for every
row (i) to be multiplied with a index(Crisp silhouette) s on each unit (row)
and then divide by the sum of all these differences
jholtman wrote:
>
> use 'apply':
>
>> head(x.m)
> V2 V3 V4 V5
> [1,] 0.66 0.04 0.01 0.30
> [2,] 0.02 0.89 0.09 0.00
> [3,] 0.06 0.92 0.01 0.01
> [4,] 0.07 0.71 0.21 0.01
> [5,] 0.10 0.85 0.04 0.01
> [6,] 0.91 0.04 0.02 0.02
>> x.m.sort <- apply(x.m, 1, sort, decreasing = TRUE)
>> head(t(x.m.sort))
> [,1] [,2] [,3] [,4]
> [1,] 0.66 0.30 0.04 0.01
> [2,] 0.89 0.09 0.02 0.00
> [3,] 0.92 0.06 0.01 0.01
> [4,] 0.71 0.21 0.07 0.01
> [5,] 0.85 0.10 0.04 0.01
> [6,] 0.91 0.04 0.02 0.02
>>
>
>
> On Fri, Jan 21, 2011 at 10:07 AM, pete <pieroleone at hotmail.it> wrote:
>>
>> hello,
>> i'm pete ,how can i order rows of matrix by max to min value?
>> I have a matrix of membership degrees, with 82 (i) rows and K coloumns, K
>> are clusters.
>> I need first and second largest elements of the i-th row.
>>
>> for example
>> 1 0.66 0.04 0.01 0.30
>> 2 0.02 0.89 0.09 0.00
>> 3 0.06 0.92 0.01 0.01
>> 4 0.07 0.71 0.21 0.01
>> 5 0.10 0.85 0.04 0.01
>> 6 0.91 0.04 0.02 0.02
>> 7 0.00 0.01 0.98 0.00
>> 8 0.02 0.05 0.92 0.01
>> 9 0.05 0.54 0.40 0.01
>> 10 0.02 0.06 0.92 0.00
>> 11 0.05 0.55 0.39 0.01
>> 12 0.77 0.02 0.01 0.20
>> 13 0.95 0.01 0.00 0.04
>> 14 0.43 0.33 0.18 0.06
>> 15 0.79 0.10 0.08 0.03
>> 18 0.02 0.04 0.94 0.00
>> 20 0.09 0.15 0.76 0.01
>> 21 0.80 0.10 0.07 0.03
>> 22 0.06 0.15 0.79 0.01
>> 23 0.05 0.01 0.00 0.94
>> 24 0.83 0.02 0.01 0.15
>> 25 0.87 0.05 0.03 0.04
>> 27 0.76 0.10 0.11 0.03
>> 28 0.17 0.68 0.10 0.05
>> 29 0.10 0.01 0.00 0.90
>> 30 0.09 0.29 0.60 0.01
>> 31 0.05 0.01 0.00 0.94
>> 32 0.53 0.04 0.01 0.43
>> 33 0.85 0.04 0.02 0.09
>> 34 0.82 0.06 0.02 0.10
>> 35 0.76 0.07 0.02 0.14
>> 37 0.36 0.31 0.30 0.02
>> 38 0.01 0.02 0.97 0.00
>> 39 0.12 0.04 0.02 0.82
>> 40 0.02 0.00 0.00 0.97
>> 41 0.57 0.15 0.02 0.25
>> 42 0.14 0.03 0.02 0.82
>> 43 0.89 0.06 0.01 0.03
>> 44 0.02 0.00 0.00 0.98
>> 45 0.61 0.02 0.01 0.36
>> 46 0.03 0.00 0.00 0.97
>> 47 0.88 0.07 0.02 0.03
>> 48 0.06 0.60 0.32 0.02
>> 49 0.01 0.98 0.01 0.00
>> 50 0.06 0.88 0.05 0.01
>> 51 0.01 0.05 0.93 0.00
>> 52 0.02 0.08 0.90 0.00
>> 53 0.11 0.01 0.01 0.87
>> 54 0.27 0.01 0.00 0.72
>> 55 0.94 0.03 0.01 0.02
>> 58 0.45 0.41 0.05 0.09
>> 59 0.12 0.61 0.22 0.05
>> 60 0.26 0.07 0.02 0.64
>> 61 0.17 0.19 0.62 0.02
>> 62 0.08 0.00 0.00 0.92
>> 63 0.02 0.94 0.03 0.00
>> 64 0.08 0.01 0.00 0.91
>> 65 0.98 0.01 0.00 0.01
>> 67 0.22 0.69 0.08 0.01
>> 68 0.96 0.02 0.00 0.02
>> 69 0.96 0.02 0.01 0.01
>> 71 0.00 0.01 0.98 0.00
>> 72 0.56 0.05 0.01 0.37
>> 73 0.10 0.01 0.01 0.88
>> 74 0.91 0.01 0.00 0.08
>> 75 0.36 0.38 0.21 0.05
>> 76 0.15 0.40 0.44 0.01
>> 77 0.02 0.06 0.91 0.00
>> 78 0.48 0.43 0.03 0.06
>> 79 0.51 0.02 0.01 0.45
>> 80 0.04 0.01 0.00 0.95
>> 81 0.47 0.03 0.01 0.49
>> 82 0.98 0.01 0.00 0.01
>> 83 0.05 0.01 0.01 0.93
>> 84 0.03 0.00 0.00 0.96
>> 85 0.76 0.07 0.01 0.15
>> 86 0.95 0.03 0.01 0.01
>> 88 0.03 0.00 0.00 0.96
>> 90 0.79 0.13 0.02 0.06
>> 91 0.37 0.50 0.05 0.09
>> 92 0.86 0.10 0.02 0.02
>> 93 0.13 0.82 0.03 0.01
>>
>>
>> A[1,][order(A[1,],decreasing=TRUE)]
>> [1] 0.66 0.30 0.04 0.01
>>
>> I want this for every row
>> thank you
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/clustering-fuzzy-tp3229853p3229853.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> 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.
>>
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
>
--
View this message in context: http://r.789695.n4.nabble.com/clustering-fuzzy-tp3229853p3231477.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list