if not set(factor.variables.keys()).issubset(set(self.variables)):
raise ValueError("Factors are not consistent with the model")
for index in range(len(factor.variables)):
self.cardinality[list(factor.variables.keys())[index]] = factor.cardinality[index]
for var in factor.variables:
After Change
self.cardinality = {}
self.factors = defaultdict(list)
model.check_model()
if isinstance(model, BayesianModel):
for node in model.nodes():
cpd = model.get_cpds(node)