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

Conditional independence tests with mixed data #8

Open
kenneth-lee-ch opened this issue Aug 17, 2024 · 0 comments
Open

Conditional independence tests with mixed data #8

kenneth-lee-ch opened this issue Aug 17, 2024 · 0 comments

Comments

@kenneth-lee-ch
Copy link

kenneth-lee-ch commented Aug 17, 2024

Can someone show an example how to use this library to conduct conditional independence tests with mixed data? Suppose I have the following data. I am confused on how to use MutualInformation as it says it can take continuous and categorical data, but I got an error once I pass the df into it.

Set seed for reproducibility

Screenshot 2024-08-16 at 11 08 56 PM

import pandas as pd
import numpy as np
from pybnesian import MutualInformation

np.random.seed(42)

# Generate continuous data
data_size = 100
continuous_data_1 = np.random.normal(loc=50, scale=10, size=data_size)
continuous_data_2 = np.random.normal(loc=30, scale=5, size=data_size)

# Generate categorical data
categories = np.random.choice(['Category A', 'Category B', 'Category C'], size=data_size)

# Create DataFrame
df = pd.DataFrame({
    'Continuous_1': continuous_data_1,
    'Continuous_2': continuous_data_2,
    'Category': categories
})

kmi = MutualInformation(df=data)
Screenshot 2024-08-16 at 11 18 58 PM
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

1 participant