Code Monkey home page Code Monkey logo

Comments (4)

qbphilip avatar qbphilip commented on May 25, 2024 1

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.

ziyuwzf avatar ziyuwzf commented on May 25, 2024

what's more,how can i define the label of dataset in the process of from_pandas?

from causalnex.

GabrielAzevedoFerreiraQB avatar GabrielAzevedoFerreiraQB commented on May 25, 2024

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.

qbphilip avatar qbphilip commented on May 25, 2024

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)

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.