This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void trainActual(Iterable<Pair<Text, VectorWritable>> inputIterable, String outBase, | |
| Map<String, Integer> clusterNamesToIds) throws IOException { | |
| Map<String, Centroid> actualClusters = Maps.newHashMap(); | |
| computeActualClusters(inputIterable, actualClusters); | |
| OnlineLogisticRegression learningAlgorithm = | |
| new OnlineLogisticRegression(NUM_CLASSES, NUM_FEATURES_ACTUAL, new L1()); | |
| for (Pair<Text, VectorWritable> pair : inputIterable) { | |
| Vector actualCentroid = pair.getSecond().get(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package syntax; | |
| import syntax.tree.SyntaxTreeNode; | |
| import syntax.tree.arithmetic.*; | |
| import syntax.tree.comparison.EqualityNode; | |
| import syntax.tree.comparison.IsVoidNode; | |
| import syntax.tree.comparison.LessOrEqualThanNode; | |
| import syntax.tree.comparison.LessThanNode; | |
| import syntax.tree.conditional.CaseNode; | |
| import syntax.tree.conditional.ConditionNode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library('gmp') | |
| primes <- data.frame(1:1000000) | |
| names(primes) <- 'nums' | |
| primes$isprime <- isprime(primes$nums) | |
| pn <- primes[primes$isprime == 2, 'nums'] | |
| e <- ecdf(pn) | |
| plot(e, xlab='n', ylab='Number of primes less or equal to n') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Re-weight everything according to the minimum distance to a seed. | |
| for (int currSeedIndex : seedSelector) { | |
| WeightedVector curr = datapoints.get(currSeedIndex); | |
| double newWeight = nextSeed.getWeight() * distanceMeasure.distance(nextSeed, curr); | |
| if (newWeight < seedSelector.getWeight(currSeedIndex)) { | |
| seedSelector.set(currSeedIndex, newWeight); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void testVectorIteration() { | |
| Vector vector = new SequentialAccessSparseVector(100); | |
| vector.set(0, 1); | |
| vector.set(2, 2); | |
| vector.set(4, 3); | |
| vector.set(6, 4); | |
| Iterator<Vector.Element> vectorIterator = vector.iterateNonZero(); | |
| Vector.Element element = null; | |
| int i = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.apache.mahout.math; | |
| import com.google.common.base.Preconditions; | |
| import org.apache.mahout.math.function.DoubleDoubleFunction; | |
| import org.apache.mahout.math.set.OpenIntHashSet; | |
| import java.util.Iterator; | |
| public abstract class VectorBinaryAssign { | |
| private static final VectorBinaryAssign operations[] = new VectorBinaryAssign[] { |
OlderNewer