BAYESOL(1)

๐Ÿ“ฆ
version 1.14 ยท 2 versions
, in nixos 26.05

๐Ÿ’… BAYESOL(1) โ€” a Bayes solution calculator for use with dbacl

okay bestie, welcome to bayesol, one of the Bayesian Classification Tools, and honestly? she's a whole vibe. get comfy, we're learning how to make optimal decisions with math. ๐Ÿงšโœจ


โœจ SYNOPSIS โœจ

bayesol [-DVNniv] -c riskspec [FILE]...

bayesol -V

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So. bayesol is a Bayes solution calculator. Her whole job is iconic: she takes the output of dbacl(1), smooshes it together with a prior distribution and a risk specification, and then calculates the optimal Bayesian decision โ€” which is the decision that minimizes the posterior risk. no cap, that's the entire personality. ๐Ÿ’…

The risk specification gets read from the text file riskspec, and it has to be written in a simple little format described further down (don't worry, we'll get there). And the dbacl(1) output? You can feed it in from FILE, or just pipe it from STDIN. either one, queen's choice. ๐ŸŽ€


๐Ÿ”ฅ EXIT STATUS ๐Ÿ”ฅ

On success, bayesol returns a positive integer corresponding to the category with the lowest risk. periodt. ๐Ÿ’–

In case of a problem, bayesol returns zero. (yes that's the sad trombone outcome, we don't love her but we respect her.)


๐Ÿ‘‘ OPTIONS ๐Ÿ‘‘

  • -c โ€” classify using riskspec. see the RISK SPECIFICATION section below, that's where the lore lives. ๐Ÿ“–
  • -i โ€” fully internationalized mode. this forces the use of wide characters internally, which is necessary in some locales. the catch? it incurs a noticeable performance penalty. so it's giving "correct but slower" energy. ๐ŸŒ
  • -n โ€” print risk scores for each category. each score is (approximately) the logarithm of the expected risk under that category. the lowest score (ie closest to -infinity) is best, etc. โœจ
  • -N โ€” print recursive risk scores for each category. each score is (approximately) the logarithm of the best score based on the remaining categories, after the previously best scoring categories have been removed, and a normalizing factor was added. a full description is given in the technical report listed at the end of this manpange. the largest score (ie closest to +infinity) is best, etc. ๐ŸŒ€
  • -v โ€” verbose mode. prints to STDOUT the category with minimum posterior risk. in case several categories are possible, prints the first category in the order in which they appear in the categories section of riskpspec. ๐Ÿ—ฃ๏ธ
  • -D โ€” print debug output. do not use. ๐Ÿ’€ (she said what she said.)
  • -V โ€” print the program version number and exit. short and sweet, we stan. ๐Ÿซถ

๐ŸŒธ RISK SPECIFICATION ๐ŸŒธ

bayesol needs to read a text file riskspec containing a risk specification. the format of this text file is as follows:

categories { cat1, cat2,..., catN}
prior { p1, p2,..., pN}
loss_matrix {
"regex1" c1 [ formula11, formula12,..., formula1N]
"regex2" c2 [ formula21, formula22,..., formula2N]
 .
 .
"regexM" cM [ formulaM1, formulaM2,..., formulaMN]
}

okay so breaking that down, in the above: cat1, cat2,..., catN are category names. p1, p2,..., pN are non-negative numbers. regex1, regex2,..., regexM are (possibly empty) regular expression strings. c1, c2,..., cM are instances of the category names cat1, cat2,..., catN. and the formulas are numbers or mathematical expressions. ๐Ÿงฎ

Every category which appears in the categories section must appear at least once in the loss_matrix section, with an empty "" regular expression. (this is not optional, bestie, it's the rules.) ๐Ÿ“

To construct the actual loss matrix used in the decision calculations, bayesol selects, for each category appearing in the categories section, the first row whose regular expression is matched within FILE or STDIN, or the first row with empty regular expression if there are no matches. ๐ŸŽฏ

Each formula can be either a single number, or an algebraic combination of the operators exp(), log(), +, -, *, /, ^ and parentheses (). the string "inf" is parsed as the value infinity. also, the string "complexity" is recognized, and converted to the complexity for that category as reported by dbacl(1). finally, if the corresponding regular expression contains submatches delimited by parentheses, their numerical values can be used inside the formulas as the special variables $1, ..., $9. note that submatches which aren't numerical are converted to the value zero. ๐Ÿช„

Case is important. spaces and newlines can be liberally inserted. comments must start with a # and extend to the end of the line. (yes, liberal spacing, conservative casing โ€” she contains multitudes. ๐Ÿ’œ)


๐ŸŒˆ USAGE ๐ŸŒˆ

Typically, bayesol is used together with dbacl(1). an invocation looks like this:

% dbacl -c one -c two -c three sample.txt -vna | bayesol -c toy.risk -v

look at that pipe. beautiful. no notes. ๐Ÿ˜ญ๐Ÿ”ฅ

See /nix/store/66jnbrh6haa7grpxg320a4fvkal7irv3-dbacl-1.14/share/dbacl/doc/costs.ps for a description of the algorithm used. see also /nix/store/66jnbrh6haa7grpxg320a4fvkal7irv3-dbacl-1.14/share/dbacl/doc/tutorial.html for a more detailed overview. ๐Ÿ“š


โญ SOURCE โญ

the source code for the latest version of this program is available at the following locations:

http://www.lbreyer.com/gpl.html
http://dbacl.sourceforge.net

go off, open source legend. ๐ŸŒ


๐ŸŽ€ AUTHOR ๐ŸŽ€

Laird A. Breyer <laird@lbreyer.com>


๐Ÿซถ SEE ALSO ๐Ÿซถ

dbacl(1), mailcross(1), mailfoot(1), mailinspect(1), mailtoe(1), regex(7)


that's the whole page, bestie โ€” go forth and minimize that posterior risk ๐Ÿ’–โœจ

sign-off szn: this was Version 1.14 of the page, from Bayesian Classification Tools, and it's BAYESOL(1) all the way down. mwah. ๐Ÿ’‹

๐Ÿ“ฆ where this page comes from