Skip to content

Conditional independence tests with mixed data #8

Description

@kenneth-lee-ch

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions