Coder Social home page Coder Social logo

datacanvasio / ylearn Goto Github PK

View Code? Open in Web Editor NEW
379.0 11.0 71.0 12.51 MB

YLearn, a pun of "learn why", is a python package for causal inference

Home Page: https://ylearn.readthedocs.io

License: Apache License 2.0

Jupyter Notebook 0.30% Python 89.54% Cython 9.10% Dockerfile 0.13% C++ 0.93%
causal-inference causality causal-models causal-discovery causality-analysis causality-algorithms uplift uplift-modeling policy-learning

ylearn's Introduction


中文

YLearn, a pun of "learn why", is a python package for causal inference which supports various aspects of causal inference ranging from causal effect identification, estimation, and causal graph discovery, etc.

Documentation website: https://ylearn.readthedocs.io

中文文档地址https://ylearn.readthedocs.io/zh_CN/latest/

Installation

Pip

The simplest way of installing YLearn is using pip:

pip install ylearn

Note that Graphviz is required to plot causal graph in notebook, so install it before running YLearn. See https://graphviz.org/download/ for more details about Graphviz installation.

Conda

YLearn can also be installed with conda. Install it from the channel conda-forge:

conda install -c conda-forge ylearn

This will install YLearn and all requirements including Graphviz.

Docker

We also publish an image in Docker Hub which can be downloaded directly and includes the components:

  • Python 3.8
  • YLearn and its dependent packages
  • JupyterLab

Download the docker image:

docker pull datacanvas/ylearn

Run a docker container:

docker run -ti -e NotebookToken="your-token" -p 8888:8888 datacanvas/ylearn

Then one can visit http://<ip-addr>:8888 in the browser and type in the token to start.

Overview of YLearn

Machine learning has made great achievements in recent years. The areas in which machine learning succeeds are mainly for prediction, e.g., the classification of pictures of cats and dogs. However, machine learning is incapable of answering some questions that naturally arise in many scenarios. One example is for the counterfactual questions in policy evaluations: what would have happened if the policy had changed? Due to the fact that these counterfactuals can not be observed, machine learning models, the prediction tools, can not be used. These incapabilities of machine learning partly give rise to applications of causal inference in these days.

Causal inference directly models the outcome of interventions and formalizes the counterfactual reasoning. With the aid of machine learning, causal inference can draw causal conclusions from observational data in various manners nowadays, rather than relying on conducting craftly designed experiments.

A typical complete causal inference procedure is composed of three parts. First, it learns causal relationships using the technique called causal discovery. These relationships are then expressed either in the form of Structural Causal Models or Directed Acyclic Graphs (DAG). Second, it expresses the causal estimands, which are clarified by the interested causal questions such as the average treatment effects, in terms of the observed data. This process is known as identification. Finally, once the causal estimand is identified, causal inference proceeds to focus on estimating the causal estimand from observational data. Then policy evaluation problems and counterfactual questions can also be answered.

YLearn, equipped with many techniques developed in recent literatures, is implemented to support the whole causal inference pipeline from causal discovery to causal estimand estimation with the help of machine learning. This is more promising especially when there are abundant observational data.

Concepts in YLearn

Concepts in YLearn

There are 5 main concepts in YLearn corresponding to the causal inference pipeline.

  1. CausalDiscovery. Discovering the causal relationships in the observational data.

  2. CausalModel. Representing the causal relationships in the form of CausalGraph and doing other related operations such as identification with CausalModel.

  3. EstimatorModel. Estimating the causal estimand with various techniques.

  4. Policy. Selecting the best policy for each individual.

  5. Interpreter. Explaining the causal effects and polices.

These components are connected to give a full pipeline of causal inference, which are also encapsulated into a single API Why.

Pipeline in YLearn

A typical pipeline in YLearn The pipeline of causal inference in YLearn.

Starting from the training data:

  1. One first uses the CausalDiscovery to reveal the causal structures in data, which will usually output a CausalGraph.
  2. The causal graph is then passed into the CausalModel, where the interested causal effects are identified and converted into statistical estimands.
  3. An EstimatorModel is then trained with the training data to model relationships between causal effects and other variables, i.e., estimating causal effects in training data.
  4. One can then use the trained EstimatorModel to predict causal effects in some new test dataset and evaluate the policy assigned to each individual or interpret the estimated causal effects.

It is also helpful to use the following flow chart in many causal inference tasks

Helpful flow chart when using YLearn

Quick Start

In this part, we first show several simple example usages of YLearn. These examples cover the most common functionalities. Then we present a case stuy with Why to unveil the hidden causal relations in data.

Example usages

We present several necessary example usages of YLearn in this section, which covers defining a causal graph, identifying the causal effect, and training an estimator model, etc. Please see their specific documentations for more details.

  1. Representation of the causal graph

    Given a set of variables, the representation of its causal graph in YLearn requires a python dict to denote the causal relations of variables, in which the keys of the dict are children of all elements in the corresponding values where each value usually should be a list of names of variables. For an instance, in the simplest case, for a given causal graph X <- W -> Y, we first define a python dict for the causal relations, which will then be passed to CausalGraph as a parameter:

        causation = {'X': ['W'], 'W':[], 'Y':['W']}
        cg = CausalGraph(causation=causation)

    cg will be the causal graph encoding the causal relation X <- W -> Y in YLearn. If there exist unobserved confounders in the causal graph, then, aside from the observed variables, we should also define a python list containing these causal relations. For example, a causal graph with unobserved confounders (green nodes)

    is first converted into a graph with latent confounding arcs (black dotted llines with two directions)

    To represent such causal graph, we should

    (1) define a python dict to represent the observed parts, and

    (2) define a list to encode the latent confounding arcs where each element in the list includes the names of the start node and the end node of a latent confounding arc:

         from ylearn.causal_model.graph import CausalGraph
         
         # define the dict to represent the observed parts
         causation_unob = {
             'X': ['Z2'],
             'Z1': ['X', 'Z2'],
             'Y': ['Z1', 'Z3'],
             'Z3': ['Z2'],
             'Z2': [], 
         }
         
         # define the list to encode the latent confounding arcs for unobserved confounders
         arcs = [('X', 'Z2'), ('X', 'Z3'), ('X', 'Y'), ('Z2', 'Y')]
    
         cg_unob = CausalGraph(causation=causation_unob, latent_confounding_arcs=arcs)
  2. Identification of causal effect

    It is crucial to identify the causal effect when we want to estimate it from data. The first step for identifying the causal effect is identifying the causal estimand. This can be easily done in YLearn. For an instance, suppose that we are interested in identifying the causal estimand P(Y|do(X=x)) in the causal graph cg defined above, then we can simply define an instance of CausalModel and call the identify() method:

         cm = CausalModel(causal_graph=cg)
         cm.identify(treatment={'X'}, outcome={'Y'}, identify_method=('backdoor', 'simple'))

    where we use the backdoor-adjustment method here by specifying identify_method=('backdoor', 'simple'). YLearn also supports front-door adjustment, finding instrumental variables, and, most importantly, the general identification method developed in [1] which is able to identify any causal effect if it is identifiable. For an example, given the following causal graph,

    if we want to identify P(Y1, Y2|do(X)), racalling that black dotted lines with two directions are latent confounding arcs (i.e., there is an unobserved confounder pointing to the two end nodes of each black dotted line), we can apply YLearn as follows

       causation = {
            'W1': [],
            'W2': [],
            'X': ['W1'],
            'Y1': ['X'],
            'Y2': ['W2']
        }
        arcs = [('W1', 'Y1'), ('W1', 'W2'), ('W1', 'Y2'), ('W1', 'Y1')]
        cg = graph.CausalGraph(causation, latent_confounding_arcs=arcs)
        cm = model.CausalModel(cg)
        p = cm.id({'Y1', 'Y2'}, {'X'})
        p.show_latex_expression()

    which will give us the identified causal effect P(Y1, Y2|X) as follows

    and calling the method p.parse() will give us the latex expression

    \sum_{W2}\left[\left[P(Y2|W2)\right]\right]\left[\sum_{W1}\left[P(W1)\right]\left[P(Y1|X, W1)\right]\right]\left[P(W2)\right]
    
  3. Instrumental variables

    Instrumental variable is an important technique in causal inference. The approach of using YLearn to find valid instrumental variables is very straightforward. For example, suppose that we have a causal graph

    ,

    we can follow the common procedure of utilizing identify methods of CausalModel to find the instrumental variables: (1) define the dict and list of the causal relations; (2) define an instance of CausalGraph to build the related causal graph in YLearn; (3) define an instance of CausalModel with the instance of CausalGraph in last step being the input; (4) call the get_iv() method of CausalModel to find the instrumental variables

         causation = {
             'p': [],
             't': ['p', 'l'],
             'l': [],
             'g': ['t', 'l']
         }
         arc = [('t', 'g')]
         cg = CausalGraph(causation=causation, latent_confounding_arcs=arc)
         cm = CausalModel(causal_graph=cg)
         cm.get_iv('t', 'g')
  4. Estimation of causal effect

    The estimation of causal effects in YLearn is also fairly easy. It follows the common approach of deploying a machine learning model since YLearn focuses on the intersection of machine learning and causal inference in this part. Given a dataset, one can apply any EstimatorModel in YLearn with a procedure composed of 3 distinct steps:

    • Given data in the form of pandas.DataFrame, find the names of treatment, outcome, adjustment, covariate.
    • Call fit() method of EstimatorModel to train the model with the names of treatment, outcome, and adjustment specified in the first step.
    • Call estimate() method of EstimatorModel to estimate causal effects in test data.

    One can refer to the documentation website for methodologies of many estimator models implemented by YLearn.

  5. Using the all-in-one API: Why

    For the purpose of applying YLearn in a unified and easier manner, YLearn provides the API Why. Why is an API which encapsulates almost everything in YLearn, such as identifying causal effects and scoring a trained estimator model. To use Why, one should first create an instance of Why which needs to be trained by calling its method fit(), after which other utilities, such as causal_effect(), score(), and whatif(), can be used. This procedure is illustrated in the following code example:

        from sklearn.datasets import fetch_california_housing
    
        from ylearn import Why
    
        housing = fetch_california_housing(as_frame=True)
        data = housing.frame
        outcome = housing.target_names[0]
        data[outcome] = housing.target
    
        why = Why()
        why.fit(data, outcome, treatment=['AveBedrms', 'AveRooms'])
    
        print(why.causal_effect())

Case Study

In the notebook CaseStudy, we utilize a typical bank customer dataset to further demonstrate the usage of the all-in-one API Why of YLearn. Why covers the full processing pipeline of causal learning, including causal discovery, causal effect identification, causal effect estimation, counterfactual inference, and policy learning. Please refer to CaseStudy for more details.

Contributing

We welcome community contributors to the project. Before you start, please firstly read our code of conduct and contributing guidelines.

Communication

We provide several communcication channels for developers.

Citation

If you use YLearn in your research, please cite us as follows:

Bochen Lyu, Xuefeng Li, Jian Yang.
YLearn: A Python Package for Causal Inference. https://github.com/DataCanvasIO/YLearn, 2022. Version 0.2.x.

BibTex:

@misc{YLearn,
  author={Bochen Lyu,Xuefeng Li,Jian Yang},
  title={{YLearn}: { A Python Package for Causal Inference}},
  howpublished={https://github.com/DataCanvasIO/YLearn},
  note={Version 0.2.x},
  year={2022}
}

License

See the LICENSE file for license rights and limitations (Apache-2.0).

References

[1] J. Pearl. Causality: models, reasoing, and inference.

[2] S. Shpister and J. Identification of Joint Interventional Distributions in Recursive Semi-Markovian Causal Models. AAAI 2006.

[3] B. Neal. Introduction to Causal Inference.

[4] M. Funk, et al. Doubly Robust Estimation of Causal Effects. Am J Epidemiol. 2011 Apr 1;173(7):761-7.

[5] V. Chernozhukov, et al. Double Machine Learning for Treatment and Causal Parameters. arXiv:1608.00060.

[6] S. Athey and G. Imbens. Recursive Partitioning for Heterogeneous Causal Effects. arXiv: 1504.01132.

[7] A. Schuler, et al. A comparison of methods for model selection when estimating individual treatment effects. arXiv:1804.05146.

[8] X. Nie, et al. Quasi-Oracle estimation of heterogeneous treatment effects. arXiv: 1712.04912.

[9] J. Hartford, et al. Deep IV: A Flexible Approach for Counterfactual Prediction. ICML 2017.

[10] W. Newey and J. Powell. Instrumental Variable Estimation of Nonparametric Models. Econometrica 71, no. 5 (2003): 1565–78.

[11] S. Kunzel2019, et al. Meta-Learners for Estimating Heterogeneous Treatment Effects using Machine Learning. arXiv: 1706.03461.

[12] J. Angrist, et al. Identification of causal effects using instrumental variables. Journal of the American Statistical Association.

[13] S. Athey and S. Wager. Policy Learning with Observational Data. arXiv: 1702.02896.

[14] P. Spirtes, et al. Causation, Prediction, and Search.

[15] X. Zheng, et al. DAGs with NO TEARS: Continuous Optimization for Structure Learning. arXiv: 1803.01422.

ylearn's People

Contributors

ayaiaz avatar bochenlv avatar cryttx avatar cyue0316 avatar diwang137 avatar felixonmars avatar liuzhaohan0 avatar lixfz avatar newbei avatar oaksharks avatar qin2dim avatar zhangxjohn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ylearn's Issues

fit不指定treatment时,进程闪退

Please make sure that this is a bug.

System information

  • OS Platform and Distribution (e.g., CentOS 7.6):
  • Python version:
  • YLearn version:
  • Other Python packages(run pip list):

**from ylearn import Why

why = Why()
why.fit(data, outcome)**

报错:
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

说明:当训练why模型时,不指定treatment参数时,程序闪退

代码如下:
**
from sklearn.datasets import fetch_california_housing

housing = fetch_california_housing(as_frame=True)
data = housing.frame
outcome = housing.target_names[0]
data[outcome] = housing.target

from ylearn import Why

why = Why()
why.fit(data, outcome)
**

Call for Contributors - 2022 July

Welcome to YLearn community!

YLearn is a python package for causal inference which has implemented many recent developed techniques, ranging from causal discovery, causal effect identification and estimation, etc. To keep improving and enhancing the performance, we encourage all interested developers to join and build YLearn.

Below we prepare three types of contribution tasks: documentation, coding, and information. If you are interested and willing to share your ideas, don't hesitate to click the issue and contribute. For our information, please reply to the issue 'I will help this one' to avoid repeat work.

We also provide a detailed instruction in Chinese . For any questions and suggestions, you could also contact us via email: [email protected]

Please find the issues:
Documentation:

Coding:

Information:

Last but not least, we encourage developers to submit your own issues to challenge us!

run case_study_bank.py plotting issue on Mac

There is a issue happened when run case_study_bank.py on Mac Machine:
MacOS Monterey 12.3.1
Python 3.10
Errors as following:

why.plot_causal_graph()

...
07-17 17:18:23 I ylearn._why.py 508 - encode treatment ...
07-17 17:18:23 I ylearn._why.py 518 - preprocess data ...
07-17 17:18:24 I ylearn._why.py 536 - fit estimator for Card_Category with PermutedTLearner(model=GradientBoostingRegressor(max_depth=100), random_state=2022, kwargs=None)
/Users/jevin/dev/python/ai/YLearn/ylearn/utils/_common.py:95: UserWarning: Failed to display pydot image: [Errno 2] "fdp" not found in path..
warnings.warn(f'Failed to display pydot image: {e}.')

Cannot use CausalTree as estimator

I try to use CausalTree as the estimator in why(), but seems like CausalTree.estimate() got unexpected keyword arguments.

Here is my code:

why1=Why(estimator='tree')
why1.fit(train_data,outcome,treatment='Card_Category')
effect1=why1.causal_effect(control='Blue',return_detail=True)

and error msg:

Traceback (most recent call last):
File "d:/06.Repo/YLearn-main/example_usages/case_study_bank.py", line 38, in
effect1=why1.causal_effect(control='Blue',return_detail=True)
File "C:\Users\peng.liu2\Anaconda3\envs\CV\lib\site-packages\ylearn_why.py", line 820, in causal_effect
return self._causal_effect_discrete(test_data, treat, control, return_detail=return_detail)
File "C:\Users\peng.liu2\Anaconda3\envs\CV\lib\site-packages\ylearn_why.py", line 850, in _causal_effect_discrete
effect = est.estimate(data=test_data, treat=t, control=c)
TypeError: estimate() got an unexpected keyword argument 'treat'

I found that CausalTree.estimate() only accept data and quantity as arguments, so how can I use CausalTree as the estimator in why()

Dependency on turtle

Why does model.py use turtle.clone instead of deepcopy to clone the estimator?

I'm asking because removing the dependency on turtle would be nice, as turtle requires tkinter and tkinter is difficult to have in some development environment (databricks to make an example)

Problem about plotting causal graph

Please make sure that this is a bug.

System information

  • OS Platform and Distribution (e.g., CentOS 7.6):Win10
  • Python version:3.9.12
  • YLearn version:0.1.2
  • Other Python packages(run pip list):

Describe the current behavior

  • I wanna use API why.plot_causal_graph() ,but it doesn't output anything. Then I use another way likewhy.causal_graph().plot(), it can output causal graph normally.

Describe the expected behavior
It should ouput a causal graph normally.

Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Jupyter notebook.

Are you willing to submit PR?(Yes/No)

  • Yes

Other info / logs
Include any logs or source code that would be helpful to diagnose the problem.
If including tracebacks, please include the full traceback. Large logs and files
should be attached.

模型保存

请问训练好一个Why模型后如何保存模型到本地路径下

Problem about calling Why.fit()

Please make sure that this is a bug.

System information

  • OS Platform and Distribution (e.g., CentOS 7.6):Win10
  • Python version:3.9.12
  • YLearn version:0.1.2
  • Other Python packages(run pip list):

Describe the current behavior

  • I call why.fit(), and input the parameter instrument, it prints bug as below:
    ValueError: Expected 2D array, got scalar array instead:
    array=None.
    Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

Describe the expected behavior

Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Jupyter notebook.

Are you willing to submit PR?(Yes/No)

  • Yes

Other info / logs
Include any logs or source code that would be helpful to diagnose the problem.
If including tracebacks, please include the full traceback. Large logs and files
should be attached.

Discussions for YLearn Release Conference

YLearn release conference will be held on the 12th July (in Chinese only). You can scan the QR code and watch the videos.
If you have questions and ideas about the talk, just reply below the discussion post. We appreciate your valuable messages.

Discussed in #19

Originally posted by LIUZhaohan0 July 8, 2022
活动海报

[YLearn因果学习开源项目发布会] 将于2022年7月12日线上举办。

扫面下方二维码即可观看直播和重播。
对于发布会内容有任何问题或讨论可在下方留言, YLearn工作人员会为大家详细解答。
感谢大家的关注!
发布会二维码

Policy Optimization API Usage

Hi, I'm trying to do policy optimization using YLearn. I have read the docs about this but didn't understand the meaning very well. Formally, a policy optimization problem can be written as: $x^{*}=\text{argmax}_x\mathbb{E}[\mathcal{Y}|\text{do}(\mathcal{X}=x), \mathcal{S}]$. Then how do $\mathcal{Y}$, $\mathcal{X}$ and $\mathcal{S}$ represented in the arguments of the est.fit() api in https://ylearn.readthedocs.io/en/latest/sub/policy.html respectively? I need a more concrete explanation to better use the given api, thanks!

How to compute CATE for continous treatment?

Hi, I'm new to YLearn and Causal Inference, really appreciate your job. I have some questions as shown below

  1. How to compute CATE with Ylearn? Is this realized by input corresponding test_data in 'why.causal_effect(test_data)'?

  2. What's the difference between adjustments and covariate? Is covariate same as effect_modifier in dowhy?
    It seems like YLearn threat all adjustments and covariates as the input of estimator by get_wv(w, v)

  3. How to find the covariate with YLearn.model.CausalModel,?

Problem about plotting policy tree

Please make sure that this is a bug.

System information

  • OS Platform and Distribution (e.g., CentOS 7.6):Win10
  • Python version:3.9.12
  • YLearn version:0.1.2
  • Other Python packages(run pip list):

Describe the current behavior

  • I wanna use API why.plot_policy_tree(), and I specify control, like:
    why.plot_policy_tree(whatif_data, max_depth=2, treatment = 'CRIM',control = 3)
  • Then I get bug which show as below:
    invalid index to scalar variable

Describe the expected behavior

  • It should output the different leaf nodes and causal effect value compared to control value I specify.(like I specify control = 3)

Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Jupyter notebook.

Are you willing to submit PR?(Yes/No)

  • Yes

Other info / logs
Include any logs or source code that would be helpful to diagnose the problem.
If including tracebacks, please include the full traceback. Large logs and files
should be attached.

为什么我的因果图是缺失的

为什么我的因果图没有显示颜色,且箭头的yes和no都没有呢?
image
运行时只有这一个warning:
WARNING:matplotlib.font_manager:findfont: Font family ['SimHei'] not found. Falling back to DejaVu Sans.

a problem return 'CausalTree' object has no attribute 'criterion' in causal_tree.py about def plot_causal_tree

Please make sure that this is a bug. yes

System information

  • OS Platform and Distribution (e.g., CentOS 7.6): win10
  • Python version: python3.9
  • YLearn version:0.1.3
  • Other Python packages(run pip list):

Describe the current behavior
I run these code ,and make a causal tree successfully,but when i want plot a causal tree by plot_causal_tree,it return a error: 'CausalTree' object has no attribute 'criterion'

Describe the expected behavior

Standalone code to reproduce the issue
import numpy as np
import matplotlib.pyplot as plt

from ylearn.estimator_model.causal_tree import CausalTree ## 本次使用的估计器是因果树
from ylearn.exp_dataset.exp_data import sq_data
from ylearn.utils._common import to_df ## ylearn 提供的很方便的数据框转换函数

数据准备

n = 2000
d = 10
n_x = 1
y, x, v = sq_data(n, d, n_x)
y ## 2000x1
len(x) ## 2000x1
v.shape ## 2000x10

真实的干预效应

true_te = lambda X: np.hstack([X[:, [0]]**2 + 1, np.ones((X.shape[0], n_x - 1))])
data = to_df(treatment=x, outcome=y, v=v)
data ## 最终的数据集
n = 2000
d = 10
n_x = 1
y, x, v = sq_data(n, d, n_x)

构造测试数据

v_test = v[:min(100, n)].copy()
v_test[:, 0] = np.linspace(np.percentile(v[:, 0], 1), np.percentile(v[:, 0], 99), min(100, n))#产生等差数列
test_data = to_df(v=v_test)
test_data ## 100x10 测试集的第一列用了原数据里边第一列的从小到大的等差数列,暂不明白目的在哪里

因果树建模并拟合

outcome = 'outcome'
treatment = 'treatment'
adjustment = data.columns[2:]
ct = CausalTree(min_samples_leaf=3, max_depth=5)
ct.fit(data=data, outcome='outcome', treatment='treatment', adjustment=adjustment)
ct_pred = ct.estimate(data=test_data) ## 基于100行的测试数据进行预测
ct_pred

ct.plot_causal_tree(max_depth=5, feature_names=adjustment)# this is the line retruning error,please help tell me how to solve it

Are you willing to submit PR?(Yes/No)
yes

Other info / logs
Include any logs or source code that would be helpful to diagnose the problem.
If including tracebacks, please include the full traceback. Large logs and files
should be attached.

Problem about build a class "Why"

Please make sure that this is a bug.

System information

  • OS Platform and Distribution (e.g., CentOS 7.6):
  • Python version:3.9.12
  • YLearn version:0.1.2
  • Other Python packages(run pip list):

Describe the current behavior

  • I build a class "Why()", and input a estimate instance "t = TLearner(model=xgb.XGBRegressor())", but when I fit and then get bug, show as below:
    t = TLearner(model=xgb.XGBRegressor())
    why = Why(estimator = t,random_state=2022)
    why.fit(data, outcome, treatment = treatment)

Describe the expected behavior

  • It should run successfully

Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Jupyter notebook.

Are you willing to submit PR?(Yes/No)

  • Yes

Other info / logs
Include any logs or source code that would be helpful to diagnose the problem.
If including tracebacks, please include the full traceback. Large logs and files
should be attached.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.