Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Causal Inference Engine in Kotlin

almo
January 20, 2021

Causal Inference Engine in Kotlin

Causal Inference Engine based in the paper[1] and implemented in Koltin using Probability Trees.

According the paper, probability trees are one of the simplest models of causal generative processes. They possess clean semantics and -- unlike causal Bayesian networks -- they can represent context-specific causal dependencies, which are necessary for e.g. causal induction. Yet, they have received little attention from the AI and ML community.

[1] Algorithms for Causal Reasoning in Probability Trees
Genewein et al. (2020)
DeepMind
https://arxiv.org/abs/2010.12237

almo

January 20, 2021
Tweet

More Decks by almo

Other Decks in Programming

Transcript

  1. Causal Inference
    Engine
    Programming AI with Kotlin
    @davilagrau

    View Slide

  2. 1. Schedule
    AI paradigm programmed in Kotlin
    ➔ Introduction
    almo, open source and community
    ➔ Kotlin AI
    Java developers’ dream of a better
    programming language.
    ➔ Curve fitting vs Strong AI
    Machines with the sense of humans: mind
    over data
    ➔ Causal Inference Engine
    Answering the simplest question: Why?

    View Slide

  3. Introduction:
    a.l.m.o
    Opensource
    Dev Communities

    View Slide

  4. A few words about me...
    Andres-Leonardo Martinez-Ortiz a.k.a almo is a member of the
    Google Engineering team, leading Google Developer Relations
    worldwide.
    Based in Zurich, he drives the success of Google's developer
    products and the Open Web by creating a thriving ecosystem of
    developers.
    Nurturing developers experts and partners in large companies,
    startups, universities and enterprises, almo fosters open standards
    and Google technologies.
    almo is also a member of IEEE, ACM, Linux Foundation and
    Computer Society.
    @davilagrau
    almo.dev
    almo

    View Slide

  5. Developers came together
    from all corners of the
    world to innovate,
    find connection,
    and solve
    problems*, using
    Internet and Open Source.
    *Octoverse 2020

    View Slide

  6. Photo by Perry Grone on Unsplash
    Compartir Aprendiendo
    Aprender Enseñando
    Enseñar Aprendiendo

    View Slide

  7. Koltin AI?

    View Slide

  8. Why Kotlin?
    Easy learning curve
    Java interoperability
    Ecosystem support
    Educational resources:
    ● Kotlin Koans
    Multi platform
    The language of Android
    and server side, web or
    native applications
    Academically recognized
    Popular in the industry
    Multi paradigm
    Concurrent programming
    including corrutines and CSP
    Object oriented
    Higher order functions and
    Lambda functions

    View Slide

  9. Curve fitting
    vs Strong AI
    Photo by Alora Griffiths on Unsplash

    View Slide

  10. CSAT for computers,
    emperors and their
    new minds & Chinese
    rooms
    Thinking about intelligence:
    Philosophical foundations.
    Photo by K. Mitch Hodge on Unsplash

    View Slide

  11. Superintelligent AI
    May Be Impossible to
    Control.
    Not even possible to know if an AI is
    superintelligent.
    https://spectrum.ieee.org/tech-talk/robotics/artificial-intelligence/super-artificialintelligence
    January 2021

    View Slide

  12. Counterfactuals
    Activities: imagining, retrospective,
    understanding.
    What if I have done… ? Why?
    Was X the cause? Y? What if
    X has not occurred? What if I
    acted differently?
    Intervention
    Activities: doing, intervening.
    What if I do… ? How? What
    would Y be if I do X? How can
    I make Y happen?
    Association
    Activities: seeing, observing.
    What if I see…? How are the
    variables related? How would
    seeing X change my belief of Y?
    The Ladder
    of Causation

    View Slide

  13. Causal
    Inference
    Engine
    Knowledge
    Assumptions Causal Model
    Testable
    Implication
    Query
    Can we
    answer?
    Back to
    2 and 3
    Estimand
    (Recipe)
    Data
    Statistical
    Estimation
    Estimate
    (Answer)
    1
    2 3 4
    5
    7 8
    9
    6
    Yes
    No
    Inference
    Engine

    View Slide

  14. Representing Knowledge in a
    Uncertain World
    Bayesian networks vs
    causality inference
    Mind over data
    “Causation is a language with
    which one can talk efficiently
    about certain structures of
    relevance relationships.”
    (1988)
    “The words embarrass
    me today ”
    (2018)

    View Slide

  15. Causal Inference in
    Probability Trees
    Algorithms for Causal
    Reasoning in Probability Trees
    Genewein et al. (2020)
    DeepMind
    https://arxiv.org/abs/1911.10500

    View Slide

  16. Definitions
    Algorithms for Causal
    Reasoning in Probability Trees
    Genewein et al. (2020)
    DeepMind
    https://arxiv.org/abs/2010.12237

    View Slide

  17. Probability Trees Recursive definition
    Node n is a tuple n = (u,S,C)
    ● Id
    ● Statements list
    ● Transition list
    Transition list is a tuple (,) ∈
    [0,1]xN
    ● transition probability
    ● Node m
    The root:
    ● Node without parents
    ● Statement “O=1”
    A leaf is a node with childs.

    View Slide

  18. Events and
    min-cuts
    An event is a collection of total
    realization i.e. path from the root to a
    leaf.
    Formally, an event is a cut δ(, ) where
    the true set and the false set contains
    all the nodes where the event becomes
    true and false respectively.
    Critical nodes are Markov Blanket: all
    variables bound within a path from the
    root to the critical nodes are exogenous
    downstream.

    View Slide

  19. Min-cuts Algorithms
    Bug:
    it should be V

    View Slide

  20. Causal Events
    Precedence Bug:
    it should be

    e
    Bug:
    it should be

    e
    Note: the event where Y=1 precedes Z=0
    cannot be stated logically. It is a causal event
    requiring a probability tree.

    View Slide

  21. Causal Events
    Conditions Bug:
    it should be q
    Question: What is the probability of the event
    A given that the event B is true?
    Note: Downstream (prediction) or upstream
    (inference)

    View Slide

  22. Causal Events
    Interventions
    Question: What is the probability of the event
    A given that the event B was made true?
    Note: only downstream (prediction)

    View Slide

  23. Code
    AI Applications in Kotlin
    almo’s github repo
    https://github.com/almo
    https://gist.github.com/almo

    View Slide

  24. Data Structure

    View Slide

  25. Tree Definition

    View Slide

  26. Initialization
    Root
    NodeID:01
    Statement:[O,1]
    Transitions
    Statements:[(X, 0)]
    NodeID:01.0
    P:0.4545
    Statements:[(Y, 0)]
    NodeID:01.0.0
    P:0.4000
    Statements:[(Z, 0)]
    NodeID:01.0.0.0
    P:0.5000
    Statements:[(Z, 1)]
    NodeID:01.0.0.1
    P:0.5000
    Statements:[(Y, 1)]
    NodeID:01.0.1
    P:0.6000
    Statements:[(Z, 1)]
    NodeID:01.0.1.0
    P:0.3333
    Statements:[(Z, 0)]
    NodeID:01.0.1.1
    P:0.6667
    Statements:[(X, 1)]
    NodeID:01.1
    P:0.5455
    Statements:[(Z, 0)]
    NodeID:01.1.0
    P:0.3333
    Statements:[(Y, 0)]
    NodeID:01.1.0.0
    P:0.5000
    Statements:[(Y, 1)]
    NodeID:01.1.0.1
    P:0.5000
    Statements:[(Z, 1)]
    NodeID:01.1.1
    P:0.6667
    Statements:[(Y, 1)]
    NodeID:01.1.1.0
    P:0.2000
    Statements:[(Y, 0)]
    NodeID:01.1.1.1
    P:0.8000

    View Slide

  27. Min-cuts
    Algorithms
    Remember:
    it should be V

    View Slide

  28. Causal Events
    Precedence
    Bug:
    it should be

    e
    Bug:
    it should be

    e

    View Slide

  29. Causal Events
    Conditions
    Bug:
    it should be q

    View Slide

  30. Causa Events
    Conditions
    Bug:
    it should be q

    View Slide

  31. Causal Events
    Interventions

    View Slide

  32. Causal Events
    Interventions

    View Slide

  33. Further details
    Please check the reference[1] for additional
    details and consideration.
    Interesting analysis of the application in
    machine learning can be found in the reference
    [2]
    The Causal Inference Engine is work in
    progress. You can find the code at
    http:/
    /bit.ly/2Mcrh4g
    Update and tech news in my twitter timeline
    @davilagrau
    [1] Algorithms for Causal
    Reasoning in Probability
    Trees
    Genewein et al. (2020)
    DeepMind
    https://arxiv.org/abs/2010.12237
    [2] Causality for
    Machine Learning
    B. Schölkopf (2019)
    DeepMind
    https://arxiv.org/abs/1911.10500

    View Slide

  34. Causal Inference
    Engine
    Programming AI with Kotlin
    @davilagrau
    Thank you!
    @davilagrau
    almo.dev
    almo

    View Slide