Skip to content

burn/old-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TREE

Tree learner via recursive random projections

tree.lua

What Notes
XY:new(s:str, n:num, nlo:num, nhi:num) ⇒ XY count the y values from xlo to xhi
XY:__tostring() ⇒ str print
XY:add(nx:num, sy:str, n:num?) ⇒ nil n[=1] times,count sy. Expand to cover nx
XY:merge(xy:XY) ⇒ XY combine two items (assumes both from same column)
XY:simpler(xy:XY, nMin:num) ⇒ XY if whole simpler than parts, return merged self+xy
SYM:discretize(s:str) ⇒ s discretizing a symbol just returns that symbol
NUM:discretize(n:num) ⇒ num discretize Nums,rounded to (hi-lo)/bins
DATA:better(row1, row2) ⇒ bool returns true if row1's goals better than row2
DATA:clone( init?) ⇒ data return a table with the same structure

glua.lua

Some general LUA functions. (c)2022 Tim Menzies [email protected] BSD-2 license

Linting

What Notes
it.rogues() ⇒ nil report rogue locals

Maths

Random number generator

The LUA doco says its random number generator is not stable across platforms. Hence, we use our own (using Park-Miller).

What Notes
it.srand(n:num) ⇒ nil reset random number seed (defaults to 937162211)
it.rand(nlo:num, nhi:num) ⇒ num return float from nlo..nhi (default 0..1)
it.rint(nlo:num, nhi:num) ⇒ int returns integer from nlo..nhi (default 0..1)

Lists

What Notes
it.any(t:tab) ⇒ any return any item from t, picked at random
it.many(t:tab, n:num) ⇒ t return n items from t, picked at random
it.per(t:tab, p) ⇒ num return the pth(=.5) item of sorted list t
it.ent(t:tab) ⇒ num entropy
it.kap(t:tab, fun:fun) ⇒ t map function fun(k,v) over list (skip nil results)
it.keys(t:tab) ⇒ t sort+return t's keys (ignore things with leading _)
it.map(t:tab, fun:fun) ⇒ t map function fun(v) over list (skip nil results)
it.push(t:tab, x) ⇒ any push x to end of list; return x
it.sd(t:tab) ⇒ num sorted list standard deviation= (90-10)th percentile/2.58
it.slice(t:tab, go, stop:str, inc) ⇒ t return t from go(=1) to stop(=#t), by inc(=1)

Sorting Lists

What Notes
it.gt(s:str) ⇒ fun return a function that sorts ascending on `s'.
it.lt(s:str) ⇒ fun return a function that sorts descending on s.
it.sort(t:tab, fun:fun) ⇒ t return t, sorted by fun (default= <)

Coercion

Strings to Things

What Notes
it.coerce(s:str) ⇒ any return int or float or bool or string from s
it.options(s:str) ⇒ t parse help string to extract a table of options
it.csv(sFilename:str, fun:fun) ⇒ nil call fun on rows (after coercing cell text)

Things to Strings

What Notes
it.fmt(sControl:str, ...) ⇒ str emulate printf
it.oo(t:tab) ⇒ nil print t's string (the one generated by o)
it.o(t:tab, seen:str?) ⇒ str table to string (recursive)

Objects

What Notes
it.obj(s:str) ⇒ t create a klass and a constructor + print method

Test suite support

What Notes
it.cli(t:tab) ⇒ t alters contents of options in t from the command-line
it.run(funs:[fun], t:tab) ⇒ nfails runs all funs (or t.go), resetting options & seed before each

That's all folks.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published