probabilistic_model.learning.jpt.jpt#
Classes#
Class that implements the JPT learning algorithm for probabilistic circuits. |
Module Contents#
- class probabilistic_model.learning.jpt.jpt.JPT(variables: Iterable[random_events.variable.Variable], targets: Iterable[random_events.variable.Variable] | None = None, features: Iterable[random_events.variable.Variable] | None = None, min_samples_leaf: int | float = 1, min_impurity_improvement: float = 0.0, max_leaves: int | float = float('inf'), max_depth: int | float = float('inf'), dependencies: random_events.product_algebra.VariableMap | None = None)#
Bases:
random_events.utils.SubclassJSONSerializerClass that implements the JPT learning algorithm for probabilistic circuits.
- targets: Tuple[random_events.variable.Variable, Ellipsis]#
The variables to optimize for.
- features: Tuple[random_events.variable.Variable, Ellipsis]#
The variables that are used to craft criteria.
- _min_samples_leaf: int | float#
The minimum number of samples to create another sum node. If this is smaller than one, it will be reinterpreted as fraction w. r. t. the number of samples total.
- min_impurity_improvement: float#
The minimum impurity improvement to create another sum node.
- max_leaves: int | float#
The maximum number of leaves.
- max_depth: int | float#
The maximum depth of the tree.
- dependencies: random_events.product_algebra.VariableMap#
The dependencies between the variables.
- total_samples: int = 1#
The total amount of samples that were used to fit the model.
- indices: numpy.ndarray | None = None#
- impurity: jpt.learning.impurity.Impurity | None = None#
- c45queue: collections.deque#
- weights: List[float]#
- keep_sample_indices: bool = False#
Rather to store the sample indices in the leaves or not.
- variables: Tuple[random_events.variable.Variable, Ellipsis]#
The variables from initialization. Since variables will be overwritten as soon as the model is learned, we need to store the variables from initialization here.
- probabilistic_circuit: probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProbabilisticCircuit#
The probabilistic circuit the result will appear in.
- root: probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.SumUnit | None = None#
The root of the circuit that will be learned.
- set_targets_and_features(targets: Iterable[random_events.variable.Variable] | None, features: Iterable[random_events.variable.Variable] | None) None#
Set the targets and features of the model. If only one of them is provided, the other is set as the complement of the provided one. If none are provided, both of them are set as the variables of the model. If both are provided, they are taken as given.
- Parameters:
targets – The targets of the model.
features – The features of the model.
- Returns:
None
- property min_samples_leaf#
The minimum number of samples to create another sum node.
- property numeric_variables#
- property numeric_targets#
- property numeric_features#
- property symbolic_variables#
- property symbolic_targets#
- property symbolic_features#
- preprocess_data(data: pandas.DataFrame) numpy.ndarray#
Preprocess the data to be used in the model.
- Parameters:
data – The data to preprocess.
- Returns:
The preprocessed data.
- fit(data: pandas.DataFrame) probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProbabilisticCircuit#
Fit the model to the data.
- Parameters:
data – The data to fit the model to.
- Returns:
The fitted model.
- c45(data: numpy.ndarray, start: int, end: int, depth: int)#
Construct a DecisionNode or DecomposableProductNode from the data.
- Parameters:
data – The data to calculate the impurity from.
start – Starting index in the data.
end – Ending index in the data.
depth – The current depth of the induction
- Returns:
The constructed decision tree node
- create_leaf_node(data: numpy.ndarray) probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProductUnit#
Create a fully decomposable product node from a 2D data array.
- Parameters:
data – The preprocessed data to use for training
- Returns:
The leaf node.
- construct_impurity() jpt.learning.impurity.Impurity#
- _variable_dependencies_to_json() Dict[str, List[str]]#
Convert the variable dependencies to a json compatible format. The result maps variable names to lists of variable names.
- empty_copy()#
- to_json() Dict[str, Any]#
- classmethod _from_json(data: Dict[str, Any]) typing_extensions.Self#
Create a variable from a json dict. This method is called from the from_json method after the correct subclass is determined and should be overwritten by the respective subclass.
- Parameters:
data – The json dict
- Returns:
The deserialized object
- __eq__(other: typing_extensions.Self)#