-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep5_affinity_prop.Rmd
87 lines (62 loc) · 1.22 KB
/
step5_affinity_prop.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
title: "Affinity Propagation Practice"
author: "Noah Klammer"
date: "5/07/2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
```
## Clear global env and report
```{r include=FALSE}
rm(list = ls())
gc()
```
# Intro
Here I am experimenting with the package `apcluster`.
# Body
```{r}
library(apcluster)
data("iris")
1:nrow(iris)
alpha <- c(letters,
paste0("a",letters),
paste0("b",letters),
paste0("c",letters),
paste0("d",letters),
paste0("e",letters)
)
# assign row names
rownames(iris) <- alpha[1:nrow(iris)]
apIris1 <- apcluster(negDistMat(r=2), iris)
apIris1
```
```{r}
plot(apIris1, iris)
dev.new(width = 5, height = 10, unit = "in", noRStudioGD = TRUE)
```
```{r}
apcluster::heatmap(apIris1)
```
```{r}
# slot `p` for input preference
# aka q in the parameter argument
# For default q=0.5, this is the median
# of all input simularities
# apIris1@p
# how many exemplars?
length(apIris1@exemplars)
# what is the sixth exemplar?
# ALSO what about labeled variables?
apIris1@exemplars[6]
# how many iterations?
apIris1@it
# what points are in the 2nd cluster?
what <- apIris1@clusters
length(what[[1]])
# how many clusters
length(what)
```
# End
<br><br><br>