本文整理汇总了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);
}
示例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) },
});
}
示例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) },
});
}
示例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$
}
}
示例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));
}
示例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 }) },
});
}