vals = [float(i) for i in prob_line[len(parents):]]
offset = sum((len(parents)-i)*self.variable_states[parents[i]].index(states[i])
for i in range(len(states)))
for i, val in enumerate(vals):
arr[i][offset] = val
arr = numpy.array(arr)
variable_cpds[var_name] = arr
return variable_cpds
After Change
for prob_line in cpds:
states = prob_line[:len(parents)]
vals = [float(i) for i in prob_line[len(parents):]]
values_dict[tuple(states)] = vals
for index, combination in enumerate(product(*[self.variable_states[var] for var in parents])):
arr[:, index] = values_dict[combination]
variable_cpds[var_name] = arr
return variable_cpds