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


Java ObjectDoubleOpenHashMap类代码示例

本文整理汇总了Java中com.carrotsearch.hppc.ObjectDoubleOpenHashMap的典型用法代码示例。如果您正苦于以下问题:Java ObjectDoubleOpenHashMap类的具体用法?Java ObjectDoubleOpenHashMap怎么用?Java ObjectDoubleOpenHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getFitness

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
/**
 * Computes min squared error
 * 
 * @param expression
 *            Expression
 * @param graphVectors
 *            Values for given graphs
 * @return Fitness of expression
 */
public double getFitness(Expression expression, ObjectDoubleOpenHashMap<String>[] graphVectors) {
    double values[] = new double[graphVectors.length];
    for (int i = 0; i < graphVectors.length; i++) {
        values[i] = Math.abs(expression.getValue(graphVectors[i]));
    }

    double max = getMax(values);
    double fitness = 0d;
    for (int i = 0; i < values.length - 1; i++) {
        for (int j = i + 1; j < values.length; j++) {
            fitness = fitness + Math.pow(values[i] - values[j], 2);
        }
    }
    if (fitness == 0) {
        return 1;
    }
    fitness = fitness / (max * max); // norm to 1
    fitness = 2 * fitness / (values.length * (values.length - 1)); // compute
                                                                   // average
    return (1d - fitness);
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:31,代码来源:MinSquaredError.java

示例2: getValue

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
@Override
public double getValue(ObjectDoubleOpenHashMap<String> graphMetrics) {
    double leftValue = left.getValue(graphMetrics);
    double rightValue = right.getValue(graphMetrics);
    switch (operation) {
    case DIV:
        return leftValue / rightValue;
    case MINUS:
        return leftValue - rightValue;
    case PLUS:
        return leftValue + rightValue;
    case TIMES:
        return leftValue * rightValue;
    default:
        return Double.NaN;
    }
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:18,代码来源:Operation.java

示例3: test

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
@Test
public void test() {
    Model model = ModelFactory.createDefaultModel();
    InputStream is = this.getClass().getClassLoader().getResourceAsStream(GRAPH_FILE);
    model.read(is, null, "N3");
    IOUtils.closeQuietly(is);

    GraphCreator creator = new GraphCreator();
    ColouredGraph graph = creator.processModel(model);

    EdgeColourDistributionMetric metric = new EdgeColourDistributionMetric();
    ObjectDistribution<BitSet> distribution = metric.apply(graph);

    ObjectDoubleOpenHashMap<BitSet> expectedCounts = new ObjectDoubleOpenHashMap<BitSet>();
    ColourPalette palette = graph.getEdgePalette();
    for (int i = 0; i < EXPECTED_PROPERTY_URIS.length; ++i) {
        expectedCounts.put(palette.getColour(EXPECTED_PROPERTY_URIS[i]), EXPECTED_PROPERTY_COUNTS[i]);
    }

    for (int i = 0; i < distribution.sampleSpace.length; ++i) {
        Assert.assertTrue(expectedCounts.containsKey(distribution.sampleSpace[i]));
        Assert.assertEquals(expectedCounts.get(distribution.sampleSpace[i]), distribution.values[i]);
    }
    Assert.assertEquals(expectedCounts.size(), distribution.sampleSpace.length);
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:26,代码来源:EdgeColourDistributionMetricTest.java

示例4: propagateTopicWeight

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
/** Propagate a topic weight to a node and all its children.
	weight is assumed to be a log.
*/
   public void propagateTopicWeight(ObjectDoubleOpenHashMap<NCRPNode> nodeWeights,
								 NCRPNode node, double weight) {
	if (! nodeWeights.containsKey(node)) {
		// calculating the NCRP prior proceeds from the
		//  root down (ie following child links),
		//  but adding the word-topic weights comes from
		//  the bottom up, following parent links and then 
		//  child links. It's possible that the leaf node may have
		//  been removed just prior to this round, so the current
		//  node may not have an NCRP weight. If so, it's not 
		//  going to be sampled anyway, so ditch it.
		return;
	}

	for (NCRPNode child: node.children) {
		propagateTopicWeight(nodeWeights, child, weight);
	}

	nodeWeights.addTo(node, weight);
   }
 
开发者ID:cmoen,项目名称:mallet,代码行数:24,代码来源:HierarchicalLDA.java

示例5: argmax

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
/** Returns the key in map that has the greatest score */
public static Object argmax (ObjectDoubleOpenHashMap map)
{
  // A local class! Yes, Virginia, this is legal Java.
  class Accumulator implements ObjectDoubleProcedure {
    double bestVal = Double.NEGATIVE_INFINITY;
    Object bestObj = null;
    public void apply (Object a, double b)
    {
      if (b > bestVal) {
        bestVal = b;
        bestObj = a;
      }
    }
  }

  Accumulator procedure = new Accumulator ();
    map.forEach(procedure);
  return procedure.bestObj;
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:21,代码来源:CollectionUtils.java

示例6: printGraphMetrics

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
private String printGraphMetrics(ObjectDoubleOpenHashMap<String>[] graphVectors) {
    StringBuilder builder = new StringBuilder();
    builder.append("Metric");
    for (int i = 0; i < graphVectors.length; ++i) {
        builder.append("\tgraph");
        builder.append(i);
    }
    builder.append('\n');
    String key;
    for (int i = 0; i < graphVectors[0].allocated.length; ++i) {
        if (graphVectors[0].allocated[i]) {
            key = (String) ((Object[]) graphVectors[0].keys)[i];
            builder.append(key);
            builder.append('\t');
            builder.append(Double.toString(graphVectors[0].values[i]));
            for (int j = 1; j < graphVectors.length; ++j) {
                builder.append('\t');
                if (graphVectors[j].containsKey(key)) {
                    builder.append(Double.toString(graphVectors[j].get(key)));
                } else {
                    builder.append('?');
                }
            }
            builder.append('\n');
        }
    }
    return builder.toString();
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:29,代码来源:CharacteristicExpressionSearcher.java

示例7: getFitness

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
@Override
public double getFitness(Expression expression, ObjectDoubleOpenHashMap<String>[] graphVectors) {
    double fitness = decorated.getFitness(expression, graphVectors);
    double comparedFitness = fitness / decorated.getFitness(expression, referenceGraphVectors);
    return (2 * fitness * comparedFitness) / (fitness + comparedFitness);
    // return comparedFitness;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:8,代码来源:ReferenceGraphBasedFitnessDecorator.java

示例8: getValue

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
@Override
public double getValue(ObjectDoubleOpenHashMap<String> graphMetrics) {
    if (graphMetrics.containsKey(metric.getName())) {
        return graphMetrics.get(metric.getName());
    } else {
        // this is an error.
        return Double.NaN;
    }
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:10,代码来源:AtomicVariable.java

示例9: test

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
@Test
public void test() {
    Model model = ModelFactory.createDefaultModel();
    InputStream is = this.getClass().getClassLoader().getResourceAsStream(GRAPH_FILE);
    model.read(is, null, "N3");
    IOUtils.closeQuietly(is);

    GraphCreator creator = new GraphCreator();
    ColouredGraph graph = creator.processModel(model);

    VertexColourDistributionMetric metric = new VertexColourDistributionMetric();
    ObjectDistribution<BitSet> distribution = metric.apply(graph);

    ObjectDoubleOpenHashMap<BitSet> expectedCounts = new ObjectDoubleOpenHashMap<BitSet>();
    ColourPalette palette = graph.getVertexPalette();
    BitSet colour;
    for (int i = 0; i < EXPECTED_VERTEX_CLASSES.length; ++i) {
        if (EXPECTED_VERTEX_CLASSES[i].contains("|")) {
            colour = palette.getColourMixture(EXPECTED_VERTEX_CLASSES[i].split("\\|"));
        } else {
            colour = palette.getColour(EXPECTED_VERTEX_CLASSES[i]);
        }
        Assert.assertTrue("There is no colour for " + EXPECTED_VERTEX_CLASSES[i], colour.cardinality() > 0);
        expectedCounts.put(colour, EXPECTED_VERTEX_COUNTS[i]);
    }
    expectedCounts.put(new BitSet(), EXPECTED_VERTEXES_WITHOUT_COLOURS);

    for (int i = 0; i < distribution.sampleSpace.length; ++i) {
        Assert.assertTrue(expectedCounts.containsKey(distribution.sampleSpace[i]));
        Assert.assertEquals(expectedCounts.get(distribution.sampleSpace[i]), distribution.values[i]);
    }
    Assert.assertEquals(expectedCounts.size(), distribution.sampleSpace.length);
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:34,代码来源:VertexColourDistributionMetricTest.java

示例10: calculateMarginals

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
public Marginals calculateMarginals() {
  ObjectDoubleOpenHashMap<String> x = ObjectDoubleOpenHashMap.newInstance();
  ObjectDoubleOpenHashMap<String> y = ObjectDoubleOpenHashMap.newInstance();
  double sum = 0;
  for (Table.Cell<String, String, Double> cell : xyProb.cellSet()) {
    x.putOrAdd(cell.getRowKey(), cell.getValue(), cell.getValue());
    y.putOrAdd(cell.getColumnKey(), cell.getValue(), cell.getValue());
    sum += cell.getValue();
  }
  return new Marginals(x, y, sum);
}
 
开发者ID:steveash,项目名称:jg2p,代码行数:12,代码来源:ProbTable.java

示例11: calculateNCRP

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
public void calculateNCRP(ObjectDoubleOpenHashMap<NCRPNode> nodeWeights, 
					  NCRPNode node, double weight) {
for (NCRPNode child: node.children) {
	calculateNCRP(nodeWeights, child,
				  weight + Math.log((double) child.customers / (node.customers + gamma)));
}

nodeWeights.put(node, weight + Math.log(gamma / (node.customers + gamma)));
  }
 
开发者ID:cmoen,项目名称:mallet,代码行数:10,代码来源:HierarchicalLDA.java

示例12: ReferenceGraphBasedFitnessDecorator

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
public ReferenceGraphBasedFitnessDecorator(FitnessFunction decorated,
        ObjectDoubleOpenHashMap<String>[] referenceGraphVectors) {
    this.decorated = decorated;
    this.referenceGraphVectors = referenceGraphVectors;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:6,代码来源:ReferenceGraphBasedFitnessDecorator.java

示例13: getFitness

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
public double getFitness(Expression expression, ObjectDoubleOpenHashMap<String>[] graphVectors) {
    double value = super.getFitness(expression, graphVectors);
    return value - expression.getSize() * FACTOR;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:5,代码来源:LengthAwareMinSquaredError.java

示例14: getValue

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
@Override
public double getValue(ObjectDoubleOpenHashMap<String> graphMetrics) {
    return constantValue;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:5,代码来源:Constant.java

示例15: createReferenceGraphVectors

import com.carrotsearch.hppc.ObjectDoubleOpenHashMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static ObjectDoubleOpenHashMap<String>[] createReferenceGraphVectors(ColouredGraph[] graphs,
        List<SingleValueMetric> metrics) {
    Grph temp;
    int numberOfNodes, partSize;
    List<ObjectDoubleOpenHashMap<String>> vectors = new ArrayList<ObjectDoubleOpenHashMap<String>>(
            5 * graphs.length);
    for (int i = 0; i < graphs.length; ++i) {
        numberOfNodes = graphs[i].getGraph().getNumberOfVertices();
        LOGGER.info("Generating reference graphs with " + numberOfNodes + " nodes.");
        // Star
        StarTopologyGenerator starGenerator = new StarTopologyGenerator();
        temp = new InMemoryGrph();
        temp.addNVertices(numberOfNodes);
        starGenerator.compute(temp);
        vectors.add(MetricUtils.calculateGraphMetrics(new ColouredGraph(temp, null, null), metrics));
        temp = null;

        // Grid
        partSize = (int) Math.sqrt(numberOfNodes);
        MetricUtils.calculateGraphMetrics(new ColouredGraph(ClassicalGraphs.grid(partSize, partSize), null, null),
                metrics);

        // Ring
        vectors.add(MetricUtils.calculateGraphMetrics(
                new ColouredGraph(ClassicalGraphs.cycle(numberOfNodes), null, null), metrics));

        // Clique
        // vectors.add(MetricUtils.calculateGraphMetrics(
        // new ColouredGraph(ClassicalGraphs.completeGraph(numberOfNodes),
        // null, null), metrics));
        vectors.add(MetricUtils.calculateGraphMetrics(
                new ColouredGraph(ClassicalGraphs.completeGraph(partSize), null, null), metrics));

        // Bipartite
        // partSize = numberOfNodes / 2;
        partSize = numberOfNodes / 8;
        vectors.add(MetricUtils.calculateGraphMetrics(
                new ColouredGraph(ClassicalGraphs.completeBipartiteGraph(partSize, partSize), null, null),
                metrics));
    }
    return vectors.toArray(new ObjectDoubleOpenHashMap[vectors.size()]);
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:44,代码来源:RefinementTest.java


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