def testing_Sym(): s1 = Sym() s1 = s1.syms( ['y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'n', 'n', 'n', 'n', 'n']) print(s1.symEnt()) result = round(s1.symEnt(), 4) assert (result == 0.9403)
def header(self,cells): self = self or Rows() self.indep = [] for c0,x in enumerate(cells): if not "?" in x: c = len(self._use) self._use.append(c0) self.name.append(x) if "$" in x or "<" in x or ">" in x: n1 = Num() self.nums[c] = n1.nums([]) else: s1 = Sym() self.syms[c] = s1.syms([]) if "<" in x: self.w[c] = -1 elif ">" in x: self.w[c] = 1 elif "!" in x: self._class = c else: self.indeps.append(c) return self
def baseSym(): s = Sym() s = s.syms( ['y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'n', 'n', 'n', 'n', 'n']) print(s.counts) print("Entropy: " + str(round(s.symEnt(), 4))) assert (round(s.symEnt(), 4) == 0.9403)
def sym_test(): """ Testing sym.py ... """ sym = Sym() sym_list = [ 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'n', 'n', 'n', 'n', 'n' ] sym.syms(sym_list) print() print('ENT', ':', sym.sym_ent()) print() assert (close(sym.sym_ent(), 0.9403))