uber / causalml

Uplift modeling and causal inference with machine learning algorithms
Other
4.92k stars 763 forks source link

uplift p_value is NAN #585

Open yanduoduan opened 1 year ago

yanduoduan commented 1 year ago

This uplift p_value is nan occurs when using UpliftTreeClassifier,why?

paullo0106 commented 1 year ago

@yanduoduan do you mind sharing more information? maybe a code snippet you were using, thanks

yanduoduan commented 1 year ago

from IPython.display import Image from causalml.inference.tree import UpliftTreeClassifier, UpliftRandomForestClassifier from causalml.inference.tree import uplift_tree_string, uplift_tree_plot from causalml.dataset import make_uplift_classification x = [[170,3,18,'v1',0], [1210,4,11,'v1',123.4], [150,7,-99,'v2',300], [230,11,6,'v2',0], [20,1,-99,'v1',523.7]] df = pd.DataFrame(x,columns=['x1','x2','x3','version','outcome']) uplift_model = UpliftTreeClassifier(max_depth=3, min_samples_leaf=1, min_samples_treatment=1, n_reg=100, evaluationFunction='ED', control_name='v1') x_names = ['x1','x2','x3'] uplift_model.fit(df[x_names].values, treatment=df['version'].values, y=df['outcome'].values)

graph = uplift_tree_plot(uplift_model.fitted_uplift_tree, x_names) Image(graph.create_png())

Thanks,My y is a continuous variable, and I want to distinguish people through the tree model to guide my decision-making.

paullo0106 commented 1 year ago

hmm UpliftTreeClassifier is for binary variable, for regression problem with continuous variable, you might want to check out from causalml.inference.tree import CausalTreeRegressor, we have a notebook for that https://github.com/uber/causalml/blob/master/examples/causal_trees_with_synthetic_data.ipynb

yanduoduan commented 1 year ago

ok. Thanks. How do I use CausalTreeRegressor if I have one control and multiple tratement? How to interpret the generated tree?