use of com.oracle.labs.mlrg.olcut.config.ConfigurationData in project tribuo by oracle.
the class TestFMClassification method fmRoundTripTest.
@Test
public void fmRoundTripTest() {
Pair<Dataset<Label>, Dataset<Label>> p = LabelledDataGenerator.denseTrainTest();
Model<Label> model = testFMClassification(p);
ConfigurationManager cm = new ConfigurationManager();
List<ConfigurationData> provConfig = ProvenanceUtil.extractConfiguration(model.getProvenance());
cm.addConfiguration(provConfig);
FMClassificationTrainer trainer = (FMClassificationTrainer) cm.lookup("fmclassificationtrainer-0");
Model<Label> newModel = trainer.train(p.getA());
assertNotNull(newModel);
}
use of com.oracle.labs.mlrg.olcut.config.ConfigurationData in project tribuo by oracle.
the class Helpers method testConfigurableRoundtrip.
/**
* Takes an object that is both {@link Provenancable} and {@link Configurable} and tests whether the configuration
* and provenance representations are the same using {@link ConfigurationData#structuralEquals(List, List, String, String)}.
* @param itm The object whose equality is to be tested
*/
public static <P extends ConfiguredObjectProvenance, C extends Configurable & Provenancable<P>> void testConfigurableRoundtrip(C itm) {
ConfigurationManager cm = new ConfigurationManager();
String name = cm.importConfigurable(itm, "item");
List<ConfigurationData> configData = cm.getComponentNames().stream().map(cm::getConfigurationData).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
List<ConfigurationData> provenData = ProvenanceUtil.extractConfiguration(itm.getProvenance());
Assertions.assertTrue(ConfigurationData.structuralEquals(configData, provenData, name, provenData.get(0).getName()));
}
Aggregations