Subject: | AI::DecisionTree does not work as expected |
Date: | Thu, 29 Dec 2016 19:35:25 +0000 |
To: | "bug-AI-DecisionTree [...] rt.cpan.org" <bug-AI-DecisionTree [...] rt.cpan.org> |
From: | Jonas Lindholm <jonas.lindholm [...] nasdaq.com> |
Hi,
Using version 0.11 of AI::DecisionTree with Perl v5.10.1 on CentOS 6.8.
I copied the example code:
#!/usr/bin/perl
use AI::DecisionTree;
my $dtree = new AI::DecisionTree;
# A set of training data for deciding whether to play tennis
$dtree->add_instance
(attributes => {outlook => 'sunny',
temperature => 'hot',
humidity => 'high'},
result => 'no');
$dtree->add_instance
(attributes => {outlook => 'overcast',
temperature => 'hot',
humidity => 'normal'},
result => 'yes');
$dtree->train;
print $dtree->rule_statements(), "\n";
# Find results for unseen instances
my $result = $dtree->get_result
(attributes => {outlook => 'sunny',
temperature => 'hot',
humidity => 'normal'});
exit;
The rule_statement() return just the following:
# perl test.pl
-> 'yes'
I expect the following should have been returned:
[ 'outlook', {
'rain' => [ 'wind', {
'strong' => 'no',
'weak' => 'yes',
} ],
'sunny' => [ 'humidity', {
'normal' => 'yes',
'high' => 'no',
} ],
'overcast' => 'yes',
} ]
Running a make test in dir AI-DecisionTree-0.11:
# make test
make[1]: Entering directory `/usr/src/AI-DecisionTree-0.11/Instance'
make[1]: Leaving directory `/usr/src/AI-DecisionTree-0.11/Instance'
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01-simple.t ...... ok
t/02-noisy.t ....... ok
t/author-critic.t .. skipped: these tests are for testing by the author
All tests successful.
Files=3, Tests=36, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.15 cusr 0.01 csys = 0.19 CPU)
Result: PASS
make[1]: Entering directory `/usr/src/AI-DecisionTree-0.11/Instance'
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, '../blib/lib', '../blib/arch')" t/*.t
t/01-basic.t ..... ok
t/02-leaktest.t .. 1/4 Subroutine AI::DecisionTree::Instance::DESTROY redefined at t/02-leaktest.t line 11.
t/02-leaktest.t .. ok
All tests successful.
Files=2, Tests=11, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.01 cusr 0.00 csys = 0.03 CPU)
Result: PASS
make[1]: Leaving directory `/usr/src/AI-DecisionTree-0.11/Instance'
Regards
/Jonas
***********************************************************
CONFIDENTIALITY NOTICE: This e-mail and any attachments are for the exclusive and confidential use of the intended recipient and may constitute non-public information. If you received this e-mail in error, disclosing, copying, distributing or taking any action in reliance of this e-mail is strictly prohibited and may be unlawful. Instead, please notify us immediately by return e-mail and promptly delete this message and its attachments from your computer system. We do not waive any work product or other applicable legal privilege(s) by the transmission of this message.
***********************************************************