def test_prev_state_methods(self):
        ## 1) Build dataset
        ## ================================================
        X, y = datasets.make_classification(n_samples=5,
                                            n_features=20,
                                            n_informative=2)
        Xy = {"X": X, "y": y}
        methods = Methods(*[TOY_CLF(v_lambda=v_lambda)
                            for v_lambda in [2, 1]])
        methods.run(**Xy)

        ps_methods = WarmStartMethods(*[TOY_CLF(v_lambda=v_lambda)
                                        for v_lambda in [2, 1]])
        ps_methods.run(**Xy)
        self.assertTrue(compare_two_node(methods, ps_methods))
        self.assertTrue(comp_2wf_reduce_res(methods, ps_methods))
    def test_prev_state_methods(self):
        ## 1) Build dataset
        ## ================================================
        X, y = datasets.make_classification(n_samples=5,
                                            n_features=20,
                                            n_informative=2)
        Xy = {"X": X, "y": y}
        methods = Methods(*[TOY_CLF(v_lambda=v_lambda)
                            for v_lambda in [2, 1]])
        methods.run(**Xy)

        ps_methods = WarmStartMethods(*[TOY_CLF(v_lambda=v_lambda)
                                        for v_lambda in [2, 1]])
        ps_methods.run(**Xy)
        self.assertTrue(compare_two_node(methods, ps_methods))
        self.assertTrue(comp_2wf_reduce_res(methods, ps_methods))
Exemple #3
0
    ## 1) Build dataset
    ## ================================================
    X, y = datasets.make_classification(n_samples=10,
                                        n_features=5,
                                        n_informative=2,
                                        random_state=1)
    Xy = {"X": X, "y": y}

    ## 2) Build Methods
    ## ================================================
    print("Methods ===================================")
    methods = Methods(*[TOY_CLF(v_lambda=v_lambda) for v_lambda in [2, 1]])
    print(methods.run(**Xy))

    ## 3) Build WarmStartMethods like Methods
    ## ================================================
    ##               WarmStartMethods
    ##             /                  \
    ##  TOY_CLF(v_lambda=2)    TOY_CLF(v_lambda=1)
    ##
    ##  1. WarmStartMethods will look for different argumenets as signature
    ##     For example, here is v_lambda, there are different for each leaf
    ##  2. And then run TOY_CLF(v_lambda=2).transform
    ##  3. Except v_lambda, WarmStartMethods copy all the other parameters
    ##     from TOY_CLF(v_lambda=2) to TOY_CLF(v_lambda=1) as initialization
    ##  4. Finally call TOY_CLF(v_lambda=1).transform
    print("WarmStartMethods ==========================")
    ps_methods = WarmStartMethods(
        *[TOY_CLF(v_lambda=v_lambda) for v_lambda in [2, 1]])
    print(ps_methods.run(**Xy))
    ## ================================================
    X, y = datasets.make_classification(n_samples=10,
                                        n_features=5,
                                        n_informative=2,
                                        random_state=1)
    Xy = {"X": X, "y": y}

    ## 2) Build Methods
    ## ================================================
    print "Methods ==================================="
    methods = Methods(*[TOY_CLF(v_lambda=v_lambda)
                        for v_lambda in [2, 1]])
    print methods.run(**Xy)

    ## 3) Build WarmStartMethods like Methods
    ## ================================================
    ##               WarmStartMethods
    ##             /                  \
    ##  TOY_CLF(v_lambda=2)    TOY_CLF(v_lambda=1)
    ##
    ##  1. WarmStartMethods will look for different argumenets as signature
    ##     For example, here is v_lambda, there are different for each leaf
    ##  2. And then run TOY_CLF(v_lambda=2).transform
    ##  3. Except v_lambda, WarmStartMethods copy all the other parameters
    ##     from TOY_CLF(v_lambda=2) to TOY_CLF(v_lambda=1) as initialization
    ##  4. Finally call TOY_CLF(v_lambda=1).transform
    print "WarmStartMethods =========================="
    ps_methods = WarmStartMethods(*[TOY_CLF(v_lambda=v_lambda)
                                    for v_lambda in [2, 1]])
    print ps_methods.run(**Xy)