@Test public void testAddToVectorUsesProductOfWeights() { WordValueEncoder wv = new StaticWordValueEncoder("word"); ContinuousValueEncoder cv = new ContinuousValueEncoder("cont"); InteractionValueEncoder enc = new InteractionValueEncoder("interactions", wv, cv); Vector v1 = new DenseVector(200); enc.addInteractionToVector("a","0.9",0.5, v1); int k = enc.getProbes(); assertEquals((float) k*0.5*0.9, v1.norm(1), 0); assertEquals(0.5*0.9, v1.maxValue(), 0); }
public void addInteractionToVector(String original1, String original2, double weight, Vector data) { byte[] originalForm1 = bytesForString(original1); byte[] originalForm2 = bytesForString(original2); addInteractionToVector(originalForm1, originalForm2, weight, data); }
InteractionValueEncoder extends FeatureVectorEncoder { public void addInteractionToVector(String original1, String original2, double weight, Vector data) { byte[] originalForm1 = bytesForString(original1); byte[] originalForm2 = bytesForString(original2); addInteractionToVector(originalForm1, originalForm2, weight, data); } }
InteractionValueEncoder extends FeatureVectorEncoder { public void addInteractionToVector(String original1, String original2, double weight, Vector data) { byte[] originalForm1 = bytesForString(original1); byte[] originalForm2 = bytesForString(original2); addInteractionToVector(originalForm1, originalForm2, weight, data); } InteractionValueEncoder(String name, FeatureVectorEncoder encoderOne, FeatureVectorEncoder encoderTwo); }
InteractionValueEncoder extends FeatureVectorEncoder { public void addInteractionToVector(String original1, String original2, double weight, Vector data) { byte[] originalForm1 = bytesForString(original1); byte[] originalForm2 = bytesForString(original2); addInteractionToVector(originalForm1, originalForm2, weight, data); } InteractionValueEncoder(String name, FeatureVectorEncoder encoderOne, FeatureVectorEncoder encoderTwo); @Override void addToVector(String originalForm, double w, Vector data); @Override void addToVector(byte[] originalForm, double w, Vector data); void addInteractionToVector(String original1, String original2, double weight, Vector data); void addInteractionToVector(byte[] originalForm1, byte[] originalForm2, double weight, Vector data); @Override String asString(String originalForm); }
InteractionValueEncoder extends FeatureVectorEncoder { public void addInteractionToVector(String original1, String original2, double weight, Vector data) { byte[] originalForm1 = bytesForString(original1); byte[] originalForm2 = bytesForString(original2); addInteractionToVector(originalForm1, originalForm2, weight, data); } InteractionValueEncoder(String name, FeatureVectorEncoder encoderOne, FeatureVectorEncoder encoderTwo); @Override void addToVector(String originalForm, double w, Vector data); @Override void addToVector(byte[] originalForm, double w, Vector data); void addInteractionToVector(String original1, String original2, double weight, Vector data); void addInteractionToVector(byte[] originalForm1, byte[] originalForm2, double weight, Vector data); @Override String asString(String originalForm);  }