This notebook is written in R. The ggplot and apcluster were installed when Binder started - you can see how by examining the repo for these notebooks.
Note that you'll get an error when you run the import script. That's because my code for writing the json in the other notebook used '
rather than "
.
# import the data
library(jsonlite)
mydata <- fromJSON("image_tsne_projections.json", flatten=TRUE)
# uncomment the 'install.packages' lines the first time you run this
# install.packages("ggplot2")
library(ggplot2)
g = ggplot(mydata, aes(x = x, y = y)) + geom_point() + labs(title = "T-SNE Plot of Image Similarity Vectors")
print(g)
X <- cbind(mydata$x, mydata$y)
## affinity propogation
# install.packages("apcluster")
library(apcluster)
Attaching package: ‘apcluster’ The following object is masked from ‘package:stats’: heatmap
d.apclus <- apcluster(negDistMat(r=2), X)
cat("affinity propogation optimal number of clusters:", length(d.apclus@clusters), "\n")
affinity propogation optimal number of clusters: 4
plot(d.apclus, X)