Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why Bayesian network requires non-negative data #1111

Open
xiuwenibm opened this issue Jul 24, 2024 · 2 comments
Open

Why Bayesian network requires non-negative data #1111

xiuwenibm opened this issue Jul 24, 2024 · 2 comments

Comments

@xiuwenibm
Copy link

I created a BayesianNetwork and fit the data:

model = BayesianNetwork(algorithm="chow-liu", max_parents=max_parents)
model.fit(data)

In fit method, it calls _learn_structure method, however, in _learn_structure, it does the parameter check:
X = _check_parameter(_cast_as_tensor(X), "X", min_value=0, ndim=2, dtypes=(torch.int32, torch.int64))

The min_value = 0, so if there is a negtive value in my dataset, the check will raise an error.
But BayesianNetwork should work for negative values too.

@jmschrei
Copy link
Owner

Currently, the implemented Bayesian networks have to be categorical. This means that the data have to correspond to integer categories ranging from 0 to n-1 (inclusive) when there are n categories, and so are non-negative.

@xiuwenibm
Copy link
Author

Got it! Thanks! So for continuous values, I just need to bin them and then apply Bayesian networks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants