Comments (4)
Thanks @GabrielAzevedoFerreiraQB,
We currently have an experimental work stream on an sklearn wrapper that uses a target/"dependent variable" explicitly.
It will still use notears in the background but will have fit/predict API as well as feature importances.
from causalnex.
what's more,how can i define the label of dataset in the process of from_pandas
?
from causalnex.
Thanks for the question and for the interest in CausalNex!
Something that is particular to the Bayesian Network formalism is that there is no notion of target variable and features: everything is a variable. This does not prevent you to train a model and use it to predict a variable you consider target, but it will give you the possibility to also predict the other variables.
With that said, there are 2 "fit" phases in CausalNex, as opposed to other more traditional ML models (such as decision trees).
First, we learn the structure of the model: what the dependencies look like. We use from_pandas
for that indeed.
Second, we do the "Probability fitting". This fits the parameters of the model (much like Decision trees would). The method for this is bn.fit_cpds
. There is no notion of "target variable" in the Bayesian Network formalism, so what this does is to fit parameters that model all the variables as a whole.
One particularity is that, at this probability fitting stage, you would need to have discrete variables, so, if you variables are continuous, you'll need to use some type of discretisation.
Bonus: to "predict" a node we do bn.predict(data, node)
, where node
is the variable you are trying to predict. This means that you can use your trained model to predict any variable in the model, including your target (bn.predict(data,YOUR_TARGET_VAR_NAME)
).
This is it in a nutshell, but it is explained in more detail in our tutorial
https://causalnex.readthedocs.io/en/latest/03_tutorial/03_tutorial.html
from causalnex.
We have added the functionality in v0.8.1.
Please have a look at the supervised sklearn wrappers DAGClassifier
and DAGRegressor
which will work similarly to the DecisionTreeClassifier
you mention (also has .score
and .feature_importances_
).
You can use: from causalnex.structure import DAGClassifier
. You will need the pytorch to run them.
The graph is stored in model.graph_
for further inference and counterfactual steps.
from causalnex.
Related Issues (20)
- the same process different results HOT 1
- Can't install causalnex using poetry on new Apple M1 chip HOT 1
- EMSingleLatentVariable is producing random error at random times HOT 1
- Add GitHub Actions installation jobs across environments HOT 1
- Unsuitability of Notears for causal inference HOT 3
- How do I save the fitted Bayesian model locally HOT 2
- get_target_subgraph function is not working HOT 1
- vis.show() UnicodeEncodeError HOT 9
- Find out the number of cycles HOT 1
- 01_first_tutorial.ipynb hangs on `from_pandas(...)`
- [Feature Request]: Support pandas >= 2.0
- [Bug]: Pycharm cannot use causalnex HOT 1
- [help]: I am unable to display images while using viz. show()
- [Feature Request]: batch_size for notears with GPU
- [Bug]: Inconsistent Use of CUDA Devices When Using GPU with notears
- [Bug]: Classification Model always predicting 0 HOT 1
- [Bug]: fix typo in 04_user_guide.md
- [Feature Request]: Support Python 3.11
- [Bug]: causalnex.discretiser.MDLPSupervisedDiscretiserMethod does not import MDLP
- An issue with plotting[Bug]: HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from causalnex.