当前位置: 首页>>代码示例>>Java>>正文


Java DataHandle.getValue方法代码示例

本文整理汇总了Java中org.deidentifier.arx.DataHandle.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java DataHandle.getValue方法的具体用法?Java DataHandle.getValue怎么用?Java DataHandle.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.deidentifier.arx.DataHandle的用法示例。


在下文中一共展示了DataHandle.getValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInputFrequencies

import org.deidentifier.arx.DataHandle; //导入方法依赖的package包/类
/**
 * Returns the frequencies of values in input data for all rows with transformation level >= level
 * @param transformations
 * @param column
 * @param level
 * @return
 */
private Map<String, Double> getInputFrequencies( int[] transformations, int column, int level) {
    DataHandle input = getInput();
    Map<String, Double> result = new HashMap<String, Double>();
    for (int row = 0; row < input.getNumRows(); row++) {
        if (transformations[row] >= level) {
            String value = input.getValue(row, column);
            Double count = result.get(value);
            result.put(value, count != null ? count + 1d : 1d);
        }

        // Check
        checkInterrupt();
    }
    return result;
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:23,代码来源:QualityModelColumnOrientedNonUniformEntropy.java

示例2: getDataValue

import org.deidentifier.arx.DataHandle; //导入方法依赖的package包/类
@Override
public Object getDataValue(int arg0, int arg1) {
    DataHandle data = context.getHandle();
    if (data == null) { return null; }
    RowSet rows = context.getRows();
    if (rows == null) {
        return data.getValue(arg1, arg0);
    } else if (arg0 == 0) {
        // Remap row index for subset if in subset view
        if (data instanceof DataHandleSubset){
            int[] subset = ((DataHandleSubset)data).getSubset();
            arg1 = subset[arg1];
        }
        return rows.contains(arg1);
    } else {
        return data.getValue(arg1, arg0 - 1);
    }
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:19,代码来源:DataTableHandleDataProvider.java

示例3: getNumbersFromNumericColumn

import org.deidentifier.arx.DataHandle; //导入方法依赖的package包/类
/**
 * Parses numbers from a numeric column
 * @param handle
 * @param column
 * @return
 */
private double[] getNumbersFromNumericColumn(DataHandle handle, int column) {
    
    try {
        
        // Prepare
        String attribute = handle.getAttributeName(column);
        double[] result = new double[handle.getNumRows()];
        
        // Parse numbers
        if (handle.getDataType(attribute) instanceof DataTypeWithRatioScale) {

            QualityConfigurationValueParser<?> parser = QualityConfigurationValueParser.create(handle.getDataType(attribute));
            for (int row = 0; row < handle.getNumRows(); row++) {
                String value = handle.getValue(row, column);
                if (handle.isOutlier(row) || super.isSuppressed(column, value)) {
                    result[row] = Double.NaN;
                } else {
                    result[row] = parser.getDouble(value);
                }
                
                // Check
                checkInterrupt();
            }
            
            // Return
            return result;
        } else {
            
            // Return
            return null;
        }
    } catch (Exception e) {
        
        // Fail silently
        return null;
    }
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:44,代码来源:QualityModelColumnOrientedMSE.java

示例4: TupleWrapper

import org.deidentifier.arx.DataHandle; //导入方法依赖的package包/类
/**
 * Constructor
 * 
 * @param handle
 * @param row
 */
public TupleWrapper(DataHandle handle, int[] indices, int row) {
    this.values = new String[indices.length];
    int hashcode = 1;
    int idx = 0;
    for (int index : indices) {
        String value = handle.getValue(row, index);
        hashcode = 31 * hashcode + value.hashCode();
        values[idx++] = value;
    }
    this.hashcode = hashcode;
    this.suppressed = handle.isOutlier(row);
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:19,代码来源:TupleWrapper.java

示例5: testMultipleDataHandlesNoForkOrphaned

import org.deidentifier.arx.DataHandle; //导入方法依赖的package包/类
/**
 * Test case
 *
 * @throws IllegalArgumentException
 * @throws IOException
 */
@Test
public void testMultipleDataHandlesNoForkOrphaned() throws IllegalArgumentException, IOException {
    
    provider.createDataDefinition();
    final ARXAnonymizer anonymizer = new ARXAnonymizer();
    final ARXConfiguration config = ARXConfiguration.create();
    config.addPrivacyModel(new KAnonymity(2));
    config.setMaxOutliers(0d);
    
    final ARXResult result = anonymizer.anonymize(provider.getData(), config);
    
    // get top and bottom node
    ARXLattice lattice = result.getLattice();
    ARXNode topNode = lattice.getTop();
    ARXNode bottomNode = lattice.getBottom();
    
    // get various handle copies
    @SuppressWarnings("unused")
    DataHandle optimal = result.getOutput();
    
    DataHandle top = result.getOutput(topNode, false);
    @SuppressWarnings("unused")
    DataHandle bottom = result.getOutput(bottomNode, false);
    
    try {
        top.getValue(0, 0);
    } catch (RuntimeException e) {
        if (e.getMessage().contains("orphaned")) {
            return;
        }
    }
    Assert.fail();
    
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:41,代码来源:TestDataHandle.java

示例6: main

import org.deidentifier.arx.DataHandle; //导入方法依赖的package包/类
/**
 * Entry point.
 * 
 * @param args
 *            the arguments
 */
public static void main(String[] args) throws IOException {

    // Define data
    DefaultData data = Data.create();
    data.add("age", "gender", "zipcode");
    data.add("34", "male", "81667");
    data.add("45", "female", "81675");
    data.add("66", "male", "81925");
    data.add("70", "female", "81931");
    data.add("34", "female", "81931");
    data.add("70", "male", "81931");
    data.add("45", "male", "81931");

    // Obtain a handle
    DataHandle inHandle = data.getHandle();

    // Read the encoded data
    inHandle.getNumRows();
    inHandle.getNumColumns();
    inHandle.getAttributeName(0);
    inHandle.getValue(0, 0);

    // Define hierarchy. Only excerpts for readability
    DefaultHierarchy zipcode = Hierarchy.create();
    zipcode.add("81667", "8166*", "816**", "81***", "8****", "*****");
    zipcode.add("81675", "8167*", "816**", "81***", "8****", "*****");
    zipcode.add("81925", "8192*", "819**", "81***", "8****", "*****");
    zipcode.add("81931", "8193*", "819**", "81***", "8****", "*****");

    // Create a data definition
    data.getDefinition()
        .setAttributeType("age", AttributeType.IDENTIFYING_ATTRIBUTE);
    data.getDefinition()
        .setAttributeType("gender", AttributeType.INSENSITIVE_ATTRIBUTE);
    data.getDefinition().setAttributeType("zipcode", zipcode);

    data.getDefinition().setDataType("zipcode", DataType.DECIMAL);

    // Create an instance of the anonymizer
    ARXAnonymizer anonymizer = new ARXAnonymizer();
    ARXConfiguration config = ARXConfiguration.create();
    config.addPrivacyModel(new KAnonymity(2));
    config.setMaxOutliers(0d);

    // Now anonymize the data utilizing the pre-encoded data
    ARXResult result = anonymizer.anonymize(data, config);

    // Obtain a handle for the transformed data
    DataHandle outHandle = result.getOutput(false);

    // Sort the data. This operation is implicitly performed on both
    // representations of the dataset.
    outHandle.sort(false, 2);

    // Print info
    printResult(result, data);

    // Process results
    System.out.println(" - Transformed data:");
    Iterator<String[]> transformed = result.getOutput(false).iterator();
    while (transformed.hasNext()) {
        System.out.print("   ");
        System.out.println(Arrays.toString(transformed.next()));
    }
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:72,代码来源:Example4.java

示例7: getRangeFromNumericColumn

import org.deidentifier.arx.DataHandle; //导入方法依赖的package包/类
/**
 * Tries to parse numbers from output when there is a numeric input column
 * @param inputNumbers
 * @param output
 * @param column
 * @return
 */
private double[] getRangeFromNumericColumn(double[] inputNumbers,
                                           DataHandle output,
                                           int column) {
    
    try {
        
        // Prepare
        String attribute = output.getAttributeName(column);
        double[] result = new double[output.getNumRows() * 2];
        double[] minmax = getMinMax(inputNumbers);
        double minimum = minmax[0];
        double maximum = minmax[1];
        
        // Create a sample of the data
        List<String> sample = new ArrayList<>();
        for (int row = 0; row < output.getNumRows() && sample.size() < 50; row++) {
            if (!output.isOutlier(row)) {
                sample.add(output.getValue(row, column));
            }
        }
        
        // Create parsers
        QualityConfigurationValueParser<?> valueParser = QualityConfigurationValueParser.create(output.getDataType(attribute));
        QualityConfigurationRangeParser rangeParser = QualityConfigurationRangeParser.getParser(valueParser, sample);
        
        // Parse
        for (int row = 0; row < output.getNumRows(); row++) {
            
            // Parse
            double[] range;
            if (output.isOutlier(row)) {
                range = new double[]{minimum, maximum};
            } else {
                String value = output.getValue(row, column);
                if (isSuppressed(column, value)) {
                    range = new double[]{minimum, maximum};    
                } else {
                    range = rangeParser.getRange(valueParser, value, minimum, maximum);
                }
            }
            
            result[row * 2] = range[0];
            result[row * 2 + 1] = range[1];
            
            // Check
            checkInterrupt();
        }
        
        // Return
        return result;
        
    } catch (Exception e) {
        
        // Fail silently
        return null;
    }
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:65,代码来源:QualityModelRowOrientedSSE.java

示例8: getMissings

import org.deidentifier.arx.DataHandle; //导入方法依赖的package包/类
/**
 * Returns the fraction of missing values
 * @param output
 * @param indices
 * @return
 */
private QualityMeasureColumnOriented getMissings(DataHandle output, int[] indices) {
    
    // Prepare
    double[] minimum = new double[indices.length];
    double[] result = new double[indices.length];
    double[] maximum = new double[indices.length];
    Arrays.fill(minimum, 0d);
    Arrays.fill(maximum, 1d);
    
    // Calculate
    for (int i = 0; i < indices.length; i++) {

        // Extract special label for missings from hierarchy
        int column = indices[i];
        String attribute = output.getAttributeName(column);
        String[][] hierarchy = output.getDefinition().getHierarchy(attribute);
        Set<String> roots = new HashSet<>();
        for (String[] row : hierarchy) {
            roots.add(row[row.length - 1]);
        }
        String ROOT_VALUE = (roots.size() == 1) ? roots.iterator().next() : null;
        
        // Search for missings
        double missings = 0d;
        for (int row = 0; row < output.getNumRows(); row++) {
            
            // Suppressed record
            if (output.isOutlier(row)) {
                missings += 1d; 
            } else {
                
                // Suppressed value
                String value = output.getValue(row, column);
                if (value.equals(DataType.ANY_VALUE) ||
                    value.equals(DataType.NULL_VALUE) ||
                    value.equals(ROOT_VALUE)) {
                    missings += 1d;
                }
            }
            
            // Check
            checkInterrupt();
        } 
        missings /= (double)output.getNumRows();
        result[i] = 1d - missings;
    }

    // Return
    return new QualityMeasureColumnOriented(output, indices, minimum, result, maximum);
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:57,代码来源:StatisticsQuality.java


注:本文中的org.deidentifier.arx.DataHandle.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。