Exposed public API for RSL-w
learn_and_get_skeleton(ci_test, data, clique_num, find_markov_boundary_matrix_fun=None)
Learn the skeleton of a graph with a bounded clique number using the RSL-W algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ci_test
|
Callable[[int, int, List[int], ndarray], bool]
|
A conditional independence test function that takes in the indices of two variables and a list of variable indices as the conditioning set, and returns True if the two variables are independent given the conditioning set, and False otherwise. |
required |
data_matrix
|
ndarray
|
The data matrix with shape (num_samples, num_vars), where each column corresponds to a variable and each row corresponds to a sample. |
required |
clique_num
|
int
|
The clique number of the graph. |
required |
Returns:
Type | Description |
---|---|
Graph
|
nx.Graph: A networkx graph representing the learned skeleton. |
Source code in rcd/rsl/rsl_w.py
RSL-w implementation details
Bases: _RSLBase
Implementation for the RSL-W algorithm for learning graphs with a bounded clique number from i.i.d. samples.
This class is initialized with a conditional independence test function, which determines whether two variables are independent given another set of variables, using the data provided.
The class has a learn_and_get_skeleton function that takes in a data matrix (numpy array), where each column corresponds to a variable and each row corresponds to a sample, and returns a networkx graph representing the learned skeleton.
Source code in rcd/rsl/rsl_w.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
__init__(ci_test, find_markov_boundary_matrix_fun=None)
Initialize the RSL-W algorithm with the conditional independence test to use.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ci_test
|
Callable[[int, int, List[int], ndarray], bool]
|
A conditional independence test function that takes in the indices of two variables and a list of variable indices as the conditioning set, and returns True if the two variables are independent given the conditioning set, and False otherwise. |
required |
find_markov_boundary_matrix_fun
|
Callable[[ndarray], ndarray]
|
A function to find the Markov boundary matrix. This function should take in a numpy array of data, and return a 2D numpy array, where the (i, j)th entry is True if the jth variable is in the Markov boundary of the ith variable, and False otherwise. |
None
|
Source code in rcd/rsl/rsl_w.py
find_neighborhood(var)
Find the neighborhood of a variable using Proposition 37.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var
|
int
|
The variable whose neighborhood we want to find. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: 1D numpy array containing the variables in the neighborhood. |
Source code in rcd/rsl/rsl_w.py
is_removable(var)
Check whether a variable is removable using Theorem 36.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var
|
int
|
The variable to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the variable is removable, False otherwise. |