How to use the suod.models.parallel_processes._parallel_predict function in suod

To help you get started, we’ve selected a few suod examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yzhao062 / SUOD / examples / temp_do_not_use.py View on Github external
print('Orig Fit time:', time.time() - start)
    print()

    all_results = list(map(list, zip(*all_results)))
    trained_estimators = _unfold_parallel(all_results[0], n_jobs)
    jl_transformers = _unfold_parallel(all_results[1], n_jobs)

    ##########################################################################
    start = time.time()
    n_estimators = len(base_estimators)
    n_estimators_list, starts, n_jobs = _partition_estimators(n_estimators,
                                                              n_jobs)
    # model prediction
    all_results_pred = Parallel(n_jobs=n_jobs, max_nbytes=None,
                                verbose=True)(
        delayed(_parallel_predict)(
            n_estimators_list[i],
            trained_estimators[starts[i]:starts[i + 1]],
            None,
            X_test,
            n_estimators,
            # rp_flags[starts[i]:starts[i + 1]],
            jl_transformers,
            approx_flags[starts[i]:starts[i + 1]],
            contamination,
            verbose=True)
        for i in range(n_jobs))

    print('Orig Predict time:', time.time() - start)
    print()

    # unfold and generate the label matrix
github yzhao062 / SUOD / examples / demo_full.py View on Github external
print('Orig Fit time:', time.time() - start)
    print()

    all_results = list(map(list, zip(*all_results)))
    trained_estimators = _unfold_parallel(all_results[0], n_jobs)
    jl_transformers = _unfold_parallel(all_results[1], n_jobs)

    ##########################################################################
    start = time.time()
    n_estimators = len(base_estimators)
    n_estimators_list, starts, n_jobs = _partition_estimators(n_estimators,
                                                              n_jobs)
    # model prediction
    all_results_pred = Parallel(n_jobs=n_jobs, max_nbytes=None,
                                verbose=True)(
        delayed(_parallel_predict)(
            n_estimators_list[i],
            trained_estimators[starts[i]:starts[i + 1]],
            None,
            X_test,
            n_estimators,
            jl_transformers,
            approx_flags[starts[i]:starts[i + 1]],
            contamination,
            verbose=True)
        for i in range(n_jobs))

    print('Orig Predict time:', time.time() - start)
    print()

    # unfold and generate the label matrix
    predicted_labels_orig = np.zeros([X_test.shape[0], n_estimators])
github yzhao062 / SUOD / suod / models / base.py View on Github external
else:
            # use simple equal split by sklearn
            n_estimators_list, starts, n_jobs = _partition_estimators(
                self.n_estimators, self.n_jobs)

        # fit the base models
        if self.verbose:
            print('Parallel label prediction...')
            start = time.time()

        # TODO: code cleanup. There is an existing bug for joblib on Windows:
        # https://github.com/joblib/joblib/issues/806
        # max_nbytes can be dropped on other OS
        all_results_pred = Parallel(n_jobs=n_jobs, max_nbytes=None,
                                    verbose=True)(
            delayed(_parallel_predict)(
                n_estimators_list[i],
                self.base_estimators[starts[i]:starts[i + 1]],
                self.approximators[starts[i]:starts[i + 1]],
                X,
                self.n_estimators,
                # self.rp_flags[starts[i]:starts[i + 1]],
                self.jl_transformers_[starts[i]:starts[i + 1]],
                self.approx_flags[starts[i]:starts[i + 1]],
                self.contamination,
                verbose=True)
            for i in range(n_jobs))

        if self.verbose:
            print('Parallel Label Predicting without Approximators '
                  'Total Time:', time.time() - start)
github yzhao062 / SUOD / examples / do_not_use_demo_full.py View on Github external
#     delayed(_parallel_predict)(
#         n_estimators_list[i],
#         trained_estimators[starts[i]:starts[i + 1]],
#         approximators[starts[i]:starts[i + 1]],
#         X,
#         n_estimators,
#         rp_flags[starts[i]:starts[i + 1]],
#         jl_transformers[starts[i]:starts[i + 1]],
#         approx_flags[starts[i]:starts[i + 1]],
#         contamination,
#         verbose=True)
#     for i in range(n_jobs))

all_results_pred = Parallel(n_jobs=n_jobs, max_nbytes=None,
                            verbose=True)(
    delayed(_parallel_predict)(
        n_estimators_list[i],
        trained_estimators[starts[i]:starts[i + 1]],
        approximators[starts[i]:starts[i + 1]],
        X,
        n_estimators,
        rp_flags[starts[i]:starts[i + 1]],
        jl_transformers[starts[i]:starts[i + 1]],
        approx_flags[starts[i]:starts[i + 1]],
        contamination,
        verbose=True)
    for i in range(n_jobs))

# unfold and generate the label matrix
predicted_labels = np.zeros([X.shape[0], n_estimators])
for i in range(n_jobs):
    predicted_labels[:, starts[i]:starts[i + 1]] = np.asarray(
github yzhao062 / SUOD / examples / temp_do_not_use_work_w_minist.py View on Github external
verbose=True)
        for i in range(n_jobs))

    print('Orig Fit time:', time.time() - start)
    print()

    all_results = list(map(list, zip(*all_results)))
    trained_estimators = _unfold_parallel(all_results[0], n_jobs)
    jl_transformers = _unfold_parallel(all_results[1], n_jobs)

    ##########################################################################
    start = time.time()
    # model prediction
    all_results_pred = Parallel(n_jobs=n_jobs, max_nbytes=None,
                                verbose=True)(
        delayed(_parallel_predict)(
            n_estimators_list[i],
            trained_estimators[starts[i]:starts[i + 1]],
            None,
            X,
            n_estimators,
            rp_flags[starts[i]:starts[i + 1]],
            jl_transformers,
            approx_flags[starts[i]:starts[i + 1]],
            contamination,
            verbose=True)
        for i in range(n_jobs))

    print('Orig Predict time:', time.time() - start)
    print()

    # unfold and generate the label matrix