def test_dependent_variable_properties_as_members_for_continous_node(): """ Tests that node prints the std and mean when contonuous column supplied """ data = np.array([1.3, 23.0, 3.0, 3.0, 12.4]) continuous_dp = CHAID.ContinuousColumn(data) node = CHAID.Node(dep_v=continuous_dp) assert node.members == {'mean': data.mean(), 's.t.d': data.std()}
def setUp(self): invalid_split = CHAID.Split(None, None, 0, 1, 0) self.tree = CHAID.Tree.from_numpy(np.array([[1]]), np.array([1])) self.tree._tree_store = [ CHAID.Node(node_id=0, split=CHAID.Split('a', [[1], [2]], 1, 0.2, 2)), CHAID.Node(node_id=1, split=invalid_split, choices=[1], parent=0), CHAID.Node(node_id=2, split=CHAID.Split('c', [[3]], 1, 0.2, 2), choices=[2], parent=0) ] self.last_node = CHAID.Node(node_id=3, split=invalid_split, choices=[3], parent=2) self.tree._tree_store.append(self.last_node)
def test_node_should_have_a_score(): """ Tests that node uses the split score and is called 'score' """ data = np.array([1.3, 23.0, 3.0, 3.0, 12.4]) continuous_dp = CHAID.ContinuousColumn(data) split = CHAID.Split("a", [], 2, 3, 4) node = CHAID.Node(dep_v=continuous_dp, split=split) assert node.score == 2