Branch Coverage

blib/lib/Algorithm/Classifier/IsolationForest.pm
Criterion Covered Total %
branch 277 336 82.4


line true false branch
2179 1 189 unless $mode eq "axis" or $mode eq "extended"
2192 1 188 unless $missing =~ /\A(?:die|zero|impute|nan)\z/
2196 1 187 unless $impute_with =~ /\A(?:mean|median)\z/
2208 1 186 unless $voting =~ /\A(?:mean|majority)\z/
2211 154 32 if (defined $args{'seed'})
2223 62 57 $args{'use_c'} && $HAS_C ? :
119 67 defined $args{'use_c'} ? :
2227 2 3 $args{'use_openmp'} && $HAS_OPENMP ? :
5 181 defined $args{'use_openmp'} ? :
2229 59 127 unless $use_c
2234 9 177 $args{'use_openmp_fit'} && $HAS_OPENMP && $use_c ? :
2259 1 185 unless $self->{'n_trees'} >= 1
2260 1 184 unless $self->{'sample_size'} >= 1
2262 1 183 if defined $self->{'extension_level'} and $self->{'extension_level'} < 0
2265 3 180 if defined $self->{'contamination'} and not $self->{'contamination'} > 0 && $self->{'contamination'} <= 0.5
2268 2 9 if defined $self->{'parallel_fit'} and !($self->{'parallel_fit'} =~ /^\d+$/) || $self->{'parallel_fit'} < 1
2311 1 8 unless defined $voting and $voting =~ /\A(?:mean|majority)\z/
2314 1 7 if $self->{'voting'} eq $voting
2323 4 3 if ($recalibrate)
2324 1 3 unless ref $data eq "ARRAY" and @$data
2331 3 3 if $recalibrate
2405 6 153 unless ref $data eq "ARRAY" and @$data
2408 4 149 unless ref $data->[0] eq "ARRAY" and @{$data->[0];}
2428 32 111 if ($self->{'mode'} eq 'extended') { }
2433 4 28 defined $self->{'extension_level'} ? :
2434 0 32 if $ext < 0
2435 2 30 if $ext > $max_ext
2446 0 143 defined $self->{'max_depth'} ? :
2447 0 143 if $limit < 1
2450 143 0 if defined $self->{'seed'}
2453 8 135 if (defined $workers and $workers > 1 and $self->{'n_trees'} > 1 and _fork_supported()) { }
7 128 elsif ($self->{'_use_c'} and $self->{'_use_openmp_fit'}) { }
79 49 elsif ($self->{'_use_c'}) { }
2495 10 133 if defined $self->{'contamination'}
2497 94 49 if $self->{'_use_c'}
2548 6817 0 if ($self->{'_use_c'} and $self->{'_c_nodes'})
2562 0 1 $self->{'missing'} eq 'nan' ? :
2605 8 41 defined $self->{'threshold'} ? :
14181 49 defined $threshold ? :
2612 18 14210 if ($self->{'voting'} eq "majority")
2618 16 0 if ($self->{'_use_c'} and $self->{'_c_nodes'})
2629 0 2 $self->{'missing'} eq 'nan' ? :
2635 1003 2394 if (_path_length($x, $trees->[$ti], 0, $nan) <= $cut)
2637 9 994 if ($votes >= $maj)
2639 117 3271 if $votes + ($t - 1 - $ti) < $maj
2651 14193 3 if ($self->{'_use_c'} and $self->{'_c_nodes'} and $self->{'c_psi'} > 0 and $threshold > 0 and $threshold < 1)
2675 414 871 $_ >= $threshold ? :
2728 5 48 unless ref $row eq "HASH"
2733 0 44 unless defined $self->{'feature_names'} and ref $self->{'feature_names'} eq "ARRAY" and @{$self->{'feature_names'};}
2741 4 40 if @unknown
2745 4 36 if @missing
2797 9 15784 if ($self->{'voting'} eq "majority")
2798 0 9 defined $self->{'threshold'} ? :
2801 7 0 if ($self->{'_use_c'} and $self->{'_c_nodes'})
2822 15723 6 if ($self->{'_use_c'} and $self->{'_c_nodes'})
2830 15722 0 if ($c > 0)
2840 3 58 $self->{'missing'} eq 'nan' ? :
2853 61 0 if ($c > 0)
2912 2 17 defined $self->{'threshold'} ? :
5328 19 defined $threshold ? :
2918 3 5344 if ($self->{'voting'} eq "majority")
2924 3 0 if ($self->{'_use_c'} and $self->{'_c_nodes'})
2935 0 0 $_ >= $maj ? :
2939 0 0 $_ >= $maj ? :
2946 5342 0 if ($self->{'_use_c'} and $self->{'_c_nodes'} and $self->{'c_psi'} > 0 and $threshold > 0 and $threshold < 1)
2974 4 8 if ($score >= $threshold) { }
3036 0 10 defined $self->{'threshold'} ? :
13652 10 defined $threshold ? :
3041 6 13656 if ($self->{'voting'} eq "majority")
3047 4 0 if ($self->{'_use_c'} and $self->{'_c_nodes'})
3065 9 117 $_ >= $maj ? :
3072 13654 0 if ($self->{'_use_c'} and $self->{'_c_nodes'} and $self->{'c_psi'} > 0 and $threshold > 0 and $threshold < 1)
3098 4 8 $_ >= $threshold ? :
3156 1 31 unless ref $payload eq "HASH" and defined $payload->{'format'} and $payload->{'format'} eq "Algorithm::Classifier::IsolationForest"
3163 1 30 if (($payload->{'version'} // 0) < 1)
3195 1 30 unless @{$self->{'trees'};}
3200 30 0 if defined $self->{'psi_used'}
3203 30 0 if $self->{'_use_c'}
3266 277710 413657 if $n <= 1
3267 68154 345503 if $n == 2
3291 0 0 $theta <= 0.5 ? :
0 36 if $c <= 0
3292 0 36 if $theta <= 0
3321 0 13 if $k >= $n
3324 13 0 if $desc->[$k] < $v
3332 0 0 if ($i > 0 and $k - $i < $j - $k)
3337 0 0 $j < $n ? :
3349 0 4 $self->{'missing'} eq 'nan' ? :
3353 2854 7226 if _path_length($data->[$i], $tree, 0, $nan) <= $cut
3390 6 7 $self->{'voting'} eq 'majority' ? :
3396 0 13 if $k < 1
3397 0 13 if $k > $n_pts
3409 0 6 $self->{'missing'} eq 'nan' ? :
3413 0 6 unless $c > 0
3472 145963 149304 if $depth >= $limit or $size <= 1
3485 23338 125966 if ($nan) { }
3489 72249 698528 unless defined $v
3490 87444 611084 if not defined $lo[$f] or $v < $lo[$f]
3491 86526 612002 if not defined $hi[$f] or $v > $hi[$f]
3498 615137 6443277 if not defined $lo[$f] or $v < $lo[$f]
3499 612680 6445734 if not defined $hi[$f] or $v > $hi[$f]
3507 333681 55 if defined $lo[$_]
3510 2795 146509 unless @varying
3513 22782 123727 $self->{'mode'} eq 'extended' ? :
3521 123727 22782 $node->[0] == 1 ? :
3551 15096 108631 if ($nan) { }
3554 111298 128069 if (defined $v and $v < $split) { }
3559 1096061 1099946 if ($row->[$attr] < $split) { }
3576 3606 19176 if $active > scalar @$varying
3611 6947 15835 if ($nan) { }
3617 26240 236042 unless (defined $v)
3620 57761 81925 if (not $missing and $dot <= $b) { }
3627 197051 203302 if ($dot <= $b) { }
3654 2650147 229682 if ($node->[0] == 1) { }
3655 4852 2645295 if ($nan) { }
3657 963 3889 defined $v && $v < $node->[2] ? :
3659 1324900 1320395 ($$x[$node->[1]] // 0) < $node->[2] ? :
3663 3034 226648 if ($nan) { }
3668 1920 2807 unless (defined $v)
3671 552 2482 !$missing && $dot <= $b ? :
3675 111563 115085 $dot <= $b ? :
3687 0 0 if ($node->{'leaf'}) { }
0 0 elsif (exists $node->{'attr'}) { }
3731 281721 275669 if ($node->[0] == 0) { }
245960 29709 elsif ($node->[0] == 1) { }
3762 25903 3806 if (defined $n_features and $num == $n_features) { }
3785 795 5257 @coef_idx ? :
3786 795 5257 @coef_val ? :
3811 9 55876 unless ref $self->{'trees'} eq "ARRAY" and @{$self->{'trees'};}
3820 6 2 if defined $cached
3823 2 0 ($Config::Config{'d_fork'} || '') eq 'define' ? :
3846 1 7 if $workers > $n_trees
3854 3 23 $w < $extras ? :
3861 0 26 unless $share > 0
3863 0 26 unless pipe my $rh, my $wh
3865 0 26 unless defined $pid
3867 0 26 if ($pid == 0)
3871 0 0 if (defined $self->{'seed'})
3888 0 0 if ($self->{'_use_c'}) { }
3921 0 26 if $exit != 0
3924 0 26 if $@ or ref $trees ne "ARRAY"
3950 14 65 $self->{'mode'} eq 'extended' ? :
3991 5 2 $self->{'mode'} eq 'extended' ? :
4015 6582 6262 if ($type == 0) { }
1604 4658 elsif ($type == 1) { }
4071 1 5 unless $self->{'_use_c'}
4072 2 3 unless ref $data eq "ARRAY"
4092 24189 31570 if (ref $data eq "Algorithm::Classifier::IsolationForest::PackedData")
4094 1 24188 unless $data->{'n_feats'} == $self->{'n_features'}
4111 95 0 if ref $data eq "ARRAY"
4112 0 0 if (ref $data eq "Algorithm::Classifier::IsolationForest::PackedData")
4150 123 26 if ($m eq "die")
4154 45878 2 if defined $row->[$f]
4164 8 18 if $m eq "nan"
4184 12 6 $m eq 'impute' ? :
4188 8 6 if $m eq "impute"
4191 7 7 if $self->{'_use_c'}
4207 6 6 if ($self->{'_use_c'})
4209 2 4 $how eq 'median' ? :
4218 2 10 unless @vals
4220 4 6 if ($how eq 'median') { }
4223 2 2 $k % 2 ? :
4255 3855 223 if (defined $r->[$_]) { }
4266 9 31650 if $m eq "nan"
4267 9 31641 if ($m eq "impute")
4270 0 9 unless ref $fill eq "ARRAY" and @$fill == $self->{'n_features'}
4284 3 71 if ($self->{'missing'} eq "impute")
4286 0 3 unless ref $self->{'missing_fill'} eq "ARRAY"