Search in sources :

Example 1 with ObjectProvenance

use of com.oracle.labs.mlrg.olcut.provenance.ObjectProvenance 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 ObjectProvenance

use of com.oracle.labs.mlrg.olcut.provenance.ObjectProvenance 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 ObjectProvenance

use of com.oracle.labs.mlrg.olcut.provenance.ObjectProvenance 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 ObjectProvenance

use of com.oracle.labs.mlrg.olcut.provenance.ObjectProvenance 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

ObjectProvenance (com.oracle.labs.mlrg.olcut.provenance.ObjectProvenance)4 ObjectMarshalledProvenance (com.oracle.labs.mlrg.olcut.provenance.io.ObjectMarshalledProvenance)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