NAME

Algorithm::Classifier::IsolationForest::App::Command::explain - Explains which features drove each sample's anomaly score using the specified model

DESCRIPTION

Runs explain_samples over the input and prints one line per (row, feature) pair, most responsible feature first. Input may be a CSV or a .iforest-packed binary from iforest pack, detected by its magic bytes.

Under the default ablation method the line format is

$row,$score,$rank,$feature,$weight,$value,$delta,$baseline

and under --method path

$row,$score,$rank,$feature,$weight,$value

$row is the 1-based input row number, so output filtered by -t still points back at the input. Ablation scores n_features + 1 variants of every explained row, which is why -t is worth reaching for on a large input: it spends that only on the rows that cleared the cutoff.

Run it as iforest explain; iforest help explain lists every option.

METHODS

App::Cmd calls these while dispatching the subcommand. Nothing else should.

opt_spec

Returns this command's option specifications, as the list of arrayrefs Getopt::Long::Descriptive expects.

abstract

Returns the one-line summary iforest commands prints beside the command name.

description

Returns the long help text iforest help explain prints under the option list.

validate

Checks the parsed options before anything is read or written, so a mistake costs nothing.

Checks that -i and -m name readable files, that -o may be written, that --method is ablation or path, that -n is not negative, and that -t lies in (0, 1).

Takes the parsed options hashref and the arrayref of remaining arguments. Calls usage_error, which prints the usage and exits, on the first problem it finds, and returns 1 when everything checks out.

execute

Loads the model, reads the input, optionally filters by -t, and prints the per-feature lines to STDOUT or to -o.

Takes the parsed options hashref and the arrayref of remaining arguments, and returns 1.