### ----------------------------------------------------
### -- ML::Clustering
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: t/02-K-means-signatures.rakutest
### ----------------------------------------------------
use v6.d;
use Test;

use lib '.';
use lib './lib';

use ML::Clustering;

my @data = [[8.8845, 8.85299], [10.7631, 10.0743], [5.5837, 5.7045], [6.20079, 4.44996], [5.63563, 4.90427], [11.4208, 9.9716], [9.96403, 10.7581],
            [9.39692, 10.0488], [5.11328, 6.06336], [10.1259, 10.0986], [8.70212, 10.9793], [6.72581, 4.68825], [9.35168, 11.3989], [11.1143, 9.83808],
            [1.39918, 4.68761], [9.52037, 9.25203], [10.8884, 9.72814], [9.2392, 10.9824], [5.70614, 4.53029], [5.91573, 5.56325], [9.88611, 9.6814],
            [10.1955, 10.5845], [6.05243, 5.61693], [9.7976, 9.62952], [6.71941, 10.4375], [3.99645, 5.47667], [8.55, 10.0132],
            [11.6791, 9.68773], [4.49344, 4.39623], [11.7249, 9.01892], [9.26977, 9.435], [5.48549, 4.45354], [8.78011, 10.4098], [10.0875, 8.86989],
            [4.47884, 5.62891], [5.38243, 4.46582], [8.87448, 12.4712], [10.8829, 10.0613], [7.43311, 11.9658], [11.8415, 9.49547], [5.57552, 4.60037],
            [10.7726, 9.5777], [8.75748, 12.4097], [10.3369, 10.443], [5.62952, 3.95791], [5.12649, 5.97215], [6.047, 4.72771], [6.43792, 4.51661],
            [9.18794, 10.0156], [11.0324, 9.55889], [3.32419, 4.85804], [5.6912, 5.49363], [10.9631, 10.1856], [8.29603, 10.3623],
            [7.23275, 4.79475], [7.72719, 6.06401], [10.5089, 10.0852], [8.84916, 10.0851], [11.7991, 9.51013], [3.80262, 4.43198], [10.8495, 8.94943],
            [12.4197, 9.07179], [11.8075, 8.45054], [10.4864, 10.3052], [6.16251, 5.2654], [9.01089, 9.97649], [11.114, 9.66312], [11.3973, 9.33427],
            [5.97944, 4.54014], [3.91852, 4.13549], [5.32664, 5.00921], [13.5242, 9.17801], [11.0185, 10.4902], [3.7172, 6.02797], [7.5785, 10.6861],
            [9.19831, 10.6158], [7.75939, 10.5714], [6.89816, 5.55528], [10.2661, 10.3225], [8.90186, 11.6354]];

plan 8;

## 1
ok find-clusters(@data, 2, method => 'K-means');

## 2
ok find-clusters(@data, 2, method => 'K-means', learning-parameter => 0.01,  max-steps => 200, min-reassignment-fraction => 1/100, prop => 'All');

## 3
ok find-clusters(@data, 2, prop => 'Clusters');

## 4
ok find-clusters(@data, 2, prop => 'ClusterLabels');

## 5
dies-ok { find-clusters(@data, 2, prop => 'ClusterIndexes') };

## 6
ok find-clusters(@data, 2, distance-function => 'Cosine', prop => 'ClusterLabels');

## 7
my @cls = |find-clusters(@data, 2, distance-function => 'Cosine', prop => 'Clusters');
is @cls ~~ Positional && @cls.elems == 2, True, 'Result shape';

## 8
ok k-means(@data, 2, distance-function => 'Cosine', prop => 'ClusterLabels');

done-testing;


