### ----------------------------------------------------
### -- ML::AssociationRuleLearning
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: t/01-basic-usage-frequent-sets.rakutest
### ----------------------------------------------------
use v6.d;
use Test;

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

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

sub is-list-of-lists($arr) {
    $arr ~~ List and ([and] $arr.map({ $_ ~~ List }))
}

plan 9;

## 1
use-ok 'Data::ExampleDatasets', 'Data::ExampleDatasets loads ok';

## 2
use-ok 'Data::Reshapers', 'Data::Reshapers loads ok';

## 3
my @dsTitanic = get-titanic-dataset();
is is-list-of-lists(@dsTitanic.map({ $_.values.List }).Array), True, 'Expected @dsTitanic transformed shape';

## 4
ok frequent-sets(@dsTitanic, 200);

## 5
ok frequent-sets(@dsTitanic, 0.2);

## 6
ok frequent-sets(@dsTitanic, min-support => 200, min-number-of-items => 2, max-number-of-items => 5);

## 7
ok frequent-sets(@dsTitanic, min-support => 200, min-number-of-items => 2, max-number-of-items => 5):counts;

## 8
ok frequent-sets(@dsTitanic.map({ $_.values.List }).Array, 200);

## 9
ok frequent-sets(@dsTitanic.map({ $_.values.List }).Array, 200, method => 'Eclat');

done-testing;



