Giter VIP home page Giter VIP logo

ubc-stat-ml / blangdsl Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 3.87 MB

Blang core (parsing, generation, eclipse plug-in)

Home Page: https://www.stat.ubc.ca/~bouchard/blang/

License: BSD 2-Clause "Simplified" License

Xtend 87.59% Java 8.55% HTML 1.62% CSS 0.86% Shell 1.38%
bayesian-inference bayesian-statistics machine-learning markov-chain-monte-carlo mcmc mcmc-sampler probabilistic-graphical-models probabilistic-models probabilistic-programming

blangdsl's People

Contributors

alexandrebouchard avatar cubranic avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blangdsl's Issues

Build system redundancy

It looks like there is currently both .pom files and .gradle files. We should stick to one to make things easier to maintain.

Use of params in initializer blocks

Consider code of the form

model {
  param T1 p
  laws {
    x | T2 y = f(p) ~ Dist(y)
  }
  def static T2 f(T1 input) { .. }
}

Here the issue is that p is actually compiled to type Supplier<T1> so the expression f(p) cannot be translated directly.

Grammar should allow less or more than 1 dependencies

The following is not allowed by the grammar but should be:

model {
  random Real y
  laws {
    y ~ Normal(0, 1)
  }
}

Similarly for

model {
  random Real y
  param Real test
  param Real test2
  laws {
    y | Real t1 = test, Real t2 = test2 ~ Normal(t1, t2)
  }
}

Empty model produces invalid code

The empty model:

model {
}

produces

import blang.core.Model;

@SuppressWarnings("all")
public class MyFile implements Model {
}

which does not compile because it does not override abstract method components().

No README.md file

Basic instructions in a README.md would be great. Topics to include initially:

  • how to build
  • how to run
  • rough developer guide to navigate which files to edit (and which are generated)

Improve model constructors

  • Allow per variable default value using ?: syntax
  • Generate factory with all param and variables as optionals
  • In generated code, test for empty optionals and provide defaults otherwise

Call and cache the value of component()?

Inconsistency between unit test execution and child eclipse execution

The following runs fine in unit test execution but not in child eclipse:

model {
  random Object test
  laws {
    logf(test) = { 1.0 + 1.0 }
  }
}

but weirdly, the following works in both:


model {
  random Object test
  laws {
    logf(test) = { 1.0 }
  }
}

Conjecture: It seems that +,-,*,.. do not work somehow in child eclipse.

Improve output/analysis functionalities

Realistically, this should be a two-step process:

  1. Focus on output into formats that are read by other tools (csv, coda) [more or less done]
  2. Bring the full Bayesian analysis within the language

The processing architecture should support this evolution.

Note that point 2 involves a lot of parts:

  • Min Bayes Risk (exact and approximate)
  • Histograms and density estimates (possibly using type/support information to get bounds right)
  • Convergence diagnostics and plots
  • Trace plots
  • ESS and MC standard error
  • HPD
  • Derived statistics
  • Expectations, variances, and other moments
  • Quantiles

For loop for model components

Example in MarkovChain, but it can be also a log or support factor:

  laws {
    for (int t = 0; t < states.size(); t++) {
      states.get(t + 1) | Int prev = states.get(t), calculator, t
        ~ Categorical(calculator.transitionsProbabilities(t).get(prev))
    }
  }

Improve annotation based calling of Instantiator

Use the following recursive structure both for Default and InitVia (and generally, to work around limitations around type permitted in annotations):

  static annotation WithArg {
    String key = "" 
    String value
    WithArg [] children = #[]
  }

  static annotation Instantiator {
    Class<?> type
    WithArg [] arguments = #[]
  }

  static annotation InitViaInstantiator {
    Instantiator value 
  }


  @InitViaInstantiator(
    @Instantiator(
      type = OneArgConstructor, 
      arguments = #[
        @WithArg(key = "type",   value = "java.lang.String"),
        @WithArg(key = "parser", value = "inits.strategies.parsers.StringParser")
      ]
    )
  )
  static class MyClass {
    new(String test) {}
  }

Clean up line parsing

For example, some of the recursive behavior can be pulled out of the loop, no comments, etc.

Automate generation of Geweke tests

Can reuse some of the stuff in blang2/bayonet but improvements are required in terms of automation, handling false positive rate adaptively, etc.

Allow zero argument Distribution/LogScaleFactor/SupportFactor

In the grammar, params for Distribution/LogScaleFactor/SupportFactor are of the form

'(' (param += Param) ( ',' param += Param)* ')'

which I think imply at least one param is needed. As some of them may have zero arguments, I suppose the alternative would be something like

'(' (
  ')' | 
  ( param += Param) ( ',' param += Param)* ')' )
)

Hashtable lookup for model variables when doing JVM inferrer

In BlangDslJvmModelInferrer when large to medium models are parsed, expression of the form model.vars.findFirst[name == p] are likely to become a computational bottleneck. This could be addressed by first going over the variables to create a hashtable lookup, and then using that hashtable.

Use SDK as basis for template

Instead of maintaining one repo for SDK development, and one for blang project template (currently, blangProjectTemplate), use a script that strips the former to create the latter. Will make it easier to maintain.

Deployable eclipse plug-in

It would be nice for users to be able to just add Blang from the Eclipse marketplace, instead of having to clone the blangDSL project and run it in child Eclipse.

It could be done with an Eclipse update site, docs

Methods handling Suppliers have wrong return type

E.g., with

param Real m,v
param List<Real> means
laws{
  for (int i : 0..<2) {
    means.get(i) | m, v ~ Normal(m, v)
  }
}

the generated methods for handling m are:

  private static Object $generated__2(final Real m, final Real v) {
    return m;
  }

  private static Supplier<Object> $generated__2_lazy(final Supplier<Real> $generated__m, final Supplier<Real> $generated__v) {
    return () -> $generated__2($generated__m.get(), $generated__v.get());
  }

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.