Remove unnecessary double underscores in gcm module
Signed-off-by: Patrick Bloebaum <bloebp@amazon.com>
This commit is contained in:
Родитель
c988220819
Коммит
f749ceebb7
|
@ -230,7 +230,7 @@ def distribution_change_of_graphs(
|
|||
validate_causal_dag(causal_model_old.graph)
|
||||
validate_causal_dag(causal_model_new.graph)
|
||||
|
||||
return __estimate_marginal_distribution_change(
|
||||
return _estimate_marginal_distribution_change(
|
||||
ProbabilisticCausalModel(node_connected_subgraph_view(causal_model_old.graph, target_node)),
|
||||
ProbabilisticCausalModel(node_connected_subgraph_view(causal_model_new.graph, target_node)),
|
||||
target_node,
|
||||
|
@ -274,7 +274,7 @@ def _fit_accounting_for_mechanism_change(
|
|||
return mechanism_changed_for_node
|
||||
|
||||
|
||||
def __estimate_marginal_distribution_change(
|
||||
def _estimate_marginal_distribution_change(
|
||||
causal_model_old: ProbabilisticCausalModel,
|
||||
causal_model_new: ProbabilisticCausalModel,
|
||||
target_node: Any,
|
||||
|
|
|
@ -205,16 +205,16 @@ class EmpiricalDistribution(StochasticModel):
|
|||
|
||||
class BayesianGaussianMixtureDistribution(StochasticModel):
|
||||
def __init__(self) -> None:
|
||||
self.__gmm_model = None
|
||||
self._gmm_model = None
|
||||
|
||||
def fit(self, X: np.ndarray) -> None:
|
||||
X = shape_into_2d(X)
|
||||
self.__gmm_model = BayesianGaussianMixture(
|
||||
n_components=BayesianGaussianMixtureDistribution.__get_optimal_number_of_components(X), max_iter=1000
|
||||
self._gmm_model = BayesianGaussianMixture(
|
||||
n_components=BayesianGaussianMixtureDistribution._get_optimal_number_of_components(X), max_iter=1000
|
||||
).fit(X)
|
||||
|
||||
@staticmethod
|
||||
def __get_optimal_number_of_components(X: np.ndarray) -> int:
|
||||
def _get_optimal_number_of_components(X: np.ndarray) -> int:
|
||||
current_best = 0
|
||||
current_best_num_components = 1
|
||||
num_best_in_succession = 0
|
||||
|
@ -241,10 +241,10 @@ class BayesianGaussianMixtureDistribution(StochasticModel):
|
|||
return current_best_num_components
|
||||
|
||||
def draw_samples(self, num_samples: int) -> np.ndarray:
|
||||
if self.__gmm_model is None:
|
||||
if self._gmm_model is None:
|
||||
raise RuntimeError("%s has not been fitted!" % self.__class__.__name__)
|
||||
|
||||
return shape_into_2d(self.__gmm_model.sample(num_samples)[0])
|
||||
return shape_into_2d(self._gmm_model.sample(num_samples)[0])
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "Approximated data distribution"
|
||||
|
|
Загрузка…
Ссылка в новой задаче