當前位置: 首頁>>代碼示例>>Java>>正文


Java EntropyLDiversity類代碼示例

本文整理匯總了Java中org.deidentifier.arx.criteria.EntropyLDiversity的典型用法代碼示例。如果您正苦於以下問題:Java EntropyLDiversity類的具體用法?Java EntropyLDiversity怎麽用?Java EntropyLDiversity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntropyLDiversity類屬於org.deidentifier.arx.criteria包,在下文中一共展示了EntropyLDiversity類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.deidentifier.arx.criteria.EntropyLDiversity; //導入依賴的package包/類
/**
 * Entry point.
 *
 * @param args the arguments
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    
    Data data = createData("adult");
    data.getDefinition().setAttributeType("occupation", AttributeType.SENSITIVE_ATTRIBUTE);
    
    ARXAnonymizer anonymizer = new ARXAnonymizer();
    ARXConfiguration config = ARXConfiguration.create();
    config.addPrivacyModel(new EntropyLDiversity("occupation", 5));
    config.setMaxOutliers(0.04d);
    config.setQualityModel(Metric.createEntropyMetric());
    
    // Anonymize
    ARXResult result = anonymizer.anonymize(data, config);
    printResult(result, data);
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:22,代碼來源:Example22.java

示例2: cases

import org.deidentifier.arx.criteria.EntropyLDiversity; //導入依賴的package包/類
/**
 * Returns the test cases.
 *
 * @return
 */
@Parameters(name = "{index}:[{0}]")
public static Collection<Object[]> cases() {
    return Arrays.asList(new Object[][] { /* 0 */{ new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createPrecomputedEntropyMetric(0.1d, false)).addPrivacyModel(new EntropyLDiversity("occupation", 5, EntropyEstimator.GRASSBERGER)), "occupation", "./data/adult.csv", 216092.124036387, new int[]{ 1, 0, 1, 0, 3, 2, 2, 0 }, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createPrecomputedEntropyMetric(0.1d, false)).addPrivacyModel(new EntropyLDiversity("occupation", 100, EntropyEstimator.SHANNON)), "occupation", "./data/adult.csv", 0.0d, null, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.0d, Metric.createPrecomputedEntropyMetric(0.1d, false)).addPrivacyModel(new EntropyLDiversity("occupation", 5, EntropyEstimator.GRASSBERGER)), "occupation", "./data/adult.csv", 324620.5269918692, new int[]{ 1, 1, 1, 1, 3, 2, 2, 1 }, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.05d, Metric.createPrecomputedEntropyMetric(0.1d, false)).addPrivacyModel(new EntropyLDiversity("occupation", 3, EntropyEstimator.GRASSBERGER)), "occupation", "./data/adult.csv", 180347.4325366015, new int[]{ 0, 0, 1, 1, 2, 2, 2, 0 }, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createPrecomputedEntropyMetric(0.1d, false)).addPrivacyModel(new EntropyLDiversity("occupation", 5, EntropyEstimator.SHANNON)), "occupation", "./data/adult.csv", 228878.2039109517, new int[]{ 1, 0, 1, 1, 2, 2, 2, 1 }, true) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.1d, Metric.createPrecomputedEntropyMetric(0.1d, false)).addPrivacyModel(new EntropyLDiversity("occupation", 100, EntropyEstimator.GRASSBERGER)), "occupation", "./data/adult.csv", 0.0d, null, true) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createDiscernabilityMetric(true)).addPrivacyModel(new EntropyLDiversity("RAMNTALL", 5, EntropyEstimator.GRASSBERGER)), "RAMNTALL", "./data/cup.csv", 1833435.0, new int[]{ 4, 0, 1, 0, 1, 3, 1 }, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.03d, Metric.createDiscernabilityMetric(true)).addPrivacyModel(new EntropyLDiversity("RAMNTALL", 100, EntropyEstimator.GRASSBERGER)), "RAMNTALL", "./data/cup.csv", 4.5168281E7, new int[]{ 4, 4, 0, 0, 1, 3, 1 }, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.0d, Metric.createDiscernabilityMetric(true)).addPrivacyModel(new EntropyLDiversity("RAMNTALL", 5)), "RAMNTALL", "./data/cup.csv", 3.01506905E8, new int[]{ 4, 4, 1, 1, 1, 4, 4 }, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.0d, Metric.createDiscernabilityMetric(true)).addPrivacyModel(new EntropyLDiversity("RAMNTALL", 3)), "RAMNTALL", "./data/cup.csv", 9.2264547E7, new int[]{ 4, 4, 1, 0, 1, 4, 4 }, false) },
                                          /* 10 */{ new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createDiscernabilityMetric(true)).addPrivacyModel(new EntropyLDiversity("RAMNTALL", 5, EntropyEstimator.SHANNON)), "RAMNTALL", "./data/cup.csv", 2823649.0, new int[]{ 4, 0, 0, 1, 1, 3, 1 }, true) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.1d, Metric.createDiscernabilityMetric(true)).addPrivacyModel(new EntropyLDiversity("RAMNTALL", 100, EntropyEstimator.GRASSBERGER)), "RAMNTALL", "./data/cup.csv", 3.4459973E7, new int[]{ 5, 0, 0, 2, 1, 2, 1 }, true) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createPrecomputedEntropyMetric(0.1d, true)).addPrivacyModel(new EntropyLDiversity("EDUC", 5, EntropyEstimator.GRASSBERGER)), "EDUC", "./data/ihis.csv", 7735322.29514608, new int[]{ 0, 0, 0, 1, 3, 0, 0, 1 }, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createPrecomputedEntropyMetric(0.1d, true)).addPrivacyModel(new EntropyLDiversity("EDUC", 2, EntropyEstimator.GRASSBERGER)), "EDUC", "./data/ihis.csv", 5428093.534997522, new int[]{ 0, 0, 0, 0, 2, 0, 0, 1 }, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.0d, Metric.createPrecomputedEntropyMetric(0.1d, true)).addPrivacyModel(new EntropyLDiversity("EDUC", 5, EntropyEstimator.SHANNON)), "EDUC", "./data/ihis.csv", 1.2258628558792587E7, new int[]{ 0, 0, 0, 3, 3, 2, 0, 1 }, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.0d, Metric.createPrecomputedEntropyMetric(0.1d, true)).addPrivacyModel(new EntropyLDiversity("EDUC", 100, EntropyEstimator.GRASSBERGER)), "EDUC", "./data/ihis.csv", 0.0d, null, false) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createPrecomputedEntropyMetric(0.1d, true)).addPrivacyModel(new EntropyLDiversity("EDUC", 5, EntropyEstimator.GRASSBERGER)), "EDUC", "./data/ihis.csv", 7735322.29514608, new int[]{ 0, 0, 0, 1, 3, 0, 0, 1 }, true) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.02d, Metric.createPrecomputedEntropyMetric(0.1d, true)).addPrivacyModel(new EntropyLDiversity("EDUC", 3, EntropyEstimator.SHANNON)), "EDUC", "./data/ihis.csv", 7578152.206004559, new int[]{ 0, 0, 0, 2, 2, 0, 0, 1 }, true) },
    });
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:28,代碼來源:TestAnonymizationEntropyLDiversity.java

示例3: cases

import org.deidentifier.arx.criteria.EntropyLDiversity; //導入依賴的package包/類
/**
 * Returns the test cases.
 * 
 * @return
 * @throws IOException
 */
@Parameters(name = "{index}:[{0}]")
public static Collection<Object[]> cases() throws IOException {
    return Arrays.asList(new Object[][] {
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new EntropyLDiversity("occupation", 5)), "./data/adult.csv", "occupation", -998962150) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new DistinctLDiversity("Highest level of school completed", 5)), "./data/atus.csv", "Highest level of school completed", 1662433089) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new RecursiveCLDiversity("Highest level of school completed", 4d, 3)), "./data/atus.csv", "Highest level of school completed", 1141779920) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new EqualDistanceTCloseness("occupation", 0.2d)).addPrivacyModel(new KAnonymity(5)), "./data/adult.csv", "occupation", 464405537) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new EqualDistanceTCloseness("occupation", 0.2d)).addPrivacyModel(new KAnonymity(100)), "./data/adult.csv", "occupation", -1306447515) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new KAnonymity(100)), "./data/adult.csv", "occupation", 484469846) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new KAnonymity(5)), "./data/adult.csv", "occupation", -1231665634) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new KMap(3, 0.01d, ARXPopulationModel.create(Region.USA), CellSizeEstimator.ZERO_TRUNCATED_POISSON)), "./data/adult.csv", "occupation", -715168499) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new KMap(1000, 0.01d, ARXPopulationModel.create(Region.USA), CellSizeEstimator.ZERO_TRUNCATED_POISSON)), "./data/adult.csv", "occupation", 2130163653) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new EDDifferentialPrivacy(1.0d, 1E-6d, DataGeneralizationScheme.create(GeneralizationDegree.MEDIUM_HIGH), true)), "./data/fars.csv", "", 482534106) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(1d, Metric.createLossMetric(0.05d)).addPrivacyModel(new DPresence(0.0, 0.2, DataSubset.create(Data.create("./data/fars.csv", StandardCharsets.UTF_8, ';'), Data.create("./data/fars_subset.csv", StandardCharsets.UTF_8, ';')))), "./data/fars.csv", "istatenum", 505248650) },
                                          
    });
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:24,代碼來源:TestAnonymizationLocalRecoding.java

示例4: getCriterion

import org.deidentifier.arx.criteria.EntropyLDiversity; //導入依賴的package包/類
@Override
public PrivacyCriterion getCriterion(Model model) {
    switch (variant) {
    case VARIANT_DISTINCT:
        return new DistinctLDiversity(getAttribute(), l);
    case VARIANT_SHANNON_ENTROPY:
        return new EntropyLDiversity(getAttribute(), l);
    case VARIANT_RECURSIVE:
        return new RecursiveCLDiversity(getAttribute(), c, l);
    case VARIANT_GRASSBERGER_ENTROPY:
        return new EntropyLDiversity(getAttribute(), l, EntropyEstimator.GRASSBERGER);
    default:
        throw new RuntimeException(Resources.getMessage("Model.0e")); //$NON-NLS-1$
    }
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:16,代碼來源:ModelLDiversityCriterion.java

示例5: testLDiversityEntropyWithoutOutliers

import org.deidentifier.arx.criteria.EntropyLDiversity; //導入依賴的package包/類
/**
 * Performs a test
 *
 * @throws IOException
 */
@Test
public void testLDiversityEntropyWithoutOutliers() throws IOException {
    
    provider.createDataDefinition();
    final Data data = provider.getData();
    data.getDefinition().setAttributeType("age", AttributeType.SENSITIVE_ATTRIBUTE);
    
    final ARXAnonymizer anonymizer = new ARXAnonymizer();
    final ARXConfiguration config = ARXConfiguration.create();
    config.addPrivacyModel(new EntropyLDiversity("age", 2));
    config.setMaxOutliers(0d);
    final String[][] result = resultToArray(anonymizer.anonymize(data, config));
    
    // TODO: check if result is correct!
    final String[][] expected = {
                                  { "age", "gender", "zipcode" },
                                  { "34", "male", "81***" },
                                  { "45", "female", "81***" },
                                  { "66", "male", "81***" },
                                  { "70", "female", "81***" },
                                  { "34", "female", "81***" },
                                  { "70", "male", "81***" },
                                  { "45", "male", "81***" } };
                                  
    assertTrue(Arrays.deepEquals(result, expected));
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:32,代碼來源:TestAnonymization.java

示例6: cases

import org.deidentifier.arx.criteria.EntropyLDiversity; //導入依賴的package包/類
/**
 * Returns test cases
 * @return
 * @throws IOException
 */
@Parameters(name = "{index}:[{0}]")
public static Collection<Object[]> cases() throws IOException {
    return Arrays.asList(new Object[][] {
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createEntropyMetric(false)).addPrivacyModel(new EntropyLDiversity("occupation", 5)), "occupation", "./data/adult.csv", 228878.2039109517, new int[] { 1, 0, 1, 1, 2, 2, 2, 1 }, false, new int[] { 4320, 2326, 397, 3407, 0, 0, 397 }) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createEntropyMetric(false)).addPrivacyModel(new RecursiveCLDiversity("Highest level of school completed", 4d, 5)), "Highest level of school completed", "./data/atus.csv", 3536911.5162082445, new int[] { 0, 4, 0, 0, 2, 0, 1, 2 }, true, new int[] { 8748, 150, 78, 72, 684, 7914, 78 }) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createEntropyMetric(false)).addPrivacyModel(new KAnonymity(100)), "./data/cup.csv", 1994002.8308631124, new int[] { 3, 4, 1, 1, 0, 4, 4, 4 }, false, new int[] { 45000, 2041, 2733, 41577, 0, 0, 1809 }) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.05d, Metric.createEntropyMetric(false)).addPrivacyModel(new DPresence(0.0, 0.2, DataSubset.create(Data.create("./data/cup.csv", StandardCharsets.UTF_8, ';'), Data.create("./data/cup_subset.csv", StandardCharsets.UTF_8, ';')))), "RAMNTALL", "./data/cup.csv", 128068.07605943311, new int[] { 2, 4, 1, 1, 0, 3, 4 }, false, new int[] { 9000, 8992, 1862, 7130, 0, 0, 1862 }) },
                                          { new ARXAnonymizationTestCase(ARXConfiguration.create(0.04d, Metric.createEntropyMetric(false)).addPrivacyModel(new EqualDistanceTCloseness("EDUC", 0.2d)).addPrivacyModel(new KAnonymity(5)), "EDUC", "./data/ihis.csv", "1.4719292081181683E7", new int[] { 0, 0, 0, 3, 4, 2, 0, 1 }, true, new int[] { 12960, 28, 6, 22, 102, 12830, 6 }) },
    });
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:16,代碼來源:TestSolutionSpaceClassification2.java


注:本文中的org.deidentifier.arx.criteria.EntropyLDiversity類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。