PLearn 0.1
Public Member Functions | Static Protected Attributes
PLearn::PairwiseDiffsCommand Class Reference

This command computes a set of statistics (user-specified) on the pairwise differences between a given column of a list of matrices. More...

#include <PairwiseDiffsCommand.h>

Inheritance diagram for PLearn::PairwiseDiffsCommand:
Inheritance graph
[legend]
Collaboration diagram for PLearn::PairwiseDiffsCommand:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PairwiseDiffsCommand ()
virtual void run (const std::vector< std::string > &args)
 The actual implementation of the 'PairwiseDiffsCommand' command.

Static Protected Attributes

static PLearnCommandRegistry reg_
 This allows to register the 'PairwiseDiffsCommand' command in the command registry.

Detailed Description

This command computes a set of statistics (user-specified) on the pairwise differences between a given column of a list of matrices.

The typical usage is to give a list of test cost matrices (e.g. such as the 'test_costs.pmat' files generated by PTester), and specify the cost of interest (column name) in the matrix. For all of the matrices taken pairwise, the command will accumulate the DIFFERENCE of the specified columns in a stats collector, and then will output a set of user-specified statistics. The default statistics are 'E' and 'PZ2t' (see the supported statistics in StatsCollector), meaning that the mean difference is computed, and the p-value that this difference is zero.

Definition at line 64 of file PairwiseDiffsCommand.h.


Constructor & Destructor Documentation

PLearn::PairwiseDiffsCommand::PairwiseDiffsCommand ( )

Definition at line 64 of file PairwiseDiffsCommand.cc.

                                          :
    PLearnCommand(
        "pairdiff",
        "Compute a set of statistics on the pairwise differences between cost matrices",
        " usage: pairdiff [--stats=E,PZ2t,...] costname costfile1.pmat costfile2.pmat ...\n"
        "\n"
        "This command computes a set of statistics (user-specified) on the\n"
        "pairwise differences between a given column of a list of matrices.  The\n"
        "typical usage is to give a list of test cost matrices (e.g. such as the\n"
        "'test_costs.pmat' files generated by PTester), and specify the cost of\n"
        "interest (column name) in the matrix.  For all of the matrices taken\n"
        "pairwise, the command will accumulate the DIFFERENCE of the specified\n"
        "columns in a stats collector, and then will output a set of\n"
        "user-specified statistics.  The default statistics are 'E' and 'PZ2t'\n"
        "(see the supported statistics in StatsCollector), meaning that the mean\n"
        "difference is computed, and the p-value that this difference is zero."
        )
{ }

Member Function Documentation

void PLearn::PairwiseDiffsCommand::run ( const std::vector< std::string > &  args) [virtual]

The actual implementation of the 'PairwiseDiffsCommand' command.

Implements PLearn::PLearnCommand.

Definition at line 114 of file PairwiseDiffsCommand.cc.

References PLearn::accumInStatsCol(), PLearn::endl(), i, j, PLearn::left(), m, PLearn::max(), n, PLearn::right(), PLearn::split(), and PLearn::tostring().

{
    if (origargs.size() < 3)
        return;

    // Default arguments
    vector<string> stats;
    stats.push_back("E");
    stats.push_back("PZ2t");

    // Parse arguments
    deque<string> args(origargs.begin(), origargs.end());
    while (args[0].substr(0,2) == "--") {
        if (args[0].substr(0,8) == "--stats=") {
            string commastats = args[0].substr(8);
            stats = split(commastats,',');
        }
        args.pop_front();
    }

    string costname = args.front();
    args.pop_front();

    // Find maximum-length filename
    int maxlen = 0;
    for (int i=0, n=int(args.size()) ; i<n ; ++i)
        maxlen = max(maxlen, int(args[i].size()));

    // Print out heading row
    const int width = 15;
    cout.setf(ios_base::left);
    cout << setw(maxlen) << "Filename1" << ' '
         << setw(maxlen) << "Filename2" << ' ';
    cout.setf(ios_base::right);
    for (int i=0, n=int(stats.size()) ; i<n ; ++i)
        cout << setw(width) << stats[i] << ' ';
    cout << endl;
    cout.setf(ios_base::left);
  
    // What we have in args is a list of filenames.  Go over them.
    for (int i=0, n=int(args.size()) ; i < n-1 ; ++i) {
        for (int j=i+1 ; j < n ; ++j) {
            PP<StatsCollector> sc = accumInStatsCol(costname, args[i], args[j]);

            // Print out result
            cout << setw(maxlen) << args[i] << ' '
                 << setw(maxlen) << args[j] << ' ';
            for (int k=0, m=int(stats.size()) ; k<m ; ++k) {
                real stat = sc->getStat(stats[k]);
                cout << format("%+"+tostring(width)+".7f ") % stat;
            }
            cout << endl;
        }
    }
}

Here is the call graph for this function:


Member Data Documentation

This allows to register the 'PairwiseDiffsCommand' command in the command registry.

Definition at line 71 of file PairwiseDiffsCommand.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines