Пример #1
0
    def run_test(cls, obj, model_type, verbose=False):
        if verbose:
            print("Calling fit with `model_type  = '%s'`..." % (model_type,), end="")
        sys.stdout.flush()

        with warnings.catch_warnings():
            warnings.filterwarnings("ignore",category=PendingDeprecationWarning)
            warnings.filterwarnings("ignore",category=LineSearchWarning)
            try:
                fit(
                    X=obj.X,
                    Y=obj.Y,
                    model_type=model_type,
                    treated_units=obj.treated_units
                    if model_type
                    in ("retrospective", "prospective", "prospective-restricted")
                    else None,
                    # KWARGS:
                    print_path=False,
                    progress=verbose,
                    grid_length=5,
                    min_iter=-1,
                    tol=1,
                    verbose=0,
                    batchFile=join(expanduser("~"),"temp","%s_batch_params.py" % model_type)
                )
                import pdb; pdb.set_trace()
                if verbose:
                    print("DONE")
            except LineSearchWarning:
                pass
            except PendingDeprecationWarning: 
                pass
            except Exception as exc:
                print("Failed with %s: %s" % (exc.__class__.__name__, exc.message))
Пример #2
0
    def run_test(cls, obj, model_type, verbose=False):
        if verbose:
            print("Calling fit with `model_type  = '%s'`..." % (model_type, ),
                  end="")
        sys.stdout.flush()

        with warnings.catch_warnings():
            warnings.filterwarnings("ignore",
                                    category=PendingDeprecationWarning)
            warnings.filterwarnings("ignore", category=LineSearchWarning)
            try:
                Model1 = fit(
                    features=obj.X,
                    targets=obj.Y,
                    model_type=model_type,
                    treated_units=obj.treated_units
                    if model_type in ("retrospective", "prospective",
                                      "prospective-restricted") else None,
                    # KWARGS:
                    print_path=False,
                    stopping_rule=1,
                    progress=verbose,
                    grid_length=5,
                    min_iter=-1,
                    tol=1,
                    verbose=0,
                )
                Model2 = fit(
                    features=obj.X,
                    targets=obj.Y,
                    model_type=model_type,
                    treated_units=obj.treated_units
                    if model_type in ("retrospective", "prospective",
                                      "prospective-restricted") else None,
                    # KWARGS:
                    print_path=False,
                    stopping_rule=1,
                    progress=verbose,
                    grid_length=5,
                    min_iter=-1,
                    tol=1,
                    verbose=0,
                    batch_client_config="sg_daemon",
                )
                if verbose:
                    print("DONE")
            except LineSearchWarning:
                pass
            except PendingDeprecationWarning:
                pass
            except Exception as exc:
                print("Failed with %s: %s" %
                      (exc.__class__.__name__, getattr(exc, "message", "<>")))
                raise exc
Пример #3
0
    def run_test(cls, obj, model_type, verbose=False):
        if verbose:
            print("Calling fit with `model_type  = '%s'`..." % (model_type,), end="")
        sys.stdout.flush()

        batchdir = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "data", "batchTest"
        )
        assert os.path.exists(batchdir), "Batch Directory '{}' does not exist".format(
            batchdir
        )

        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
            warnings.filterwarnings("ignore", category=LineSearchWarning)
            try:
                verbose = 0
                model_a = fit(
                    features=obj.X,
                    targets=obj.Y,
                    model_type=model_type,
                    treated_units=obj.treated_units
                    if model_type
                    in ("retrospective", "prospective", "prospective-restricted")
                    else None,
                    # KWARGS:
                    print_path=verbose,
                    stopping_rule=1,
                    progress=0,
                    grid_length=5,
                    min_iter=-1,
                    tol=1,
                    verbose=0,
                )

                model_b = aggregate_batch_results(
                    batchDir=batchdir
                )  # , batch_client_config="sg_daemon"

                assert np.all(
                    np.abs(model_a.scores - model_b.scores) < 1e-14
                ), "model scores are not within rounding error"

                if verbose:
                    print("DONE")
            except LineSearchWarning:
                pass
            except PendingDeprecationWarning:
                pass
            except Exception as exc:  # pylint: disable=broad-except
                print(
                    "Failed with %s(%s)"
                    % (exc.__class__.__name__, getattr(exc, "message", ""))
                )
                raise exc
Пример #4
0
    def run_test(cls, obj, model_type, verbose=False):
        if verbose:
            print("Calling fit with `model_type  = '%s'`..." % (model_type, ),
                  end="")
        sys.stdout.flush()

        batchdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                "data", "batchTest")
        print("dumping batch artifacts to: {}'".format(batchdir))

        with warnings.catch_warnings():
            warnings.filterwarnings("ignore",
                                    category=PendingDeprecationWarning)
            warnings.filterwarnings("ignore", category=LineSearchWarning)
            try:
                fit(
                    features=obj.X,
                    targets=obj.Y,
                    model_type=model_type,
                    treated_units=obj.treated_units
                    if model_type in ("retrospective", "prospective",
                                      "prospective-restricted") else None,
                    # KWARGS:
                    print_path=False,
                    stopping_rule=1,
                    progress=verbose,
                    grid_length=5,
                    min_iter=-1,
                    tol=1,
                    verbose=0,
                    batchDir=batchdir,
                )
                if verbose:
                    print("DONE")
            except LineSearchWarning:
                pass
            except PendingDeprecationWarning:
                pass
            except Exception as exc:  # pylint: disable=broad-except
                print("Failed with %s(%s)" %
                      (exc.__class__.__name__, getattr(exc, "message", "")))
                raise exc