Algorithm-DecisionTree

 view release on metacpan or  search on metacpan

Examples/README  view on Meta::CPAN

    and the second, `training3.csv' was generated by the same script 
    using the parameter file

           param_numeric_extremely_overlapping_classes.txt


(3) So far we have talked about classifying one test data record at a time.
    You can place multiple test data records in a disk file and classify
    them all in one go.  To see how that can be done, execute the following
    two command lines in the `examples' directory:

     classify_test_data_in_a_file.pl   training4.csv   test4.csv   out4.csv

    This script constructs the decision tree from the data in the first
    argument file and then uses it to classify the data in the second
    argument file.  The computed class labels are deposited in the third
    argument file.

    In general, the test data files should look identical to the training
    data files.  Of course, for real-world test data, you will not have the
    class labels for the test samples.  You are still required to reserve a
    column for the class label, which now must be just the empty string ""
    for each data record.  For example, the test data supplied in the
    following two calls through the files test4_no_class_labels.csv and
    test4_no_class_labels.dat does not mention class labels:

 classify_test_data_in_a_file.pl training4.csv test4_no_class_labels.csv out4.csv



(4) Let's now talk about how you can deal with features that, statistically
    speaking, are not so "nice".  We are talking about features with
    heavy-tailed distributions over large value ranges.  As mentioned in
    the HTML based API for this module, such features can create problems
    with the estimation of the probability distributions associated with
    them.  As mentioned there, the main problem that such features cause
    is with deciding how best to sample the value range.

    Beginning with Version 2.22, you have two options in dealing with such
    features.  You can choose to go with the default behavior of the
    module, which is to sample the value range for such a feature over a
    maximum of 500 points.  Or, you can supply an additional option to the
    constructor that sets a user-defined value for the number of points to
    use.  The name of the option is "number_of_histogram_bins".  The
    following script

          construct_dt_for_heavytailed.pl

    shows an example of a DecisionTree constructor with the
    "number_of_histogram_bins" option.


===========================================================================


          FOR USING A DECISION TREE CLASSIFIER INTERACTIVELY


Starting with Version 1.6 of the module, you can use the DecisionTree
classifier in an interactive mode.  In this mode, after you have
constructed the decision tree, the user is prompted for answers to the
questions regarding the feature tests at the nodes of the tree.  Depending
on the answer supplied by the user at a node, the classifier takes a path
corresponding to the answer to descend down the tree to the next node, and
so on.  To get a feel for using a decision tree in this mode, examine the
script

        classify_by_asking_questions.pl

Execute the script as it is and see what happens.


===========================================================================


     EVALUATING THE CLASS DISCRIMINATORY POWER OF YOUR TRAINING DATA


Given a training data file that contains data records and the associated
class labels, one often wants to know the quality of the data in the file.
In other words, one wants to know if a training data file contains
sufficient information to discriminate between the different classes
mentioned in the file.

Starting with Version 2.2 of the DecisionTree module, you can now run a
10-fold cross-validation test on your training data to find out how much
class-discriminatory information is contained in the data.  The following
two scripts in the Examples directory:

       evaluate_training_data1.pl

       evaluate_training_data2.pl

As these scripts show, the following class 

       EvalTrainingData

defined in the main DecisionTree module file makes it straightforward to
evaluate the class discriminatory power your data (as long as it resides in
a `.csv' file.)  This new class is is a subclass of the DecisionTree class
in the module file.

Both the `evaluate' scripts mentioned above are identical in terms of the
usage logic shown.  The first is specifically for the training data file
`stage3cancer.csv' and second for the training data files `training.csv',
`training2.csv', and `training3.csv'.  The latter three data files contain
two Gaussian classes that are increasingly overlapping.  You can see for
yourself the decreasing quality of the training data as you evaluate first
the training file `training.csv', then the training file `training2.csv',
and finally the training file `training3.csv'.


===========================================================================

                  USING THE DT INTROSPECTION CLASS


Starting with Version 2.3, you can ask the DTIntrospection class of the
module to explain the classification decisions made at the different nodes
of the decision tree.  An instance of this class can also show as to which
nodes of the tree are directly affected by a given training sample. A node



( run in 0.482 second using v1.01-cache-2.11-cpan-6aa56a78535 )