public class Ducks
extends java.lang.Object
(Naive-) Bayes
"
function-model
in
[the book].
Also see the
[home page].Modifier and Type | Field and Description |
---|---|
static Vector |
attributes
|
static UPFunctionModel |
bird_2_walk_N_talk
UnParameterised function-model of Species→Bool×Bool.
|
static Dependent |
bird_N_walk_N_talk
UnParameterised Model of Species×(Bool×Bool).
|
static Vector |
birds
|
static MultiState |
birdUPM
UnParameterised Model over
Species ={coot,duck,swan}. |
static NaiveBayes.M |
book_eg
The particular Naive Bayes function-model used as
an example in the book.
|
static MultiState |
boolUPM
|
static Value |
coot
coot, duck, swan :
Species . |
static Vector |
ds
A toy data-set from which to estimate a function-model.
|
static Value |
duck
coot, duck, swan :
Species . |
static NaiveBayes.M |
estimated
A Naive Bayes function-model estimated from data-set
ds . |
static Value.Bool |
f
't' and 'f', short for
Value.ttrue and Value.ttrue . |
static Vector |
quacks
|
static Type.Enum |
Species
Species = coot | duck | swan.
|
static Value |
swan
coot, duck, swan :
Species . |
static Value.Bool |
t
't' and 'f', short for
Value.ttrue and Value.ttrue . |
static Vector |
waddles
|
static Independent |
walk_N_talk
UnParameterised Independent Model over Bool×Bool.
|
static NaiveBayes |
walk_N_talk_2_bird
new
NaiveBayes (bird_N_walk_N_talk ). |
static double[] |
weights
|
Constructor and Description |
---|
Ducks() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] argv)
Walk the walk and talk the talk.
|
public static Value.Bool t
Value.ttrue
and Value.ttrue
.public static Value.Bool f
Value.ttrue
and Value.ttrue
.public static Type.Enum Species
public static Vector birds
public static Vector waddles
public static Vector quacks
public static double[] weights
public static Vector attributes
public static Vector ds
attributes
.zip(birds
)).weight(weights
)
: 〈〈waddles?,quacks?〉,bird〉*,
note weighted by weights.public static MultiState boolUPM
public static MultiState birdUPM
Species
={coot,duck,swan}.public static Independent walk_N_talk
walk_N_talk
and
thence in bird_N_walk_N_talk
that makes walk_N_talk_2_bird
"Naive".public static UPFunctionModel bird_2_walk_N_talk
CPT
(triple(coot,swan,walk_N_talk
)).public static Dependent bird_N_walk_N_talk
Species
and the attributes
"walks" and "talks" (like a duck).
It is made from birdUPM
and bird_2_walk_N_talk
.
Note that the attribute-pair is Dependent on Species but
each attribute is Independent of the other.public static NaiveBayes walk_N_talk_2_bird
NaiveBayes
(bird_N_walk_N_talk
).
That is, an UnParameterised "NaiveBayes" function-model of
(Bool×Bool)→Species
. The story is that
walk_N_talk_2_bird is made from bird_N_walk_N_talk
which is made from birdUPM
and bird_2_walk_N_talk
.
The latter is made from walk_N_talk
and walking and
talking (like a duck) are modelled as Independent
but nothing actually requires this — apart from naivety.public static NaiveBayes.M book_eg
public static NaiveBayes.M estimated
ds
.
walk_N_talk_2_bird
.estimator(...).apply(ds
)
is similar to book_eg
but not quite identical.
(The estimator's parameters are
〈triv,〈triv,triv〉〉,
the first triv is for birdUPM
's estimator and
〈triv,triv〉 is for the pair of boolUPM
estimators inside walk_N_talk
.)