-- | /O(m)/ where /m/ is the number of feature values. Computes the
-- frequency of the given label from the given conditional prob. table.
labelCount :: Num n => CPT -> String -> n
labelCount cpt c = sum $ map fromIntegral (M.elems (cpt M.! c))

-- | /O(l m)/ Calculate the number of training instances from a CPT.
dataLength :: Num n => CPT -> n
dataLength = fromIntegral . sum . map (sum . M.elems) . M.elems