MUSH - Manual model construction
MUSH - Analysis of the UCI Machine Learning Repository Mushroom Data Set/Manual model construction
There are some rules for poisonous mushrooms from most general to most specific:
P_1) odor=NOT(almond.OR.anise.OR.none)
120 poisonous cases missed, 98.52% accuracy
P_2) spore-print-color=green
48 cases missed, 99.41% accuracy
P_3) odor=none.AND.stalk-surface-below-ring=scaly.AND.
(stalk-color-above-ring=NOT.brown)
8 cases missed, 99.90% accuracy
P_4) habitat=leaves.AND.cap-color=white
100% accuracy
Rule P_4) may also be
P_4') population=clustered.AND.cap_color=white
The following script creates a fud of transforms for each of these rules and writes them to MUSH_model_manual.json,
from MUSHDev import *
aa = mushaa(open('./agaricus-lepiota.data', 'r').readlines())
uu = sys(aa)
vv = uvars(uu)
vvl = sset([VarStr("edible")])
vvk = vv - vvl
wwc = cart(uu,sset([VarStr("odor")]))
wwi = sset([llss([(VarStr("odor"),ValStr(u))]) for u in ["creosote","fishy","foul","musty","pungent","spicy"]])
w = VarStr("p1")
aao = unit(sset([llss([(w,ValInt(0))])]))
aai = unit(sset([llss([(w,ValInt(1))])]))
tt1 = trans(add(mul(unit(wwc-wwi),aao),mul(unit(wwi),aai)),sset([w]))
wwc = cart(uu,sset([VarStr("spore-print-color")]))
wwi = sset([llss([(VarStr("spore-print-color"),ValStr(u))]) for u in ["green"]])
w = VarStr("p2")
aao = unit(sset([llss([(w,ValInt(0))])]))
aai = unit(sset([llss([(w,ValInt(1))])]))
tt2 = trans(add(mul(unit(wwc-wwi),aao),mul(unit(wwi),aai)),sset([w]))
wwc = cart(uu,sset([VarStr("odor"),VarStr("stalk-surface-below-ring"),VarStr("stalk-color-above-ring")]))
wwi = sset([llss([(VarStr("odor"), ValStr("none")), (VarStr("stalk-surface-below-ring"), ValStr("scaly")), (VarStr("stalk-color-above-ring"), ValStr(u))]) for u in ["buff","cinnamon","gray","orange","pink","red","white","yellow"]])
w = VarStr("p3")
aao = unit(sset([llss([(w,ValInt(0))])]))
aai = unit(sset([llss([(w,ValInt(1))])]))
tt3 = trans(add(mul(unit(wwc-wwi),aao),mul(unit(wwi),aai)),sset([w]))
wwc = cart(uu,sset([VarStr("habitat"), VarStr("cap-color")]))
wwi = sset([llss([(VarStr("habitat"), ValStr("leaves")), (VarStr("cap-color"), ValStr("white"))])])
w = VarStr("p4")
aao = unit(sset([llss([(w,ValInt(0))])]))
aai = unit(sset([llss([(w,ValInt(1))])]))
tt4 = trans(add(mul(unit(wwc-wwi),aao),mul(unit(wwi),aai)),sset([w]))
wwc = cart(uu,sset([VarStr("population"), VarStr("cap-color")]))
wwi = sset([llss([(VarStr("population"), ValStr("clustered")), (VarStr("cap-color"), ValStr("white"))])])
w = VarStr("p4a")
aao = unit(sset([llss([(w,ValInt(0))])]))
aai = unit(sset([llss([(w,ValInt(1))])]))
tt4a = trans(add(mul(unit(wwc-wwi),aao),mul(unit(wwi),aai)),sset([w]))
ggm = qqff(sset([tt1,tt2,tt3,tt4]))
open("MUSH_model_manual.json","w").write(fudPersistentsEncode(fudsPersistent(ggm)))