Decisions, Decisions

I decided to add some basic support for decisions and utilities in this iteration. Searching for good policies really only works with small decision node sets at this stage (i.e. not too many decision combinations):


  • Support for decision nodes
  • Support for utility nodes
  • Expected value calculations for current network
  • Limited search for best set of decisions
  • Status bar shows time taken for last belief update
  • Animated belief bars
  • Performance improvements

Next release: Jan 3rd, 2015

Not Quite Keeping Promises

Ok, so I missed doing the update on the 6th. In my defence, I had no internet connection. (Let’s ignore that I could have planned things better). Release and changelist below.

Make-Believe (R3)

  • Cleaned up the status bar and toolbar so that they work a little more nicely.
  • I also just added a zoom.

I should note that I’m developing and testing in Firefox only, but I occasionally test in other browsers. Next release: 20th December.

Make-Believe: A Web-based Bayes Net Thingamajig

It’s been a year and a half since my last and first blog post — I think it’s safe to say I’m not obsessive about updating this blog! In any event, I now have something to write about.

On and off (and mostly off) for the past couple of years I’ve been spare-time hacking on a html-js Bayes net (BN) viewer. While it’s still pretty fragile, I think it’s in an OK enough state to put something out. I’m releasing it under an MIT License (i.e. do what you want with it, just don’t sue me or claim it’s yours) and I’ll be putting the source code (which is also the run code) up on Github shortly. I’m also hosting it and will always have the latest version of it right here:

One of the reasons I’m releasing it now is that I’ve started adding ‘non-core’ features to it (namely, a subset of GeNIe’s DBN viewer functionality), and it didn’t seem that difficult to do. That’s given me the hope (hopefully not false) that I might be able to make useful improvements to it in my spare time. So to spur me on, I’m releasing it publicly and committing to fortnightly updates. Now, fortnightly updates doesn’t mean something exciting every 2 weeks; it just means at least something changed every 2 weeks. That’s also why I’ll be using release numbers rather than version numbers. But hopefully it’s enough to get me into the routine of updating it and making useful additions to it over the long term.

Here’s some notes on the current version:

  • It’s 100% client-side html-js. In future, there will be plugins that will allow calling into server-side code, but these won’t ever be essential. So if you want to run Make-Believe from file: (and don’t have a browser with a crappy security policy), you’ll get the full non-plugin experience.
  • It currently only reads GeNIe .xdsl files. More formats will be added in future, but .xdsl will be the best supported format unless I decide there’s an extremely good reason to switch focus to another format. If you need to convert your net to work with it right now, you can try converting it with GeNIe.
  • It is currently limited to viewing a BN and performing belief updating. The aim is to have it do much more in future, hence the ‘thingamajig’ in the title of this post.
  • Discrete variables only for now. This is a limitation I’m eager to remove…
  • It only performs stochastic updating (using likelihood-weighting). This will likely remain true, but I will make the engine easy to swap out. Conversely, it will eventually be easy to use just the engine. Right now, the engine, file loader and viewer are a bit tangled up.
  • It supports some GeNIe DBNs. Namely, those which have all their nodes in the ‘Transition Step’ of the temporal plate. Wider support to come.
  • There is no support for decision networks or other BN extensions. Again, this is likely to change.
  • I’ve spent a fair bit of time optimising the engine. I haven’t benchmarked it properly, but it works fast and accurately enough on some of my real BNs, that I can use it in place of desktop BN packages for inference. (With recent browsers, of¬† course.) I have more to do, though, as I intend to use workers (threads) and SIMD.js to improve things still further.
  • Please fork and improve it. Just don’t expect me to keep up. I’d love to see others take the code and turn it into something great. But that doesn’t mean I’ll bring those changes into my version. This is a hobby for me, and I don’t want to spend all my time assessing the implications of and merging in other people’s cool changes — I just want to hack around and have fun. ūüôā

That’s it. Expect another post from me around the 22nd November.

HTM Light: A HTML generator

I’ve been looking for a clean, simple, readable HTML generator library (for any common server-side language) for perhaps a decade now. There are certainly lots of useful libraries around, and templating and MVC systems abound, but nothing quite appealed. I’ve also tried to create my own, but my efforts had always come unstuck, or otherwise I’ve focused on the big-ticket items (i.e. lists and data-tables). I think, though, I may finally have a solution I’m happy with, which should work reasonably well cross-language. Here’s a surprisingly succinct Python version with no dependencies, which I’m calling HTM Light (dedicated to public domain):

HTM Light

class node(object):
    # 'c' is for content
    def __init__(self, tagName, c=None, **attrs):
        self.tagName = tagName
        self.content = c if c else []
        self.attrs = attrs

    def escape(self, s):
        return str(s).replace('&', '&amp;').replace('<', '&lt;') \
            .replace('>', '&gt;').replace('"', '&quot;')

    def __str__(self):
        s = "<"+self.tagName

        # Handle attributes
        for k,v in self.attrs.items():
            s += " " + k + '="'+self.escape(v)+'" ';
        s += ">"

        # Handle content
        for el in self.content:
            s += str(el)

        s += "</"+self.tagName+">"

        return s

Continue reading ‘HTM Light: A HTML generator’ »