<commit_before>use Test::More 'no_plan';
use strict;
use File::Temp 'tempdir';
use AI::FANN::Evolving;

# instantiate factory
my $fac = AI::FANN::Evolving::Factory->new;
ok( $fac->can('create') );

# create the training data for a XOR operator:
my $xor_train = AI::FANN::TrainData->new( 
	[-1, -1] => [-1],
	[-1,  1] => [ 1],
    [ 1, -1] => [ 1],
    [ 1,  1] => [-1] 
);
ok( $xor_train->isa('AI::FANN::TrainData') );

# create the experiment
my $exp = $fac->create_experiment( 
	'workdir'   => tempdir( 'CLEANUP' => 1 ),
	'traindata' => $xor_train,
	'factory'   => $fac,
	'env'       => $xor_train,
	'mutation_rate' => 0.1,
	'ngens'         => 10,
);
ok( $exp->isa('Algorithm::Genetic::Diploid::Experiment') );

# initialize the experiment
ok( $exp->initialize );

# run!
$exp->run();<commit_msg>modified to use real data<commit_after>use Test::More 'no_plan';
use strict;
use FindBin qw($Bin);
use File::Temp 'tempdir';
use AI::FANN::Evolving;

# input files
my $dir = "$Bin/../examples";

# instantiate factory
my $fac = AI::FANN::Evolving::Factory->new;
ok( $fac->can('create') );

# create the experiment
my $exp = $fac->create_experiment( 
	'workdir'   => tempdir( 'CLEANUP' => 1 ),
	'traindata' => $fac->create_traindata( 'file' => "$dir/bb_train.tsv" )->to_fann,
	'factory'   => $fac,
	'env'       => $fac->create_traindata( 'file' => "$dir/bb_test.tsv" )->to_fann,
	'mutation_rate' => 0.1,
	'ngens'         => 10,
);
ok( $exp->isa('Algorithm::Genetic::Diploid::Experiment') );

# initialize the experiment
ok( $exp->initialize );

# run!
$exp->run();
{'fraction_non_alphanumeric': 0.225, 'fraction_numerical': 0.014102564102564103, 'mean_word_length': 4.309523809523809, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2162301', 'n_tokens_mistral': 646, 'n_tokens_neox': 617, 'n_words': 134}