You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I used the fill() function of UpliftTreeClassifier according to the documentation, where the parameters are specified as NumPy arrays
However, I encountered a bug.
uplift_model.fill(X=X_val, treatment=treatment_val, y=y_val)
File "causalml/inference/tree/uplift.pyx", line 534, in causalml.inference.tree.uplift.UpliftTreeClassifier.fill
File "causalml/inference/tree/uplift.pyx", line 557, in causalml.inference.tree.uplift.UpliftTreeClassifier.fillTree
File "causalml/inference/tree/uplift.pyx", line 846, in causalml.inference.tree.uplift.UpliftTreeClassifier.tree_node_summary
File "causalml/inference/tree/uplift.pyx", line 667, in causalml.inference.tree.uplift.UpliftTreeClassifier.group_uniqueCounts
AttributeError: 'bool' object has no attribute 'sum'
To Reproduce
`import numpy as np
import pandas as pd
from causalml.inference.tree import UpliftTreeClassifier
from sklearn.model_selection import train_test_split
Describe the bug
I used the fill() function of UpliftTreeClassifier according to the documentation, where the parameters are specified as NumPy arrays
However, I encountered a bug.
uplift_model.fill(X=X_val, treatment=treatment_val, y=y_val)
File "causalml/inference/tree/uplift.pyx", line 534, in causalml.inference.tree.uplift.UpliftTreeClassifier.fill
File "causalml/inference/tree/uplift.pyx", line 557, in causalml.inference.tree.uplift.UpliftTreeClassifier.fillTree
File "causalml/inference/tree/uplift.pyx", line 846, in causalml.inference.tree.uplift.UpliftTreeClassifier.tree_node_summary
File "causalml/inference/tree/uplift.pyx", line 667, in causalml.inference.tree.uplift.UpliftTreeClassifier.group_uniqueCounts
AttributeError: 'bool' object has no attribute 'sum'
To Reproduce
`import numpy as np
import pandas as pd
from causalml.inference.tree import UpliftTreeClassifier
from sklearn.model_selection import train_test_split
data = pd.DataFrame({
'feature1': np.random.rand(1000000),
'feature2': np.random.rand(1000000),
'treatment': np.random.choice([0, 1], 1000000),
'outcome': np.random.choice([0, 1], 1000000)
})
X = data[['feature1', 'feature2']]
treatment = np.where(data['treatment'] == 0, 'control', 'treatment') #
y = data['outcome']
X_train, X_val, treatment_train, treatment_val, y_train, y_val = train_test_split(
X, treatment, y, test_size=0.2, random_state=42
)
uplift_model = UpliftTreeClassifier(
max_depth=3,
min_samples_leaf=200,
min_samples_treatment=5,
n_reg=100,
evaluationFunction='KL',
control_name='control'
)
uplift_model.fit(X=X_train.values, treatment=treatment_train, y=y_train.values)
uplift_model.fill(X=X_val.values, treatment=treatment_val, y=y_val.values)`
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: