Algorithm-DecisionTree
view release on metacpan or search on metacpan
lib/Algorithm/DecisionTree.pm view on Meta::CPAN
package Algorithm::DecisionTree;
#--------------------------------------------------------------------------------------
# Copyright (c) 2017 Avinash Kak. All rights reserved. This program is free
# software. You may modify and/or distribute it under the same terms as Perl itself.
# This copyright notice must remain attached to the file.
#
# Algorithm::DecisionTree is a Perl module for decision-tree based classification of
# multidimensional data.
# -------------------------------------------------------------------------------------
#use 5.10.0;
use strict;
use warnings;
use Carp;
our $VERSION = '3.43';
############################################ Constructor ##############################################
sub new {
my ($class, %args, $eval_or_boosting_mode);
if (@_ % 2 != 0) {
($class, %args) = @_;
} else {
$class = shift;
$eval_or_boosting_mode = shift;
die unless $eval_or_boosting_mode eq 'evalmode' || $eval_or_boosting_mode eq 'boostingmode';
die "Only one string arg allowed in eval and boosting modes" if @_;
}
unless ($eval_or_boosting_mode) {
my @params = keys %args;
croak "\nYou have used a wrong name for a keyword argument --- perhaps a misspelling\n"
if check_for_illegal_params2(@params) == 0;
}
bless {
_training_datafile => $args{training_datafile},
_entropy_threshold => $args{entropy_threshold} || 0.01,
_max_depth_desired => exists $args{max_depth_desired} ?
$args{max_depth_desired} : undef,
_debug1 => $args{debug1} || 0,
_debug2 => $args{debug2} || 0,
_debug3 => $args{debug3} || 0,
_csv_class_column_index => $args{csv_class_column_index} || undef,
_csv_columns_for_features => $args{csv_columns_for_features} || undef,
_symbolic_to_numeric_cardinality_threshold
=> $args{symbolic_to_numeric_cardinality_threshold} || 10,
_number_of_histogram_bins => $args{number_of_histogram_bins} || undef,
_csv_cleanup_needed => $args{csv_cleanup_needed} || 0,
_training_data => [],
_root_node => undef,
_probability_cache => {},
_entropy_cache => {},
_training_data_hash => {},
_features_and_values_hash => {},
_samples_class_label_hash => {},
_class_names => [],
_class_priors => [],
_class_priors_hash => {},
_feature_names => [],
_numeric_features_valuerange_hash => {},
_sampling_points_for_numeric_feature_hash => {},
_feature_values_how_many_uniques_hash => {},
_prob_distribution_numeric_features_hash => {},
_histogram_delta_hash => {},
_num_of_histogram_bins_hash => {},
}, $class;
( run in 0.626 second using v1.01-cache-2.11-cpan-df04353d9ac )