Skip to contents

Class to represent a group structure.

Public fields

feature_names

(character())
The names of the features of the mlr3::Task.

Active bindings

n_features

(integer(1))
Number of features part of the mlr3::Task.

n_selected

(integer(1))
Number of selected features based on the group structure.

selected_features

(character())
Names of the selected features.

unselected_features

(character())
Names of the unselected features.

n_groups

(integer(1))
Number of groups under the group structure. Determined based on the number of equivalence classes + 1 (due to the first group of unselected features also always being accounted for).

monotone_features

(data.table::data.table)
A data.table with as many rows as features with the feature column indicating the feature and the monotonicity column indicating the monotonicity constraint as an integer (NA indicating no constraint, e.g., for unselected features).

groups

(list())
A list containing a character vector of all features ($features), an integer vector of all equivalence classes ($eqcs) and an integer vector indicating the belonging of each feature to each class ($belonging).

monotone_eqcs

(data.table::data.table)
A data.table with as many rows as equivalence classes with the eqcs column indicating the equivalence class and the monotonicity column indicating the monotonicity constraint as an integer (NA indicating no constraint, e.g., for the group of unselected features).

allow_all_unselected

(logical(1))
Whether unselecting all features should be allowed i.e., having only a single group of unselected features is considered a valid group structure.

Methods


Method new()

Creates a new instance of this R6 class.

Usage

GroupStructure$new(
  task,
  n_selected = NULL,
  scores = NULL,
  interaction_detector = NULL,
  unconstrained_weight_table = NULL,
  unconstrained = FALSE
)

Arguments

task

([mlr3::Task)
Task.

n_selected

(integer(1))
Number of selected features.

scores

(data.table::data.table)
data.table with as many rows as features and two columns feature and score with feature being the id of the feature and score being the feature importance score.

interaction_detector

(InteractionDetector)
Interaction detector.

unconstrained_weight_table

(data.table::data.table)
data.table with as many rows as features and two columns feature_name and unconstrained_weight with feature_name being the id of the feature and unconstrained_weight being the score based on an MonotonicityDetector.

unconstrained

(logical(1))
Whether an unconstrained group structure should be created. This means that all features are selected and all features are allowed to interact and no features are constrained with respect to a monotone feature effect.


Method get_groups()

Method to get a more human readable representation of the group structure.

Usage

GroupStructure$get_groups()

Returns

A (list()) of character vectors with each character vector containing names of features that are in the same group.


Method get_matrix()

Method to get the pairwise interaction matrix of features.

Usage

GroupStructure$get_matrix()

Returns

A (matrix()) filled with integers indicating allowance of pairwise interaction of selected features.


Method create_selector()

Method to create a mlr3pipelines::Selector of selected features.

Usage

GroupStructure$create_selector()


Method create_interaction_constraints()

Method to create a list of interaction constraints of features.

Usage

GroupStructure$create_interaction_constraints()

Returns

(list()) of integer vectors of feature indices allowed to interact with each other.


Method create_monotonicity_constraints()

Method to create an integer vector of monotonicity constraints of selected features.

Usage

GroupStructure$create_monotonicity_constraints()

Returns

Named (integer()) vector of monotonicity constraints of selected features.


Method get_full_group_structure()

Method to create the full group structure based on the equivalence classes of features allowed to interact and the unselected features forming the first group.

Usage

GroupStructure$get_full_group_structure(eqcs, unselected_features)

Arguments

eqcs

(list())
List containing a (character()) vector of selected features, an (integer()) vector of equivalence classes ids and an (integer()) vector indicating the equivalence class each feature belongs to.

unselected_features

(character())
Character vector describing the set on unselected features

Returns

(list()) similarly as eqcs but updated so that the unselected features now resample the first group (equivalence class)


Method mutate()

Performs mutations on the group structure by creating a new group, destroying a group, shuffling membership, or mutating group membership.

Usage

GroupStructure$mutate(p)

Arguments

p

(numeric(1))
Numeric value between 0 and 1 specifying the mutation probability.

Returns

Invisible (NULL)


Method crossover()

Performs crossover between the groups of two GroupStructure objects. First parent is given by groups of the object itself (self$groups). Combines and exchanges groups between the parent objects based on the specified crossing sections.

Usage

GroupStructure$crossover(parent2, crossing_sections)

Arguments

parent2

(list(1))
A group of a GroupStructure object representing the second parent.

crossing_sections

(list(1))
A list containing the crossing sections for the first parent (crossing_section1) and second parent (crossing_section2). The crossing sections define the boundaries of groups to be exchanged between the parents. Each crossing section is an integer vector of length 2, indicating the start and end points of the crossing section.

Returns

Invisible (NULL)


Method get_crossing_sections()

Calculates and returns the crossing sections for performing crossover between the group structures of two groups of GroupStructure objects. The crossing sections define the boundaries of groups to be exchanged between the parents during crossover.

Usage

GroupStructure$get_crossing_sections(parent2)

Arguments

parent2

A $groups of a GroupStructure object representing the second parent.

Returns

A list() containing the crossing sections for the first parent (crossing_section1) and second parent (crossing_section2). Each crossing section is an integer vector of length 2, indicating the start and end points of the crossing section.


Method clone()

The objects of this class are cloneable with this method.

Usage

GroupStructure$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.