datagenerator.interacting_features
Attributes
Classes
A dataset subclass for modeling interactions between categorical and continuous features within weighted datasets. |
Module Contents
- class datagenerator.interacting_features.InteractingFeatureDataset(seed: int = 0, n_features: int = 4, n_samples: int = 50, weight_range: Tuple[float, float] = (-1.0, 1.0), weights: List[float] | None = None, zero_likelihood: float = 0.5, interacting_features: List[List[int]] = [[1, 0], [3, 2]], **kwargs: Any)
Bases:
xaiunits.datagenerator.WeightedFeaturesDatasetA dataset subclass for modeling interactions between categorical and continuous features within weighted datasets.
This class extends WeightedFeaturesDataset to support scenarios where the influence of one feature on the model is conditional on the value of another, typically categorical, feature. For instance, the model may include terms like w_i(x_j) * x_i + w_j * x_j, where the weight w_i(x_j) changes based on the value of x_j.
- Inherits from:
WeightedFeaturesDataset: Class extending BaseFeaturesDataset with support for weighted features
- interacting_features
Pairs of indices where the first index is the feature whose weight is influenced by the second, categorical feature.
- Type:
list[list[int]]
- zero_likelihood
The likelihood of the categorical feature being zero.
- Type:
float
- seed
Random seed for reproducibility.
- Type:
int
- n_features
Number of features in the dataset.
- Type:
int
- n_samples
Number of samples in the dataset.
- Type:
int
- weight_range
Min and max values for generating weights.
- Type:
tuple[float]
- weights
Initial weight values for features.
- Type:
list | NoneType
- subset_attribute
List of attributes that define the subset of the data with specific characteristics.
- Type:
list[str]
- interacting_features = [[1, 0], [3, 2]]
- zero_likelihood = 0.5
- subset_attribute
- cat_features
- make_cat() None
Modifies the dataset to incorporate the specified categorical-to-continuous feature interactions.
The method ensures that the dataset is correctly modified to reflect the specified feature interactions and their impact on weights and samples.
- _get_flat_weights(weights: List[float] | None) torch.Tensor | None
Convert the weights into a flat tensor.
This method takes a list of weights, which can be tuples representing ranges, and converts them into a flat tensor. If the input weights are None, the method returns None.
- Parameters:
weights (list | NoneType) – List of weights or None if weights are not specified.
- Returns:
Flat tensor of weights if weights are provided, else None.
- Return type:
torch.Tensor | NoneType
- generate_model() torch.nn.Module
Generates a neural network model for interacting features analysis.
This method instantiates and returns a neural network model specifically designed for analyzing datasets with interacting features. The model is configured using the specified number of features, feature weights, and interacting features information.
- Returns:
- An instance of the InteractingFeaturesNN class, representing
the neural network model designed for interacting features analysis.
- Return type:
- datagenerator.interacting_features.data