@Override protected void cleanup(Context context) throws IOException, InterruptedException { List<Cluster> clusters = classifier.getModels(); ClusterWritable cw = new ClusterWritable(); for (int index = 0; index < clusters.size(); index++) { cw.setValue(clusters.get(index)); context.write(new IntWritable(index), cw); } super.cleanup(context); }
@Override protected void cleanup(Context context) throws IOException, InterruptedException { List<Cluster> clusters = classifier.getModels(); ClusterWritable cw = new ClusterWritable(); for (int index = 0; index < clusters.size(); index++) { cw.setValue(clusters.get(index)); context.write(new IntWritable(index), cw); } super.cleanup(context); }
@Override protected void cleanup(Context context) throws IOException, InterruptedException { List<Cluster> clusters = classifier.getModels(); ClusterWritable cw = new ClusterWritable(); for (int index = 0; index < clusters.size(); index++) { cw.setValue(clusters.get(index)); context.write(new IntWritable(index), cw); } super.cleanup(context); }
public void writeToSeqFiles(Path path) throws IOException { writePolicy(policy, path); Configuration config = new Configuration(); FileSystem fs = FileSystem.get(path.toUri(), config); ClusterWritable cw = new ClusterWritable(); for (int i = 0; i < models.size(); i++) { try (SequenceFile.Writer writer = new SequenceFile.Writer(fs, config, new Path(path, "part-" + String.format(Locale.ENGLISH, "%05d", i)), IntWritable.class, ClusterWritable.class)) { Cluster cluster = models.get(i); cw.setValue(cluster); Writable key = new IntWritable(i); writer.append(key, cw); } } }
@Override protected void reduce(IntWritable key, Iterable<ClusterWritable> values, Context context) throws IOException, InterruptedException { Iterator<ClusterWritable> iter = values.iterator(); Cluster first = iter.next().getValue(); // there must always be at least one while (iter.hasNext()) { Cluster cluster = iter.next().getValue(); first.observe(cluster); } List<Cluster> models = Lists.newArrayList(); models.add(first); classifier = new ClusterClassifier(models, policy); classifier.close(); context.write(key, new ClusterWritable(first)); }
public void writeToSeqFiles(Path path) throws IOException { writePolicy(policy, path); Configuration config = new Configuration(); FileSystem fs = FileSystem.get(path.toUri(), config); SequenceFile.Writer writer = null; ClusterWritable cw = new ClusterWritable(); for (int i = 0; i < models.size(); i++) { try { Cluster cluster = models.get(i); cw.setValue(cluster); writer = new SequenceFile.Writer(fs, config, new Path(path, "part-" + String.format(Locale.ENGLISH, "%05d", i)), IntWritable.class, ClusterWritable.class); Writable key = new IntWritable(i); writer.append(key, cw); } finally { Closeables.close(writer, false); } } }
public void writeToSeqFiles(Path path) throws IOException { writePolicy(policy, path); Configuration config = new Configuration(); FileSystem fs = FileSystem.get(path.toUri(), config); SequenceFile.Writer writer = null; ClusterWritable cw = new ClusterWritable(); for (int i = 0; i < models.size(); i++) { try { Cluster cluster = models.get(i); cw.setValue(cluster); writer = new SequenceFile.Writer(fs, config, new Path(path, "part-" + String.format(Locale.ENGLISH, "%05d", i)), IntWritable.class, ClusterWritable.class); Writable key = new IntWritable(i); writer.append(key, cw); } finally { Closeables.close(writer, false); } } }
@Override protected void reduce(IntWritable key, Iterable<ClusterWritable> values, Context context) throws IOException, InterruptedException { Iterator<ClusterWritable> iter = values.iterator(); Cluster first = iter.next().getValue(); // there must always be at least one while (iter.hasNext()) { Cluster cluster = iter.next().getValue(); first.observe(cluster); } List<Cluster> models = Lists.newArrayList(); models.add(first); classifier = new ClusterClassifier(models, policy); classifier.close(); context.write(key, new ClusterWritable(first)); }
@Override protected void reduce(IntWritable key, Iterable<ClusterWritable> values, Context context) throws IOException, InterruptedException { Iterator<ClusterWritable> iter = values.iterator(); Cluster first = iter.next().getValue(); // there must always be at least one while (iter.hasNext()) { Cluster cluster = iter.next().getValue(); first.observe(cluster); } List<Cluster> models = new ArrayList<>(); models.add(first); classifier = new ClusterClassifier(models, policy); classifier.close(); context.write(key, new ClusterWritable(first)); }
@Override protected void reduce(Text arg0, Iterable<VectorWritable> values, Context context) throws IOException, InterruptedException { for (VectorWritable value : values) { Vector point = value.get(); canopyClusterer.addPointToCanopies(point, canopies); } for (Canopy canopy : canopies) { canopy.computeParameters(); if (canopy.getNumObservations() > clusterFilter) { ClusterWritable clusterWritable = new ClusterWritable(); clusterWritable.setValue(canopy); context.write(new Text(canopy.getIdentifier()), clusterWritable); } } }
@Override protected void reduce(Text arg0, Iterable<VectorWritable> values, Context context) throws IOException, InterruptedException { for (VectorWritable value : values) { Vector point = value.get(); canopyClusterer.addPointToCanopies(point, canopies); } for (Canopy canopy : canopies) { canopy.computeParameters(); if (canopy.getNumObservations() > clusterFilter) { ClusterWritable clusterWritable = new ClusterWritable(); clusterWritable.setValue(canopy); context.write(new Text(canopy.getIdentifier()), clusterWritable); } } }
@Override protected void reduce(Text arg0, Iterable<VectorWritable> values, Context context) throws IOException, InterruptedException { for (VectorWritable value : values) { Vector point = value.get(); canopyClusterer.addPointToCanopies(point, canopies); } for (Canopy canopy : canopies) { canopy.computeParameters(); if (canopy.getNumObservations() > clusterFilter) { ClusterWritable clusterWritable = new ClusterWritable(); clusterWritable.setValue(canopy); context.write(new Text(canopy.getIdentifier()), clusterWritable); } } }
Kluster newCluster = new Kluster(value.get(), index, measure); newCluster.observe(value.get(), 1); ClusterWritable clusterWritable = new ClusterWritable(); clusterWritable.setValue(newCluster); chosenClusters.put(index, clusterWritable);
Kluster newCluster = new Kluster(value.get(), index, measure); newCluster.observe(value.get(), 1); ClusterWritable clusterWritable = new ClusterWritable(); clusterWritable.setValue(newCluster); chosenClusters.put(index, clusterWritable);
Kluster newCluster = new Kluster(value.get(), index, measure); newCluster.observe(value.get(), 1); ClusterWritable clusterWritable = new ClusterWritable(); clusterWritable.setValue(newCluster); chosenClusters.put(index, clusterWritable);
Text.class, ClusterWritable.class); try { ClusterWritable clusterWritable = new ClusterWritable(); for (Canopy canopy : canopies) { canopy.computeParameters();
Text.class, ClusterWritable.class); try { ClusterWritable clusterWritable = new ClusterWritable(); for (Canopy canopy : canopies) { canopy.computeParameters();
Text.class, ClusterWritable.class); try { ClusterWritable clusterWritable = new ClusterWritable(); for (Canopy canopy : canopies) { canopy.computeParameters();
try { Writable key = new Text(); ClusterWritable clusterWritable = new ClusterWritable(); assertTrue("more to come", reader.next(key, clusterWritable)); assertEquals("1st key", "C-0", key.toString());
try { Writable key = new Text(); ClusterWritable clusterWritable = new ClusterWritable(); assertTrue("more to come", reader.next(key, clusterWritable)); assertEquals("1st key", "C-0", key.toString());