public Frame transform(Vec wordVec, AggregateMethod aggregateMethod) { if (wordVec.get_type() != Vec.T_STR) { throw new IllegalArgumentException("Expected a string vector, got " + wordVec.get_type_str() + " vector."); } byte[] types = new byte[_output._vecSize]; Arrays.fill(types, Vec.T_NUM); MRTask<?> transformTask = aggregateMethod == AggregateMethod.AVERAGE ? new Word2VecAggregateTask(this) : new Word2VecTransformTask(this); return transformTask.doAll(types, wordVec).outputFrame(Key.<Frame>make(), null, null); }
/** Simple testing scenario, splitting frame in the middle and comparing the values */ static void testScenario(Frame f, String[] expValues, MRTask chunkAssertions) { double[] ratios = ard(0.5, 0.5); Key<Frame>[] keys = aro(Key.<Frame>make("test.hex"), Key.<Frame>make("train.hex")); Frame[] splits = null; try { splits = ShuffleSplitFrame.shuffleSplitFrame(f, keys, ratios, 42); Assert.assertEquals("Expecting 2 splits", 2, splits.length); // Collect values from both splits String[] values = append( collectS(splits[0].vec(0)), collectS(splits[1].vec(0))); // Sort values, but first replace all nulls by unique value Arrays.sort(replaceNulls(expValues)); Arrays.sort(replaceNulls(values)); Assert.assertArrayEquals("Values should match", expValues, values); if (chunkAssertions != null) { for (Frame s: splits) chunkAssertions.doAll(s).getResult(); } } finally { f.delete(); if (splits!=null) for(Frame s: splits) s.delete(); } }
public Frame transform(Vec wordVec, AggregateMethod aggregateMethod) { if (wordVec.get_type() != Vec.T_STR) { throw new IllegalArgumentException("Expected a string vector, got " + wordVec.get_type_str() + " vector."); } byte[] types = new byte[_output._vecSize]; Arrays.fill(types, Vec.T_NUM); MRTask<?> transformTask = aggregateMethod == AggregateMethod.AVERAGE ? new Word2VecAggregateTask(this) : new Word2VecTransformTask(this); return transformTask.doAll(types, wordVec).outputFrame(Key.<Frame>make(), null, null); }