BaseEstimator.state_counts() erroneously reports zero for nodes with a single parent
Closed this issue · 1 comments
mellesies commented
When computing state counts for nodes with a single parent, the function BaseEstimator.state_counts() erroneously reports zero:
import pandas as pd
from pgmpy.models import BayesianModel
from pgmpy.estimators import BaseEstimator, ParameterEstimator
# Generate the data
data = pd.DataFrame(data={'fruit': ["banana", "apple", "banana", "apple", "banana","apple", "banana",
"apple", "apple", "apple", "banana", "banana", "apple", "banana",],
'tasty': ["yes", "no", "yes", "yes", "yes", "yes", "yes",
"yes", "yes", "yes", "yes", "no", "no", "no"],
'size': ["large", "large", "large", "small", "large", "large", "large",
"small", "large", "large", "large", "large", "small", "small"]})
be = BaseEstimator(data)
print(be.state_counts('tasty', parents=['fruit'])) # conditional on fruitYields:
fruit apple banana
tasty
no 0.0 0.0
yes 0.0 0.0
Which should be:
fruit apple banana
tasty
no 2 2
yes 5 5
mellesies commented
Sorry .. mistakenly posted this issue to the wrong project.