Search in sources :

Example 1 with ConfigurationData

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);
}
Also used : Dataset(org.tribuo.Dataset) Label(org.tribuo.classification.Label) ConfigurationData(com.oracle.labs.mlrg.olcut.config.ConfigurationData) ConfigurationManager(com.oracle.labs.mlrg.olcut.config.ConfigurationManager) Test(org.junit.jupiter.api.Test)

Example 2 with ConfigurationData

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()));
}
Also used : Optional(java.util.Optional) ConfigurationData(com.oracle.labs.mlrg.olcut.config.ConfigurationData) ConfigurationManager(com.oracle.labs.mlrg.olcut.config.ConfigurationManager)

Aggregations

ConfigurationData (com.oracle.labs.mlrg.olcut.config.ConfigurationData)2 ConfigurationManager (com.oracle.labs.mlrg.olcut.config.ConfigurationManager)2 Optional (java.util.Optional)1 Test (org.junit.jupiter.api.Test)1 Dataset (org.tribuo.Dataset)1 Label (org.tribuo.classification.Label)1