$dt->run
return rule results as
[[1, 0, 1], [1, 1], [1, 0], [0, 1]]
and the rules obj private member '_true_false_results' fields are set to the results as well:
[
bless({ _true_false_results => [1, 0, 1], actions => [2, 1], true => [0, 1, 2] }, "Decision::Table::Rule::Indexed"),
bless({ _true_false_results => [1, 1], actions => [1], true => [0, 2] }, "Decision::Table::Rule::Indexed"),
bless({ _true_false_results => [1, 0], actions => [0], true => [0, 1] }, "Decision::Table::Rule::Indexed"),
bless({ _true_false_results => [0, 1], actions => [0], true => [1, 2] }, "Decision::Table::Rule::Indexed"),
],
decide
[ { DISTANCE => 29, DISTANCE_DETAILS => [3, 1, 4, 3, 3, 3, 3, 3, 3, 3], RULE => bless({ actions => [0], code => "+++ +++ +++ --- --- --- --- --- --- ---", id => 0, translated => [3, 3, 3, -3, -3, -3, -3, -3, -3, -3], }, "Decision::Table::Rule::Combination::PlusMinus"), }, { DISTANCE => 17, DISTANCE_DETAILS => [3, 5, 2, 1, 1, 1, 1, 1, 1, 1], RULE => bless({ actions => [1], code => "--- --- --- + + + + + + + ", id => 1, translated => [-3, -3, -3, 1, 1, 1, 1, 1, 1, 1], }, "Decision::Table::Rule::Combination::PlusMinus"), }, { DISTANCE => 6, DISTANCE_DETAILS => [3, 2, 1, 0, 0, 0, 0, 0, 0, 0], RULE => bless({ actions => [2], code => "+++ ", id => 2, translated => [3, 0, 0, 0, 0, 0, 0, 0, 0, 0], }, "Decision::Table::Rule::Combination::PlusMinus"), }, { DISTANCE => 4, DISTANCE_DETAILS => [1, 1, 2, 0, 0, 0, 0, 0, 0, 0], RULE => bless({ actions => [3], code => "- + + ", id => 3, translated => [-1, 1, 1, 0, 0, 0, 0, 0, 0, 0], }, "Decision::Table::Rule::Combination::PlusMinus"), }, { DISTANCE => 9, DISTANCE_DETAILS => [0, 5, 4, 0, 0, 0, 0, 0, 0, 0], RULE => bless({ actions => [4], code => " --- +++ ", id => 4, translated => [0, -3, 3, 0, 0, 0, 0, 0, 0, 0], }, "Decision::Table::Rule::Combination::PlusMinus"), },
.. ]
$dt->score_to_text( $results )
Formats and print he href from $dt->score
as a human readible text.
translates
{
DISTANCE => 9,
DISTANCE_DETAILS => [0, 5, 4, 0, 0, 0, 0, 0, 0, 0],
RULE => bless({
actions => [4],
code => " --- +++ ",
id => 4,
translated => [0, -3, 3, 0, 0, 0, 0, 0, 0, 0],
}, "Decision::Table::Rule::Combination::PlusMinus"),
},
to
$array_ref =
[
tcf1 => 28.44
tcf1 => 28.13
tcf3 => 26.92
tcf3 => 26.09
gapdh => 17.08
gapdh => 16.1
];
Then a call
transform_array_to_hash( $array_ref )
will return this hash
{
gapdh => ["17.08", "16.1"],
tcf1 => ["28.44", "28.13"],
tcf3 => ["26.92", "26.09"],
}
NAME
Decision::Table::Diagnostic::Combinations - make diagnostic decisions on combinations of attributes
SYNOPSIS
use Decision::Table;
use Decision::Table::Diagnostic;
sub score
{
my $string = shift;
my $val;
$val += ( { '+' => 1, '-' => -1 }->{$_} || 0 ) foreach split //, $string;
return $val;
}
sub digest
{
my $encoded = shift || die;
return [ map { score( $_ ) } ( $encoded =~ m/(...)\s?/g ) ];
}
our $dtp;
# Diagnosis Score
#
# In a Diagnosis Score Table the Decision Table 'actions' are diagnosis.
#
# We have a homologe scores:
#
# +++ = 3 (absolutely sure)
# ++ = 2 (yes, yes)
# + = 1 (yes)
# = 0 (indifferent)
# - = -1 (no)
# -- = -2 (no, no)
# --- = -3 (definitifly not)
$dtp = Decision::Table::Diagnostic->new(
conditions =>
[
Decision::Table::Condition->new( text => 'nadeln = ja' ), # C0
Decision::Table::Condition->new( text => 'nadeln = nein' ), # C1
Decision::Table::Condition->new( text => 'Rundliche Zapfen' ), # C2
Decision::Table::Condition->new( text => 'Laengliche Zapfen' ), # C3
Decision::Table::Condition->new( text => '-- haengend' ), # C4
Decision::Table::Condition->new( text => '-- stehend' ), # C5
Decision::Table::Condition->new( text => 'Lange Nadeln' ), # C6
Decision::Table::Condition->new( text => 'Kurze Nadeln' ), # C7
Decision::Table::Condition->new( text => '-- eher scheitelfoermig' ), # C8
Decision::Table::Condition->new( text => '-- rundum' ), # C9
Decision::Table::Condition->new( text => 'Rissige oder geborstene Rinde' ), # C10
],
actions =>
[
Decision::Table::Action->new( text => 'Kiefer' ),
Decision::Table::Action->new( text => 'Tanne' ),
Decision::Table::Action->new( text => 'Fichte' ),
Decision::Table::Action->new( text => 'Eiche' ),
Decision::Table::Action->new( text => 'Buche' ),
Decision::Table::Action->new( text => 'Linde' ),
Decision::Table::Action->new( text => 'Esche' ),
Decision::Table::Action->new( text => 'Birke' ),
Decision::Table::Action->new( text => 'Ahorn' ),
Decision::Table::Action->new( text => 'Kastanie' ),
Decision::Table::Action->new( text => 'Muratze' ),
Decision::Table::Action->new( text => 'Unbekannt' ),
],
rules =>
[
#C0 C1 C2 C3 C4 C5 C6 C7 C8 C9
digest( '+++ +++ +++ --- --- --- --- --- --- ---' ) => [ 0 ], # Kiefer
digest( '--- --- --- + + + + + + + ' ) => [ 1 ], # Tanne
digest( '+++ ' ) => [ 2 ], # Fichte
digest( '- + + ' ) => [ 3 ], # Eiche
digest( ' --- +++ ' ) => [ 4 ], # Buche
digest( '+++ - - ' ) => [ 5 ], # Linde
digest( '- + + ' ) => [ 6 ], # Esche
digest( ' ++ - ' ) => [ 7 ], # Birke
digest( ' -- ' ) => [ 8 ], # Ahorn
digest( '+++ +++ +++ --- --- --- --- --- --- ---' ) => [ 9 ], # Kastanie
digest( '+++ +++ +++ --- --- --- --- --- --- ---' ) => [ 10 ], # "Muratze" ;)
],
else => [ 10 ],
);
# I have a patient, give him diagnosis
#C0 C1 C2 C3 C4 C5 C6 C7 C8 C9
print "\nDIAGNOSIS for ' ++ - '\n";
#C0 C1 C2 C3 C4 C5 C6 C7 C8 C9
print Dumper my $results = $dtp->decide( digest( ' ++ - ' ) );
print "Rangliste:\n\n";
$dtp->score_to_text( $results );
# Lets look who is similar (DIFFERENTIAL DIAGNOSIS) to each other
# and we could even detect identical diagnosis
$dtp->analyse();
DESCRIPTION
Make diagnosis from knowledge (of an expert). In essence the technique is similar to an expert system or markov believe networks. The simple data structure is but far more easier to maintain (and to understand). Through computation of probilistic values you become a picture which diagnosis is the best (or better which set of diagnosis is the most probalistic ones). The above synopsis (in german) outlines the recognition of trees by their leafs, envelope and fir-cones etc.
Decision::Table::Partial
This is a decision table that has an addtional attribute else
. If all conditions fail than this actions will be called.
else => [ 0, 5, 2 ]
for example would call action 0, 5, and 2 if no conditions matched.
METHODS
$dt = Decision::Table::Diagnostic->new( conditions => [], actions => [], rules => [] )
- - conditions the condition objects in an aref
- - actions action objects in an aref
- - rules a condition action combinatorial hash (see Decision::Table constructor).
- - else the actions called when no rule applied (attests that this is a partial decision table)
$dt->decide( $patient )
This method computes the highscore of comulative probalistic values (by comparing to a given $patient
). It returns a href with a table of following scheme
{
$score => [ $action_id, $action_id, ... ],
}
[DE Ziel: Suche die Evtl. Decision::Table::Actions herraus die am wenigsten "Abstand" (mengen_differenz) zu unserem "Patienten" haben].
Imagine you found a tree with following attributes (encoded by + and -, see synopsis)
digest( ' ++ - ' )
and want to retrieve the highscore of the probabilistic of type.
print Dumper my $results = $dtp->decide( digest( ' ++ - ' ) );
This would print the highscore as a raw perl hash.
$dt->analyse;
Analyses the virgin $dt and displays informative text. It prints how far
away (or near) the expected diagnoses are (in terms of problabilistic values), so one can get a picture which diagnosis will always be very close to each other. So from the synopsis it would print
Rangliste:
0 => Birke
4 => Eiche, Esche
5 => Ahorn
6 => Fichte, Linde
9 => Buche
17 => Tanne
29 => Kiefer, Kastanie, Muratze
Who is similar to Kiefer ?
0 => Kiefer, Kastanie, Muratze
27 => Fichte
28 => Ahorn
29 => Eiche, Linde, Esche, Birke
30 => Buche
46 => Tanne
Who is similar to Tanne ?
0 => Tanne
16 => Buche
17 => Eiche, Linde, Esche, Birke
18 => Ahorn
19 => Fichte
46 => Kiefer, Kastanie, Muratze
Who is similar to Fichte ?
0 => Fichte
2 => Linde
5 => Ahorn
6 => Eiche, Esche, Birke
9 => Buche
19 => Tanne
27 => Kiefer, Kastanie, Muratze
Who is similar to Eiche ?
0 => Eiche, Esche
4 => Birke
5 => Ahorn
6 => Fichte
7 => Buche
8 => Linde
17 => Tanne
29 => Kiefer, Kastanie, Muratze
Who is similar to Buche ?
0 => Buche
7 => Eiche, Esche
8 => Ahorn
9 => Fichte, Linde, Birke
16 => Tanne
30 => Kiefer, Kastanie, Muratze
...
EXPORT
None by default.
AUTHOR
Murat Ünalan, <muenalan@cpan.org>
SEE ALSO
Decision::Table::Diagnostic, Decision::Table::Wheighted
REFERENCES
<1> Book (German): M. Rammè, "Entscheidungstabellen: Entscheiden mit System" (Prentice Hall))
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 571:
Non-ASCII character seen before =encoding in 'Ünalan,'. Assuming CP1252