Class LoopyBeliefInference
- java.lang.Object
-
- com.bayesserver.inference.LoopyBeliefInference
-
-
Constructor Summary
Constructors Constructor Description LoopyBeliefInference(Network network)Initializes a new instance of theLoopyBeliefInferenceclass, with the target Bayesian network.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EvidencegetBaseEvidence()Optional evidence which can be used to calculate the lift of queries.EvidencegetEvidence()Represents the evidence, or case data (e.g.NetworkgetNetwork()The target Bayesian network.QueryDistributionCollectiongetQueryDistributions()Gets the collection of distributions to calculate.QueryFunctionCollectiongetQueryFunctions()Gets the collection of functions to evaluate, after QueryDistributions have been calculated.QueryLifecyclegetQueryLifecycle()Optional, allowing callers to hook into query lifecycle events, such as begin query and end query.voidquery(QueryOptions queryOptions, QueryOutput queryOutput)Calculates a number of distributions, e.g.voidsetBaseEvidence(Evidence value)Optional evidence which can be used to calculate the lift of queries.voidsetEvidence(Evidence value)Represents the evidence, or case data (e.g.voidsetQueryDistributions(QueryDistributionCollection value)Sets the collection of distributions to calculate.voidsetQueryFunctions(QueryFunctionCollection value)Sets the collection of functions to evaluate, after QueryDistributions have been calculated.voidsetQueryLifecycle(QueryLifecycle value)Optional, allowing callers to hook into query lifecycle events, such as begin query and end query.
-
-
-
Constructor Detail
-
LoopyBeliefInference
public LoopyBeliefInference(Network network)
Initializes a new instance of theLoopyBeliefInferenceclass, with the target Bayesian network.- Parameters:
network- The targetNetwork.- Throws:
NullPointerException- Raised if [network] is null.
-
-
Method Detail
-
getNetwork
public Network getNetwork()
The target Bayesian network.- Specified by:
getNetworkin interfaceInference
-
getEvidence
public Evidence getEvidence()
Represents the evidence, or case data (e.g. row in a database) used in aquery. Thedistributionsare only recalculated byInference.query(com.bayesserver.inference.QueryOptions, com.bayesserver.inference.QueryOutput), not each time evidence is changed.For more information see
Evidence.- Specified by:
getEvidencein interfaceInference
-
setEvidence
public void setEvidence(Evidence value)
Represents the evidence, or case data (e.g. row in a database) used in aquery. Thedistributionsare only recalculated byInference.query(com.bayesserver.inference.QueryOptions, com.bayesserver.inference.QueryOutput), not each time evidence is changed.For more information see
Evidence.- Specified by:
setEvidencein interfaceInference
-
getBaseEvidence
public Evidence getBaseEvidence()
Optional evidence which can be used to calculate the lift of queries. Defaults to null. WhenQueryDistribution.getComparison()istruequeries are adjusted based on marginals calculated with this evidence or no evidence if this value is null.- Specified by:
getBaseEvidencein interfaceInference- See Also:
QueryDistribution.getComparison()
-
setBaseEvidence
public void setBaseEvidence(Evidence value)
Optional evidence which can be used to calculate the lift of queries. Defaults to null. WhenQueryDistribution.getComparison()istruequeries are adjusted based on marginals calculated with this evidence or no evidence if this value is null.- Specified by:
setBaseEvidencein interfaceInference- See Also:
QueryDistribution.getComparison()
-
getQueryLifecycle
public QueryLifecycle getQueryLifecycle()
Optional, allowing callers to hook into query lifecycle events, such as begin query and end query.- Specified by:
getQueryLifecyclein interfaceInference
-
setQueryLifecycle
public void setQueryLifecycle(QueryLifecycle value)
Optional, allowing callers to hook into query lifecycle events, such as begin query and end query.- Specified by:
setQueryLifecyclein interfaceInference
-
getQueryDistributions
public QueryDistributionCollection getQueryDistributions()
Gets the collection of distributions to calculate. SeeQueryDistributionCollection. If required, a query distribution collection can be dynamically attached or detached. Also note that individual elements can be enabled or disabled on a per query basis.- Specified by:
getQueryDistributionsin interfaceInference
-
setQueryDistributions
public void setQueryDistributions(QueryDistributionCollection value)
Sets the collection of distributions to calculate. SeeQueryDistributionCollection. If required, a query distribution collection can be dynamically attached or detached. Also note that individual elements can be enabled or disabled on a per query basis.- Specified by:
setQueryDistributionsin interfaceInference
-
getQueryFunctions
public QueryFunctionCollection getQueryFunctions()
Gets the collection of functions to evaluate, after QueryDistributions have been calculated. If required, a query function collection can be dynamically attached or detached. Also note that individual elements can be enabled or disabled on a per query basis.- Specified by:
getQueryFunctionsin interfaceInference
-
setQueryFunctions
public void setQueryFunctions(QueryFunctionCollection value)
Sets the collection of functions to evaluate, after QueryDistributions have been calculated. If required, a query function collection can be dynamically attached or detached. Also note that individual elements can be enabled or disabled on a per query basis.- Specified by:
setQueryFunctionsin interfaceInference
-
query
public void query(QueryOptions queryOptions, QueryOutput queryOutput) throws InconsistentEvidenceException
Calculates a number of distributions, e.g. P(A) and P(B) given theevidence(case data, e.g. row in a database), and if requested the log-likelihood of the data. Each time this method is called thedistributionshave their values replaced, acting like buffers.As well as requesting distributions of the form P(A), P(B) it is also possible to request distributions over a number of variables such as P(A,B).
If
CLGaussiandistributions are requested that include instantiated discrete variables, an algorithm may legitimately return mean and covariance values equal to NaN for entries corresponding to inconsistent discrete combinations. For example, if a CLGaussian is requested that includes a discrete variable 'Gender' with states 'Male' and 'Female' and evidence is set to 'Female' then any mean and covariance entries that correspond to 'Male' may be set to NaN. NaN values will always be accompanied by a corresponding zero value in theCLGaussian.getTable().- Specified by:
queryin interfaceInference- Parameters:
queryOptions- Options governing which calculations are performed and how.queryOutput- Returns any information, in addition to thedistributions, that is requested. For example thelog-likelihood.- Throws:
InconsistentEvidenceException- Raised if inconsistent evidence is detected, or underflow/overflow occurs when calculating queries or the conflict measure. Note that log-likelihood calculations do not raise this exception, but instead report -Infinity or +Infinity.
-
-