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);
}
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);
}
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());
}
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);
}
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);
}
Aggregations