Ejemplo n.º 1
0
 def setUp(self):
     self.X = format_covariate_matrix(pd.DataFrame({"a": [1, 2, 3, 4, 5]}))
     self.raw_y = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
     self.data = Data(format_covariate_matrix(self.X),
                      self.raw_y,
                      normalize=True)
     normalizing_scale = self.data.y.normalizing_scale
     self.model = Model(self.data,
                        Sigma(0.001,
                              0.001,
                              scaling_factor=normalizing_scale),
                        n_trees=2,
                        initializer=None)
     self.model.initialize_trees()
Ejemplo n.º 2
0
 def setUp(self):
     self.data = Data(format_covariate_matrix(pd.DataFrame({"a": [1]})),
                      np.array([1]).astype(float))
     self.d = LeafNode(Split(self.data), None)
     self.e = LeafNode(Split(self.data), None)
     self.c = DecisionNode(Split(self.data), self.d, self.e)
     self.b = LeafNode(Split(self.data))
     self.a = DecisionNode(Split(self.data), self.b, self.c)
     self.tree = Tree([self.a, self.b, self.c, self.d, self.e])
Ejemplo n.º 3
0
 def setUp(self):
     self.y = np.array([1, 2, 3, 4, 5])
     self.X = pd.DataFrame({
         "a": [1, 2, 3, 4, 5],
         "b": [1, 1, 1, 1, 1],
         "c": [1, 2, 3, 3, 4]
     })
     self.X = format_covariate_matrix(self.X)
     self.data = Data(self.X, self.y, normalize=True)
Ejemplo n.º 4
0
    def setUp(self):
        X = format_covariate_matrix(
            pd.DataFrame({
                "a": [1, 2, 3],
                "b": [1, 2, 3]
            }))
        self.data = Data(X, np.array([1, 2, 3]).astype(float))

        self.a = split_node(LeafNode(Split(
            self.data)), (SplitCondition(0, 1, le), SplitCondition(0, 1, gt)))
        self.b = self.a.left_child
        self.x = self.a.right_child
        self.tree = Tree([self.a, self.b, self.x])

        self.c = split_node(
            self.a._right_child,
            (SplitCondition(1, 2, le), SplitCondition(1, 2, gt)))
        mutate(self.tree, TreeMutation("grow", self.x, self.c))

        self.d = self.c.left_child
        self.e = self.c.right_child
Ejemplo n.º 5
0
 def setUp(self):
     self.X = format_covariate_matrix(pd.DataFrame({"a": [1, 2, 3, 4, 5]}))
     self.data = Data(format_covariate_matrix(self.X),
                      np.array([1.0, 2.0, 3.0, 4.0, 5.0]))
     self.split = Split(self.data)
     self.node = LeafNode(self.split)
Ejemplo n.º 6
0
 def setUp(self):
     self.X = format_covariate_matrix(pd.DataFrame({"a": [1]}))
     self.data = Data(format_covariate_matrix(self.X), np.array([1.0]))
Ejemplo n.º 7
0
 def setUp(self):
     self.X = pd.DataFrame({"a": [1, 2, 3, 4, 5], "b": [1, 1, 1, 1, 1], "c": [1, 2, 3, 3, 4]})
     self.X = format_covariate_matrix(self.X)
     self.X = CovariateMatrix(self.X, mask=np.zeros(5).astype(bool), n_obsv=5, unique_columns=None, splittable_variables=None)