NAME
Algorithm::Classifier::IsolationForest::App::Command::pack - Pre-pack a CSV dataset into a binary file the scoring commands can read directly
DESCRIPTION
Converts a CSV into the .iforest-packed binary format, so repeated scoring runs over the same dataset skip the CSV parse and the input-packing step. iforest predict and iforest explain detect the format by its magic bytes and take it wherever they take a CSV.
The file holds only the packed doubles and their dimensions -- no model is embedded, so it is on the caller to pair it with a model of the same feature width.
Run it as iforest pack; iforest help pack 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 pack 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 -o were given, that -i is readable, and that -m names a readable model.
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
Reads the CSV, packs it through the model, and writes the binary to -o.
Takes the parsed options hashref and the arrayref of remaining arguments, and returns 1.
read_packed_file
Reads a .iforest-packed file, so the scoring commands all parse the format the same way.
Takes the path and returns the three-element list of the row count, the feature width, and the raw row-major double buffer. It dies naming the path on a bad magic number, an unsupported version, or a truncated file.
my ( $n_pts, $n_feats, $bytes ) = $class->read_packed_file($path);
is_packed_file
Cheap check for whether a path holds a .iforest-packed file, so a command can tell a packed input from a CSV without slurping either.
Takes the path and returns true when the first eight bytes are the format's magic number. A missing or unreadable path is simply false, so this never dies and needs no -f test first.
if ( is_packed_file($input) ) { ... }