Class ParameterLearning
- java.lang.Object
-
- com.bayesserver.learning.parameters.ParameterLearning
-
public final class ParameterLearning extends Object
Learns the parameters of Bayesian networks and Dynamic Bayesian networks, from data. Seelearn(com.bayesserver.data.EvidenceReaderCommand, com.bayesserver.learning.parameters.ParameterLearningOptions)
for sample code.
-
-
Constructor Summary
Constructors Constructor Description ParameterLearning(Network network, InferenceFactory factory)
Initializes a new instance of theParameterLearning
class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Network
getNetwork()
Returns the relevant network.ParameterLearningOutput
learn(EvidenceReaderCommand readerCommand, ParameterLearningOptions options)
Learns the parameters of a Bayesian network or Dynamic Bayesian network, from data.ParameterLearningOutput
learn(EvidenceReaderCommand readerCommand, List<DistributionSpecification> distributionSpecifications, ParameterLearningOptions options)
Learns the parameters of a Bayesian network or Dynamic Bayesian network, from data.static ParameterLearningOutput
learnDistributed(Network network, ParameterLearningOptions options, Distributer<DistributerContext> distributer)
Learns the parameters of a Bayesian network or Dynamic Bayesian network from data, on a distributed platform.static ParameterLearningOutput
learnDistributed(Network network, List<DistributionSpecification> distributionSpecifications, ParameterLearningOptions options, Distributer<DistributerContext> distributer)
Learns the parameters of a Bayesian network or Dynamic Bayesian network from data, on a distributed platform.static void
learnDistributedMapper(EvidencePartition<DistributedMapperContext> partition, NameValuesReader configuration, NameValuesWriter output, InferenceFactory factory)
This method should be called during distributed parameter learning on a distributed partition.static void
learnDistributedReducer(Iterable<NameValuesReader> inputs, NameValuesReader configuration, NameValuesWriter output)
Aggregates (reduces) the results obtained from the distributed calls tolearnDistributedMapper(com.bayesserver.data.distributed.EvidencePartition<com.bayesserver.learning.parameters.DistributedMapperContext>, com.bayesserver.NameValuesReader, com.bayesserver.NameValuesWriter, com.bayesserver.inference.InferenceFactory)
.
-
-
-
Constructor Detail
-
ParameterLearning
public ParameterLearning(Network network, InferenceFactory factory)
Initializes a new instance of theParameterLearning
class. Learning uses inference as a subroutine, and creates one or more inference engines via the [factory] parameter.- Parameters:
network
- The network whose parameters are being learnt.factory
- The inference factory used to create inference engines in cases when learning requires inference.
-
-
Method Detail
-
getNetwork
public Network getNetwork()
Returns the relevant network.- Returns:
- The network.
-
learn
public ParameterLearningOutput learn(EvidenceReaderCommand readerCommand, ParameterLearningOptions options)
Learns the parameters of a Bayesian network or Dynamic Bayesian network, from data.- Parameters:
readerCommand
- Can create a reader containing the data to learn from.options
- Learning options.- Returns:
- Summary information about parameter learning.
-
learnDistributedReducer
public static void learnDistributedReducer(Iterable<NameValuesReader> inputs, NameValuesReader configuration, NameValuesWriter output)
Aggregates (reduces) the results obtained from the distributed calls tolearnDistributedMapper(com.bayesserver.data.distributed.EvidencePartition<com.bayesserver.learning.parameters.DistributedMapperContext>, com.bayesserver.NameValuesReader, com.bayesserver.NameValuesWriter, com.bayesserver.inference.InferenceFactory)
.- Parameters:
inputs
- The results from each distributed mapper.configuration
- Configuration data that was distributed during the call tolearnDistributed(com.bayesserver.Network, com.bayesserver.learning.parameters.ParameterLearningOptions, com.bayesserver.Distributer<com.bayesserver.learning.parameters.DistributerContext>)
.output
- The aggregated results which will be used by the driver program which calledlearnDistributed(com.bayesserver.Network, com.bayesserver.learning.parameters.ParameterLearningOptions, com.bayesserver.Distributer<com.bayesserver.learning.parameters.DistributerContext>)
.
-
learnDistributedMapper
public static void learnDistributedMapper(EvidencePartition<DistributedMapperContext> partition, NameValuesReader configuration, NameValuesWriter output, InferenceFactory factory)
This method should be called during distributed parameter learning on a distributed partition.- Parameters:
partition
- The distributed data to be learnt from.configuration
- Configuration data that was distributed during the call tolearnDistributed(com.bayesserver.Network, com.bayesserver.learning.parameters.ParameterLearningOptions, com.bayesserver.Distributer<com.bayesserver.learning.parameters.DistributerContext>)
.output
- Stores the result of the distributed process. These results will later be passed to an aggregator (reducer).factory
- The inference factory used to create inference engines in cases when learning requires inference.
-
learnDistributed
public static ParameterLearningOutput learnDistributed(Network network, ParameterLearningOptions options, Distributer<DistributerContext> distributer)
Learns the parameters of a Bayesian network or Dynamic Bayesian network from data, on a distributed platform.- Parameters:
network
- The network whose parameters are being learnt.options
- Learning options.distributer
- The caller must implement this interface, which allows processing to be distributed.learnDistributedMapper(com.bayesserver.data.distributed.EvidencePartition<com.bayesserver.learning.parameters.DistributedMapperContext>, com.bayesserver.NameValuesReader, com.bayesserver.NameValuesWriter, com.bayesserver.inference.InferenceFactory)
should be called in the map phase, andlearnDistributedReducer(java.lang.Iterable<com.bayesserver.NameValuesReader>, com.bayesserver.NameValuesReader, com.bayesserver.NameValuesWriter)
should be called to reduce the results.- Returns:
- Summary information about parameter learning.
-
learnDistributed
public static ParameterLearningOutput learnDistributed(Network network, List<DistributionSpecification> distributionSpecifications, ParameterLearningOptions options, Distributer<DistributerContext> distributer)
Learns the parameters of a Bayesian network or Dynamic Bayesian network from data, on a distributed platform. Seecom.bayesserver.learning.parameters.ParameterLearning#learn(IEvidenceReader, ParameterLearningOptions)
for sample code.- Parameters:
network
- The network whose parameters are being learnt.distributionSpecifications
- The distributions to learn and options.options
- Learning options.distributer
- The caller must implement this interface, which allows processing to be distributed.learnDistributedMapper(com.bayesserver.data.distributed.EvidencePartition<com.bayesserver.learning.parameters.DistributedMapperContext>, com.bayesserver.NameValuesReader, com.bayesserver.NameValuesWriter, com.bayesserver.inference.InferenceFactory)
should be called in the map phase, andlearnDistributedReducer(java.lang.Iterable<com.bayesserver.NameValuesReader>, com.bayesserver.NameValuesReader, com.bayesserver.NameValuesWriter)
should be called to reduce the results.- Returns:
- Summary information about parameter learning.
-
learn
public ParameterLearningOutput learn(EvidenceReaderCommand readerCommand, List<DistributionSpecification> distributionSpecifications, ParameterLearningOptions options)
Learns the parameters of a Bayesian network or Dynamic Bayesian network, from data. The parameters of theNetwork
are replaced during learning. If necessary, a copy of the original network can be made prior to learning, to keep the original values.- Parameters:
readerCommand
- Can create a reader containing the data to learn from.distributionSpecifications
- The distributions to learn and options.options
- Learning options.- Returns:
- Summary information about parameter learning.
-
-