Remove unnecessary double underscores in gcm module

Signed-off-by: Patrick Bloebaum <bloebp@amazon.com>
This commit is contained in:
Patrick Bloebaum 2022-10-31 17:33:07 -07:00 коммит произвёл Patrick Blöbaum
Родитель c988220819
Коммит f749ceebb7
2 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -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"