Implementation using Julia

For Julia, we use the package called Clustering. The next example is borrowed from Lin, Regier, and Arslan (2016) with a minor modification (https://github.com/JuliaStats/Clustering.jl/blob/master/test/affprop.jl). First, we generate a set of random numbers. Then, replace the values along the main diagonal line with the median values. Then, the program classifies them into different groups:

using Base.Test 
using Distances 
using Clustering 
# 
srand(12345) 
d = 10 
n = 500 
x = rand(d, n) 
S = -pairwise(Euclidean(), x, x) 
# set diagonal value to median value 
S = S - diagm(diag(S)) + median(S)*eye(size(S,1))  
R = affinityprop(S) 

The output is shown here:

Based on the output, we see a few groups and which numbers belong ...

Get Hands-On Data Science with Anaconda now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.