Search in sources :

Example 1 with ObjectMarshalledProvenance

use of com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance in project tribuo by oracle.

the class Helpers method testProvenanceMarshalling.

public static void testProvenanceMarshalling(ObjectProvenance inputProvenance) {
    List<ObjectMarshalledProvenance> provenanceList = ProvenanceUtil.marshalProvenance(inputProvenance);
    ObjectProvenance unmarshalledProvenance = ProvenanceUtil.unmarshalProvenance(provenanceList);
    Assertions.assertEquals(unmarshalledProvenance, inputProvenance);
}
Also used : ObjectProvenance(com.oracle.labs.mlrg.olcut.provenance.ObjectProvenance) ConfiguredObjectProvenance(com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance) ObjectMarshalledProvenance(com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance)

Example 2 with ObjectMarshalledProvenance

use of com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance in project tribuo by oracle.

the class CSVDataSourceTest method testBasic.

@Test
public void testBasic() {
    CSVDataSource<MockOutput> dataSource = new CSVDataSource<>(dataFile, rowProcessor, true);
    MutableDataset<MockOutput> dataset = new MutableDataset<>(dataSource);
    assertEquals(6, dataset.size(), "Found an incorrect number of rows when loading the csv.");
    DatasetProvenance prov = dataset.getProvenance();
    List<ObjectMarshalledProvenance> datasetProvenance = ProvenanceUtil.marshalProvenance(prov);
    assertFalse(datasetProvenance.isEmpty());
    ObjectProvenance unmarshalledProvenance = ProvenanceUtil.unmarshalProvenance(datasetProvenance);
    assertEquals(prov, unmarshalledProvenance);
}
Also used : ObjectProvenance(com.oracle.labs.mlrg.olcut.provenance.ObjectProvenance) MockOutput(org.tribuo.test.MockOutput) ObjectMarshalledProvenance(com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance) DatasetProvenance(org.tribuo.provenance.DatasetProvenance) MutableDataset(org.tribuo.MutableDataset) Test(org.junit.jupiter.api.Test)

Example 3 with ObjectMarshalledProvenance

use of com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance in project tribuo by oracle.

the class CSVDataSourceTest method testRegexExpand.

@Test
public void testRegexExpand() {
    CSVDataSource<MockOutput> dataSource = new CSVDataSource<>(regexDataFile, regexRowProcessor, true);
    MutableDataset<MockOutput> dataset = new MutableDataset<>(dataSource);
    assertEquals(6, dataset.size(), "Found an incorrect number of rows when loading the csv.");
    DatasetProvenance prov = dataset.getProvenance();
    List<ObjectMarshalledProvenance> datasetProvenance = ProvenanceUtil.marshalProvenance(prov);
    assertFalse(datasetProvenance.isEmpty());
    ObjectProvenance unmarshalledProvenance = ProvenanceUtil.unmarshalProvenance(datasetProvenance);
    assertEquals(prov, unmarshalledProvenance);
    assertEquals(13, dataset.getFeatureMap().size());
}
Also used : ObjectProvenance(com.oracle.labs.mlrg.olcut.provenance.ObjectProvenance) MockOutput(org.tribuo.test.MockOutput) ObjectMarshalledProvenance(com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance) DatasetProvenance(org.tribuo.provenance.DatasetProvenance) MutableDataset(org.tribuo.MutableDataset) Test(org.junit.jupiter.api.Test)

Example 4 with ObjectMarshalledProvenance

use of com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance in project tribuo by oracle.

the class Model method copy.

/**
 * Copies a model, returning a deep copy of any mutable state, and a shallow copy otherwise.
 * @return A copy of the model.
 */
public Model<T> copy() {
    List<ObjectMarshalledProvenance> omp = ProvenanceUtil.marshalProvenance(provenance);
    ModelProvenance provenanceCopy = (ModelProvenance) ProvenanceUtil.unmarshalProvenance(omp);
    return copy(name, provenanceCopy);
}
Also used : ObjectMarshalledProvenance(com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance) ModelProvenance(org.tribuo.provenance.ModelProvenance)

Example 5 with ObjectMarshalledProvenance

use of com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance in project tribuo by oracle.

the class JsonDataSourceTest method loadTest.

@Test
public void loadTest() throws URISyntaxException {
    URI dataFile = JsonDataSourceTest.class.getResource("/org/tribuo/json/test.json").toURI();
    RowProcessor<MockOutput> rowProcessor = buildRowProcessor();
    JsonDataSource<MockOutput> source = new JsonDataSource<>(dataFile, rowProcessor, true);
    MutableDataset<MockOutput> dataset = new MutableDataset<>(source);
    assertEquals(20, dataset.size(), "Found an incorrect number of rows when loading the json file.");
    DatasetProvenance prov = dataset.getProvenance();
    List<ObjectMarshalledProvenance> datasetProvenance = ProvenanceUtil.marshalProvenance(prov);
    assertFalse(datasetProvenance.isEmpty());
    ObjectProvenance unmarshalledProvenance = ProvenanceUtil.unmarshalProvenance(datasetProvenance);
    assertEquals(prov, unmarshalledProvenance);
}
Also used : ObjectProvenance(com.oracle.labs.mlrg.olcut.provenance.ObjectProvenance) MockOutput(org.tribuo.test.MockOutput) ObjectMarshalledProvenance(com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance) DatasetProvenance(org.tribuo.provenance.DatasetProvenance) URI(java.net.URI) MutableDataset(org.tribuo.MutableDataset) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectMarshalledProvenance (com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance)5 ObjectProvenance (com.oracle.labs.mlrg.olcut.provenance.ObjectProvenance)4 Test (org.junit.jupiter.api.Test)3 MutableDataset (org.tribuo.MutableDataset)3 DatasetProvenance (org.tribuo.provenance.DatasetProvenance)3 MockOutput (org.tribuo.test.MockOutput)3 ConfiguredObjectProvenance (com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance)1 URI (java.net.URI)1 ModelProvenance (org.tribuo.provenance.ModelProvenance)1