public class ModelBatch extends java.util.ArrayList<GraphicalModel>
The idea here is pretty straightforward, but requires some explanation.
GraphicalModels are great for storing lots of metadata about the model, though storing full featurizations can be a bit slow.
With a ModelBatch, you can get your models from anywhere, and after running LENSE on them (which will add lots of annotations, potentially) you can write those models to disk in a big fat batch. Those models you've stored can be stored without featurizing them, as long as you keep enough metadata to be able to featurize later. Then when you load a batch from disk to run simulations, you can try out different feature sets and gameplayers, all while keeping the beautifully precomputed metadata for the model (including instructions for querying, and the query logs).
Constructor and Description |
---|
ModelBatch()
Creates an empty ModelBatch
|
ModelBatch(java.io.InputStream inputStream)
Load a batch of models from disk, without specifying a function to re-featurize those models.
|
ModelBatch(java.io.InputStream inputStream,
java.util.function.Consumer<GraphicalModel> featurizer)
Load a batch of models from disk, while running the function "featurizer" on each of the models before adding it
to the batch.
|
ModelBatch(java.lang.String filename)
This loads a model batch from a file, then closes the file handler.
|
ModelBatch(java.lang.String filename,
java.util.function.Consumer<GraphicalModel> featurizer)
This loads a model batch from a file, then closes the file handler.
|
Modifier and Type | Method and Description |
---|---|
void |
writeToFile(java.lang.String filename)
Convenience function to write the current state of the modelBatch out to a file, including all factors.
|
void |
writeToFileWithoutFactors(java.lang.String filename)
Convenience function to write the current state of the modelBatch out to a file, without factors.
|
void |
writeToStream(java.io.OutputStream outputStream)
This writes the entire batch, including all factors, to the given output stream.
|
void |
writeToStreamWithoutFactors(java.io.OutputStream outputStream)
This writes the whole batch, WITHOUT FACTORS, which means that anyone loading this batch will need to include
their own featurizer.
|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
public ModelBatch()
public ModelBatch(java.lang.String filename) throws java.io.IOException
filename
- the file to load fromjava.io.IOException
public ModelBatch(java.lang.String filename, java.util.function.Consumer<GraphicalModel> featurizer) throws java.io.IOException
filename
- the file to load fromfeaturizer
- a function that gets run on every GraphicalModel, and has a chance to edit them (eg by adding
or changing features)java.io.IOException
public ModelBatch(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- the inputstream to load fromjava.io.IOException
public ModelBatch(java.io.InputStream inputStream, java.util.function.Consumer<GraphicalModel> featurizer) throws java.io.IOException
inputStream
- the input stream to load fromfeaturizer
- a function that gets run on every GraphicalModel, and has a chance to edit them (eg by adding
or changing features)java.io.IOException
public void writeToFile(java.lang.String filename) throws java.io.IOException
WARNING: These files can get quite large, if you're using large embeddings as features.
filename
- the file to write the batch tojava.io.IOException
public void writeToFileWithoutFactors(java.lang.String filename) throws java.io.IOException
filename
- the file to write the batch tojava.io.IOException
public void writeToStream(java.io.OutputStream outputStream) throws java.io.IOException
WARNING: These files can get quite large, if you're using large embeddings as features.
outputStream
- the outputstream to write our files tojava.io.IOException
public void writeToStreamWithoutFactors(java.io.OutputStream outputStream) throws java.io.IOException
outputStream
- the outputstream to write our files tojava.io.IOException