binarizeKMeans: k-means Binarization

Description Usage Arguments Value See Also Examples

Description

Binarizes a vector of real-valued data using the k-means clustering algorithm. The data is first split into 2 clusters.The values belonging to the cluster with the smaller centroid are set to 0, and the values belonging to the greater centroid are set to 1.

Usage

1
2
3
4
5
binarize.kMeans(vect, 
                nstart=1, 
                iter.max=10,
                dip.test=TRUE,
                na.rm=FALSE)

Arguments

vect

A real-valued vector to be binarized (at least 3 measurements).

nstart

The number of restarts for k-means. See kmeans for details.

iter.max

The maximum number of iterations for k-means. See kmeans for details.

dip.test

If set to TRUE, Hartigan's dip test for unimodality is performed on vect, and its p-value is returned in the pvalue slot of the result. An insignificant test indicates that the data may not be binarizeable.

na.rm

If set to TRUE, NA values are removed from the input. Otherwise, binarization will fail in the presence of NA values.

Value

Returns an object of class BinarizationResult.

See Also

kmeans, BinarizationResult, BoolNet

Examples

1
2
3
4
result <- binarize.kMeans(iris[,"Petal.Length"])

print(result)
plot(result, twoDimensional=TRUE)

Example output

Loading required package: diptest
Method: k-Means

Threshold: 3.15

Binarized vector: [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ]

p value: 0
$ylab
[1] ""

$xlab
[1] ""

$lty
[1] 2

$cex.axis
[1] 1

$cex.lab
[1] 1

$pch
  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1
[112] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[149] 1 1

$col
  [1] "red"   "red"   "red"   "red"   "red"   "red"   "red"   "red"   "red"  
 [10] "red"   "red"   "red"   "red"   "red"   "red"   "red"   "red"   "red"  
 [19] "red"   "red"   "red"   "red"   "red"   "red"   "red"   "red"   "red"  
 [28] "red"   "red"   "red"   "red"   "red"   "red"   "red"   "red"   "red"  
 [37] "red"   "red"   "red"   "red"   "red"   "red"   "red"   "red"   "red"  
 [46] "red"   "red"   "red"   "red"   "red"   "green" "green" "green" "green"
 [55] "green" "green" "green" "green" "green" "green" "green" "green" "green"
 [64] "green" "green" "green" "green" "green" "green" "green" "green" "green"
 [73] "green" "green" "green" "green" "green" "green" "green" "green" "green"
 [82] "green" "green" "green" "green" "green" "green" "green" "green" "green"
 [91] "green" "green" "green" "green" "green" "green" "green" "green" "red"  
[100] "green" "green" "green" "green" "green" "green" "green" "green" "green"
[109] "green" "green" "green" "green" "green" "green" "green" "green" "green"
[118] "green" "green" "green" "green" "green" "green" "green" "green" "green"
[127] "green" "green" "green" "green" "green" "green" "green" "green" "green"
[136] "green" "green" "green" "green" "green" "green" "green" "green" "green"
[145] "green" "green" "green" "green" "green" "green"

$type
[1] "p"

$xaxt
[1] "n"

$x
  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
 [19]  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36
 [37]  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54
 [55]  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72
 [73]  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90
 [91]  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108
[109] 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
[127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
[145] 145 146 147 148 149 150

$y
  [1] 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 1.5 1.6 1.4 1.1 1.2 1.5 1.3 1.4
 [19] 1.7 1.5 1.7 1.5 1.0 1.7 1.9 1.6 1.6 1.5 1.4 1.6 1.6 1.5 1.5 1.4 1.5 1.2
 [37] 1.3 1.4 1.3 1.5 1.3 1.3 1.3 1.6 1.9 1.4 1.6 1.4 1.5 1.4 4.7 4.5 4.9 4.0
 [55] 4.6 4.5 4.7 3.3 4.6 3.9 3.5 4.2 4.0 4.7 3.6 4.4 4.5 4.1 4.5 3.9 4.8 4.0
 [73] 4.9 4.7 4.3 4.4 4.8 5.0 4.5 3.5 3.8 3.7 3.9 5.1 4.5 4.5 4.7 4.4 4.1 4.0
 [91] 4.4 4.6 4.0 3.3 4.2 4.2 4.2 4.3 3.0 4.1 6.0 5.1 5.9 5.6 5.8 6.6 4.5 6.3
[109] 5.8 6.1 5.1 5.3 5.5 5.0 5.1 5.3 5.5 6.7 6.9 5.0 5.7 4.9 6.7 4.9 5.7 6.0
[127] 4.8 4.9 5.6 5.8 6.1 6.4 5.6 5.1 5.6 6.1 5.6 5.5 4.8 5.4 5.6 5.1 5.1 5.9
[145] 5.7 5.2 5.0 5.2 5.4 5.1

Binarize documentation built on May 1, 2019, 7:05 p.m.