public void testDenseFeatureSelection() { Pipe p = makeSpacePredictionPipe(); InstanceList instances = new InstanceList(p); instances.addThruPipe(new ArrayIterator(data)); // Test that dense observations wights aren't added for // "default-feature" edges. CRF crf1 = new CRF(p, null); crf1.addOrderNStates(instances, new int[] { 0 }, null, "start", null, null, true); CRFTrainerByLabelLikelihood crft1 = new CRFTrainerByLabelLikelihood( crf1); crft1.setUseSparseWeights(false); crft1.train(instances, 1); // Set weights dimension int nParams1 = crft1.getOptimizableCRF(instances).getNumParameters(); CRF crf2 = new CRF(p, null); crf2.addOrderNStates(instances, new int[] { 0, 1 }, new boolean[] { false, true }, "start", null, null, true); CRFTrainerByLabelLikelihood crft2 = new CRFTrainerByLabelLikelihood( crf2); crft2.setUseSparseWeights(false); crft2.train(instances, 1); // Set weights dimension int nParams2 = crft2.getOptimizableCRF(instances).getNumParameters(); assertEquals(nParams2, nParams1 + 4); }
public void testDenseFeatureSelection() { Pipe p = makeSpacePredictionPipe(); InstanceList instances = new InstanceList(p); instances.addThruPipe(new ArrayIterator(data)); // Test that dense observations wights aren't added for // "default-feature" edges. CRF crf1 = new CRF(p, null); crf1.addOrderNStates(instances, new int[] { 0 }, null, "start", null, null, true); CRFTrainerByLabelLikelihood crft1 = new CRFTrainerByLabelLikelihood( crf1); crft1.setUseSparseWeights(false); crft1.train(instances, 1); // Set weights dimension int nParams1 = crft1.getOptimizableCRF(instances).getNumParameters(); CRF crf2 = new CRF(p, null); crf2.addOrderNStates(instances, new int[] { 0, 1 }, new boolean[] { false, true }, "start", null, null, true); CRFTrainerByLabelLikelihood crft2 = new CRFTrainerByLabelLikelihood( crf2); crft2.setUseSparseWeights(false); crft2.train(instances, 1); // Set weights dimension int nParams2 = crft2.getOptimizableCRF(instances).getNumParameters(); assertEquals(nParams2, nParams1 + 4); }