for att in range(max_attempts):
            for index_grado_privacy in range(len(grado_privacy_list)):
                grado_privacy = grado_privacy_list[index_grado_privacy]

                df.compute_band_matrix(dim_finale=dim_finale,
                                       nome_file_item=listaItem,
                                       num_sensibile=num_sensibile,
                                       plot=False)
                dataframe_bandizzato = df.dataframe_bandizzato.copy()
                for index_r in range(len(r_list)):
                    print(
                        "%.2f |File : %s | Index privacy : %s | Attempt : %s | Index R: %s"
                        % (time.time() - big_ben, index_nameFile,
                           index_grado_privacy, att, index_r))
                    r = r_list[index_r]
                    cahd = CAHDalgorithm.CAHDalgorithm(
                        df, grado_privacy=grado_privacy, alfa=alpha)
                    cahd.compute_hist()
                    hist_item = cahd.hist
                    if cahd.CAHD_algorithm(analysis=True, plot=False):
                        if cahd.lista_gruppi is not None:
                            QID = cahd.lista_gruppi[0].columns.tolist()
                            KL_Divergence = 0
                            for kl_attempt in range(kl_attempts):
                                QID_select = list()
                                while len(QID_select) < r and len(
                                        QID_select) < len(QID):
                                    temp = random.choice(QID)
                                    if temp not in QID_select:
                                        QID_select.append(temp)
                                all_value = KLDivergence.get_all_combination_of_n(
                                    r)
Ejemplo n.º 2
0
                while len(QID_select) < r:
                    temp = random.choice(QID)
                    if temp not in QID_select:
                        QID_select.append(temp)
                QID_list_to_select.append(QID_select)

            KLs = list()
            time_list = list()
            q_time_list = list()
            exit_list = list()

            for iii in range(q_value_attempts):
                start_time = time.time()
                q_value = np.random.uniform(min_q, max_q)
                cahd = CAHDalgorithm.CAHDalgorithm(df,
                                                   grado_privacy=grado_privacy,
                                                   alfa=alpha,
                                                   q_value=q_value)
                cahd.compute_hist()
                hist_item = cahd.hist
                if cahd.CAHD_algorithm(analysis=True, plot=False):
                    end_time_1 = time.time() - start_time
                    KL_Divergence = 0
                    for ii in range(kl_attempts):
                        all_value = KLDivergence.get_all_combination_of_n(r)
                        # get max value of sensibile data
                        item_sensibile = int(
                            max(hist_item.keys(),
                                key=(lambda k: hist_item[k])))
                        QID_select = QID_list_to_select[ii]
                        for valori in all_value:
                            actsc = KLDivergence.compute_act_s_in_c(