|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
Contiguous-block representation of grouped observations. More...
#include <GroupPartition.hpp>
Public Member Functions | |
| GroupPartition (types::ResponseVector const &y) | |
| Construct from a sorted response vector. | |
| types::FeatureMatrix | bgss (types::FeatureMatrix const &x) const |
| Between-group sum of squares matrix (p × p). | |
| GroupPartition | collapse () const |
| Collapse all groups into a single supergroup. | |
| auto | data (types::FeatureMatrix const &x) const |
| Extract all rows across all groups. | |
| auto | group (types::FeatureMatrix const &x, Group const &group) const |
| Extract rows belonging to a group (or supergroup). | |
| int | group_end (Group const &group) const |
Last row index (inclusive) of the block for group. | |
| int | group_size (Group const &group) const |
Number of observations in group. | |
| int | group_start (Group const &group) const |
First row index of the block for group. | |
| types::FeatureVector | mean (types::FeatureMatrix const &x) const |
| Overall mean of all grouped rows (p). | |
| GroupPartition | remap (GroupMap const &mapping) const |
| Merge groups according to a mapping. | |
| GroupPartition | subset (GroupSet groups) const |
| Create a partition containing only the given groups. | |
| types::FeatureMatrix | wgss (types::FeatureMatrix const &x) const |
| Within-group sum of squares matrix (p × p). | |
Static Public Member Functions | |
| static bool | is_contiguous (GroupVector const &y) |
Check whether all equal values in y form a single contiguous block. | |
Public Attributes | |
| GroupSet const | groups |
| Set of all group labels in this partition. | |
| GroupInvMap const | subgroups |
| Maps each group to its set of subgroups. | |
| GroupMap const | supergroups |
| Maps each group to its supergroup (identity if no merge). | |
Contiguous-block representation of grouped observations.
Assumes the response vector is sorted so that observations of the same group are contiguous. Stores the start/end row indices of each group block and provides efficient extraction, subsetting, and computation of between- and within-group statistics.
Groups can be hierarchically merged via remap(), which assigns supergroup labels while tracking the original subgroups.
| ppforest2::stats::GroupPartition::GroupPartition | ( | types::ResponseVector const & | y | ) |
Construct from a sorted response vector.
| y | Response vector (n) with contiguous group blocks. |
| types::FeatureMatrix ppforest2::stats::GroupPartition::bgss | ( | types::FeatureMatrix const & | x | ) | const |
Between-group sum of squares matrix (p × p).
| GroupPartition ppforest2::stats::GroupPartition::collapse | ( | ) | const |
Collapse all groups into a single supergroup.
|
inline |
Extract all rows across all groups.
| x | Feature matrix (n × p). |
|
inline |
Extract rows belonging to a group (or supergroup).
| x | Feature matrix (n × p). |
| group | Group label. |
group. | int ppforest2::stats::GroupPartition::group_end | ( | Group const & | group | ) | const |
Last row index (inclusive) of the block for group.
| int ppforest2::stats::GroupPartition::group_size | ( | Group const & | group | ) | const |
Number of observations in group.
| int ppforest2::stats::GroupPartition::group_start | ( | Group const & | group | ) | const |
First row index of the block for group.
|
static |
Check whether all equal values in y form a single contiguous block.
| types::FeatureVector ppforest2::stats::GroupPartition::mean | ( | types::FeatureMatrix const & | x | ) | const |
Overall mean of all grouped rows (p).
| GroupPartition ppforest2::stats::GroupPartition::remap | ( | GroupMap const & | mapping | ) | const |
Merge groups according to a mapping.
| mapping | Maps original group labels to supergroup labels. |
| GroupPartition ppforest2::stats::GroupPartition::subset | ( | GroupSet | groups | ) | const |
Create a partition containing only the given groups.
| groups | Set of group labels to keep. |
groups. | types::FeatureMatrix ppforest2::stats::GroupPartition::wgss | ( | types::FeatureMatrix const & | x | ) | const |
Within-group sum of squares matrix (p × p).
| GroupSet const ppforest2::stats::GroupPartition::groups |
Set of all group labels in this partition.
| GroupInvMap const ppforest2::stats::GroupPartition::subgroups |
Maps each group to its set of subgroups.
| GroupMap const ppforest2::stats::GroupPartition::supergroups |
Maps each group to its supergroup (identity if no merge).