### ----------------------------------------------------
### -- ML::AssociationRuleLearning
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: t/04-correct-support.rakutest
### ----------------------------------------------------
use v6.d;
use Test;

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

use ML::AssociationRuleLearning;
use Data::ExampleDatasets;
use Data::Reshapers;

plan 3;

## 1
my @dsTitanic = get-titanic-dataset();
my @freqSets1 = eclat(@dsTitanic.map({ $_.values.List }).Array, min-support => 171, min-number-of-items => 2, max-number-of-items => 6):counts;

my @freqSetsCheck = @freqSets1.map( -> $fq { $fq.key => @dsTitanic.grep({ ($_.values (&) $fq.key).elems == $fq.key.elems }).elems });

is-deeply @freqSets1, @freqSetsCheck, 'Titanic correctness check';

## 2
my @freqSets2 = apriori(@dsTitanic.map({ $_.values.List }).Array, min-support => 171, min-number-of-items => 2, max-number-of-items => 6):counts;

is-deeply @freqSets2.keys, @freqSets1.keys, 'Apriori-vs-Eclat over Titanic correctness check: frequent sets';

## 3
is-deeply @freqSets2.Hash.deepmap({ $_.Int }), @freqSets1.Hash, 'Apriori-vs-Eclat over Titanic correctness check: counts';

done-testing;


