Tabnine Logo
Tuple
Code IndexAdd Tabnine to your IDE (free)

How to use
Tuple
in
de.jungblut.math.tuple

Best Java code snippets using de.jungblut.math.tuple.Tuple (Showing top 18 results out of 315)

origin: de.jungblut.common/thomasjungblut-common

  @Override
  public CostGradientTuple call() throws Exception {
    return evaluateBatch(parameters, featureOutcome.getFirst(),
        featureOutcome.getSecond());
  }
}
origin: de.jungblut.common/thomasjungblut-common

/**
 * Consumes the next entries from a parallel interator.
 *
 * @param it  the left iterator.
 * @param it2 the right iterator.
 * @return a tuple. This tuple can have either of its two entries as NULL once
 * the end of one iterator has been reached. If both iterators are at
 * their end it simply returns null.
 */
public static <K, V> Tuple<K, V> consumeNext(final Iterator<K> it,
                       final Iterator<V> it2) {
  K nextK = null;
  V nextV = null;
  if (it.hasNext()) {
    nextK = it.next();
  }
  if (it2.hasNext()) {
    nextV = it2.next();
  }
  if (nextK == null && nextV == null) {
    return null;
  } else {
    return new Tuple<>(nextK, nextV);
  }
}
origin: de.jungblut.math/tjungblut-math

@SuppressWarnings("unchecked")
@Override
public int compareTo(Tuple<FIRST, SECOND> o) {
 if (o.getFirst() instanceof Comparable && getFirst() instanceof Comparable) {
  return ((Comparable<FIRST>) getFirst()).compareTo(o.getFirst());
 } else {
  return 0;
 }
}
origin: de.jungblut.jrpt/jrpt

@Override
public void constructWithPayload(Stream<Tuple<DoubleVector, VALUE>> pairs) {
 pairs.forEach((v) -> add(v.getFirst(), v.getSecond()));
}
origin: de.jungblut.common/thomasjungblut-common

@Override
public void train(Iterable<DoubleVector> features,
         Iterable<DoubleVector> outcome) {
  // zip the streams and construct the kd tree
  Stream<Tuple<DoubleVector, DoubleVector>> stream = StreamUtils.zip(
      StreamSupport.stream(features.spliterator(), false),
      StreamSupport.stream(outcome.spliterator(), false),
      (l, r) -> new Tuple<>(l, r));
  tree.constructWithPayload(stream);
}
origin: de.jungblut.common/thomasjungblut-common

/**
 * Constructs the similarity aggregation by seed tokens to expand and a given
 * bipartite graph. The bipartite graph is represented as a three tuple, which
 * consists of the vertices (called (candidate-) terms or entities) on the
 * first item, the context vertices on the second item and the edges between
 * those is a NxM matrix, where n is the entity tokens count and m is the
 * number of the context vertices. Alpha is the constant weighting factor used
 * throughout the paper (usually 0.5). The distance measurer to be used must
 * be also defined.
 */
public IterativeSimilarityAggregation(String[] seedTokens,
                   Tuple<String[], DoubleMatrix> bipartiteGraph, double alpha,
                   DistanceMeasurer distance) {
  this.seedTokens = seedTokens;
  this.termNodes = bipartiteGraph.getFirst();
  // make sure we transpose to have a better distance lookup
  this.weightMatrix = bipartiteGraph.getSecond().transpose();
  this.alpha = alpha;
  this.similarityMeasurer = new SimilarityMeasurer(distance);
  init();
}
origin: de.jungblut.common/thomasjungblut-common

/**
 * Filters all examples where the feature at the given index has NOT the
 * specific value. So the returned lists contain only vectors where the
 * feature has the specific value.
 *
 * @return a new tuple of two new lists (features and their outcome).
 */
private Tuple<List<DoubleVector>, List<DoubleVector>> filterNominal(
    List<DoubleVector> features, List<DoubleVector> outcome,
    int bestSplitIndex, int nominalValue) {
  List<DoubleVector> newFeatures = Lists.newArrayList();
  List<DoubleVector> newOutcomes = Lists.newArrayList();
  Iterator<DoubleVector> featureIterator = features.iterator();
  Iterator<DoubleVector> outcomeIterator = outcome.iterator();
  while (featureIterator.hasNext()) {
    DoubleVector feature = featureIterator.next();
    DoubleVector out = outcomeIterator.next();
    if (((int) feature.get(bestSplitIndex)) == nominalValue) {
      newFeatures.add(feature);
      newOutcomes.add(out);
    }
  }
  return new Tuple<>(newFeatures, newOutcomes);
}
origin: de.jungblut.common/thomasjungblut-common

    featureIterator, outcomeIterator);
int numDistinctClasses = first.getSecond().getDimension();
    .getFirst().getDimension());
observe(first.getFirst(), first.getSecond(), numDistinctClasses,
    tokenPerClass, numDocumentsPerClass);
int numDocumentsSeen = 1;
while ((first = Iterables.consumeNext(featureIterator, outcomeIterator)) != null) {
  observe(first.getFirst(), first.getSecond(), numDistinctClasses,
      tokenPerClass, numDocumentsPerClass);
  numDocumentsSeen++;
origin: de.jungblut.common/thomasjungblut-common

return new Tuple<>(newFeatures, newOutcomes);
origin: de.jungblut.common/thomasjungblut-common

if (tuple != null) {
  if (tuple.getFirst() < globalCost) {
    globalCost = tuple.getFirst();
    globalBestPosition = tuple.getSecond();
origin: de.jungblut.common/thomasjungblut-common

return new Tuple<>(features, outcome);
origin: de.jungblut.common/thomasjungblut-common

  node.children[cIndex] = build(filtered.getFirst(),
      filtered.getSecond(), newPossibleFeatures, level + 1);
  cIndex++;
    bestSplit.getNumericalSplitValue(), false);
if (filterNumeric.getFirst().isEmpty()
    || filterNumericHigher.getFirst().isEmpty()) {
  newPossibleFeatures.remove(bestSplitIndex);
} else {
AbstractTreeNode lower = build(filterNumeric.getFirst(),
    filterNumeric.getSecond(), new TIntHashSet(newPossibleFeatures),
    level + 1);
AbstractTreeNode higher = build(filterNumericHigher.getFirst(),
    filterNumericHigher.getSecond(),
    new TIntHashSet(newPossibleFeatures), level + 1);
origin: de.jungblut.common/thomasjungblut-common

points.size()).mapToObj(i -> new Tuple<>(points.get(i), i));
origin: de.jungblut.common/thomasjungblut-common

values.size()).mapToObj(i -> new Tuple<>(values.get(i), i));
origin: de.jungblut.common/thomasjungblut-common

DoubleMatrix featuresWithBias = sparse ? new SparseDoubleRowMatrix(bias,
    featureMatrix) : new DenseDoubleMatrix(bias, featureMatrix);
batches.add(new Tuple<>(featuresWithBias, outcomeMat));
origin: de.jungblut.common/thomasjungblut-common

@Override
public Tuple<Double, DoubleVector> call() throws Exception {
  // loop over all particles and calculate new positions
  for (int particleIndex = range.getStart(); particleIndex < range.getEnd(); particleIndex++) {
    DoubleVector currentPosition = particlePositions[particleIndex];
    DoubleVector currentBest = particlePersonalBestPositions[particleIndex];
    DenseDoubleVector vec = new DenseDoubleVector(dim);
    for (int index = 0; index < vec.getDimension(); index++) {
      double value = (phi * currentPosition.get(index)) // inertia
          + (alpha * random.nextDouble() * (currentBest.get(index) - currentPosition
          .get(index))) // personal memory
          + (beta * random.nextDouble() * (globalBestPosition.get(index) - currentPosition
          .get(index))); // group memory
      vec.set(index, value);
    }
    particlePositions[particleIndex] = vec;
    double cost = f.evaluateCost(vec).getCost();
    // check if we have a personal best
    if (cost < particlePersonalBestCost[particleIndex]) {
      particlePersonalBestCost[particleIndex] = cost;
      particlePersonalBestPositions[particleIndex] = vec;
      // if we had a personal best, do we have a better global?
      if (cost < globalCost) {
        globalCost = cost;
        globalBestPosition = vec;
      }
    }
  }
  return new Tuple<>(globalCost, globalBestPosition);
}
origin: de.jungblut.common/thomasjungblut-common

return new Tuple<>(mean, stdVector);
origin: de.jungblut.common/thomasjungblut-common

return new Tuple<>(matrix, meanVector);
de.jungblut.math.tupleTuple

Javadoc

Tuple class to hold two generic attributes. This class implements hashcode, equals and comparable via the first element.

Most used methods

  • getFirst
  • getSecond
  • <init>

Popular in Java

  • Reactive rest calls using spring rest template
  • onRequestPermissionsResult (Fragment)
  • runOnUiThread (Activity)
  • setRequestProperty (URLConnection)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • BoxLayout (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now