How to use the suod.models.parallel_processes.clf_idx_mapping 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 / suod / models / random_projection.py View on Github external
def build_rp_codes(n_estimators, base_estimators, rp_clf_list, rp_ng_clf_list,
                   proj_enabled):
    base_estimator_names = []
    rp_flag = np.zeros([n_estimators, 1], dtype=int)

    for i in range(n_estimators):

        try:
            clf_name = type(base_estimators[i]).__name__

        except TypeError:
            print('Unknown detection algorithm.')
            clf_name = 'UNK'

        if clf_name not in list(clf_idx_mapping):
            # print(clf_name)
            clf_name = 'UNK'
        # build the estimator list
        base_estimator_names.append(clf_name)

        # check whether the projection is needed
        if clf_name in rp_clf_list:
            rp_flag[i] = 1
        elif clf_name in rp_ng_clf_list:
            continue
        else:
            warnings.warn(
                "{clf_name} does not have a predefined projection code. "
                "RP disabled.".format(clf_name=clf_name))

    if not proj_enabled: