|
ppforest2 v0.1.3
Projection Pursuit Decision Trees and Random Forests
|
Classes | |
| struct | FeatureSet |
| Result of parsing a feature-only CSV (no response column). More... | |
Functions | |
| stats::DataPacket | read (std::string const &filename) |
| Read a CSV file into a DataPacket. | |
| stats::DataPacket | read (std::string const &filename, types::Mode mode) |
| Read a CSV file, parsing the response column in a known mode. | |
| FeatureSet | read_features_from_string (std::string const &content) |
| Parse a feature-only CSV from an in-memory string. | |
| stats::DataPacket | read_sorted (std::string const &filename) |
| Read a CSV file and sort rows ascending by the response column. | |
| stats::DataPacket | read_sorted (std::string const &filename, types::Mode mode) |
| Read a CSV file sorted by response, parsing the response in a known mode. | |
| types::OutcomeVector | remap_labels (stats::DataPacket const &data, types::Names const &target_groups) |
Re-encode data.y label codes into a target label space. | |
| void | write (stats::DataPacket const &data, std::string const &filename) |
| Write a DataPacket to a CSV file (features followed by label, no header). | |
| stats::DataPacket ppforest2::io::csv::read | ( | std::string const & | filename | ) |
Read a CSV file into a DataPacket.
Assumes the last column is the response variable (group label as string) and all preceding columns are features. Categorical feature columns are automatically detected and integer-encoded. String labels are mapped to contiguous integer codes starting at 0.
| filename | Path to the CSV file. |
| UserError | on any failure: missing file, empty file, rows whose column count differs from the header, or a column mixing numeric and non-numeric cells (stray "NA", empty, or non-finite values). |
| stats::DataPacket ppforest2::io::csv::read | ( | std::string const & | filename, |
| types::Mode | mode ) |
Read a CSV file, parsing the response column in a known mode.
Same as read, but skips the written-form mode detection: mode states how to parse the response column. Classification maps labels to integer codes in first-appearance order (populating group_names); regression parses a continuous float response and rejects non-numeric values. Rows keep their file order — use this when predictions must line up with the input rows (e.g. predict), with the mode taken from the model.
| UserError | on any failure (missing file, parse error, malformed shape, non-numeric regression response). |
| FeatureSet ppforest2::io::csv::read_features_from_string | ( | std::string const & | content | ) |
Parse a feature-only CSV from an in-memory string.
The first row is the header (feature names); every subsequent row is one observation. There is no response column. Used by the serve subcommand to parse POST /predict request bodies — categorical encoding runs per-call, so callers must encode categoricals consistently with the training data.
| UserError | on empty body, missing header, no data rows, or malformed shape. |
| stats::DataPacket ppforest2::io::csv::read_sorted | ( | std::string const & | filename | ) |
Read a CSV file and sort rows ascending by the response column.
Mode is detected from the y column's written form:
., e, E), y is parsed as a continuous float response (regression shape) and group_names is empty.group_names carries the original label strings (classification shape). This keeps integer-coded label CSVs like Wine and Glass on the classification path.Rows are sorted ascending by the encoded y, which gives the training routines what they need: classification — contiguous groups; regression — y-ordered rows for ByCutpoint::init's median split.
| UserError | on any failure (missing file, parse error, malformed shape) — CSV reading failures are user-facing by nature. |
| stats::DataPacket ppforest2::io::csv::read_sorted | ( | std::string const & | filename, |
| types::Mode | mode ) |
Read a CSV file sorted by response, parsing the response in a known mode.
Same as the one-argument read_sorted, but skips the written-form mode detection: mode states how to parse the response column. Use this when the mode is already decided (e.g. train --mode regression) so that integer-written regression responses stay numeric instead of being label-encoded.
| UserError | on any failure, including a non-numeric response in regression mode. |
| types::OutcomeVector ppforest2::io::csv::remap_labels | ( | stats::DataPacket const & | data, |
| types::Names const & | target_groups ) |
Re-encode data.y label codes into a target label space.
data.y carries integer codes indexing data.group_names — the order labels first appeared in the file. Model predictions and metrics use the model's own label order (meta.groups), which can differ when a prediction file lists classes in a different order than the training file. Returns a copy of data.y re-encoded so that code i means target_groups[i].
| UserError | if the file contains a label that is not present in target_groups. |
| void ppforest2::io::csv::write | ( | stats::DataPacket const & | data, |
| std::string const & | filename ) |
Write a DataPacket to a CSV file (features followed by label, no header).
| data | The DataPacket to write. |
| filename | Output file path. |