Class QueryDistribution
- java.lang.Object
-
- com.bayesserver.inference.QueryDistribution
-
- All Implemented Interfaces:
Cloneable
public final class QueryDistribution extends Object implements Cloneable
Defines a distribution to be queried in a call toInference.query(com.bayesserver.inference.QueryOptions, com.bayesserver.inference.QueryOutput)
.
-
-
Constructor Summary
Constructors Constructor Description QueryDistribution(Distribution distribution)
Initializes a new instance of theQueryDistribution
class.QueryDistribution(Distribution distribution, boolean isEnabled)
Initializes a new instance of theQueryDistribution
class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryDistribution
copy()
Copies this instance, creating a copy of the distribution as well.QueryComparison
getComparison()
Gets a value indicating whether queried values should be adjusted to show how they compare to the same query with no evidence, or base evidence.Double
getDistance()
The distance between this query calculated with base evidence or no evidence, and when calculated with evidence.Distribution
getDistribution()
Gets the distribution to query.boolean
getIsEnabled()
Gets a value indicating whether the distribution should be queried.Double
getLogLikelihood()
The log-likelihood specific to the evidence used to calculate this query.QueryDistance
getQueryDistance()
Gets a value indicating whether the distance should be calculated between the query calculated with base evidence (or no evidence), and the same query calculated with evidence.boolean
getQueryLogLikelihood()
Determines whether or not to calculate thegetLogLikelihood()
specific to the evidence used to calculate this query.void
setComparison(QueryComparison value)
Sets a value indicating whether queried values should be adjusted to show how they compare to the same query with no evidence, or base evidence.void
setDistance(Double value)
The distance between this query calculated with base evidence or no evidence, and when calculated with evidence.void
setIsEnabled(boolean value)
Sets a value indicating whether the distribution should be queried.void
setLogLikelihood(Double value)
The log-likelihood specific to the evidence used to calculate this query.void
setQueryDistance(QueryDistance value)
Sets a value indicating whether the distance should be calculated between the query calculated with base evidence (or no evidence), and the same query calculated with evidence.void
setQueryLogLikelihood(boolean value)
Determines whether or not to calculate thegetLogLikelihood()
specific to the evidence used to calculate this query.String
toString()
Returns aString
that represents this instance.
-
-
-
Constructor Detail
-
QueryDistribution
public QueryDistribution(Distribution distribution)
Initializes a new instance of theQueryDistribution
class. The enabled property defaults to true.- Parameters:
distribution
- The distribution to query.
-
QueryDistribution
public QueryDistribution(Distribution distribution, boolean isEnabled)
Initializes a new instance of theQueryDistribution
class.- Parameters:
distribution
- The distribution to query.isEnabled
- Sets thegetIsEnabled()
property.
-
-
Method Detail
-
copy
public QueryDistribution copy()
Copies this instance, creating a copy of the distribution as well.- Returns:
- A copy of this instance.
-
getQueryDistance
public QueryDistance getQueryDistance()
Gets a value indicating whether the distance should be calculated between the query calculated with base evidence (or no evidence), and the same query calculated with evidence.The distance can be calculated against no evidence, or against base evidence which can be set on
Inference.getBaseEvidence()
.
-
setQueryDistance
public void setQueryDistance(QueryDistance value)
Sets a value indicating whether the distance should be calculated between the query calculated with base evidence (or no evidence), and the same query calculated with evidence.The distance can be calculated against no evidence, or against base evidence which can be set on
Inference.getBaseEvidence()
.
-
getComparison
public QueryComparison getComparison()
Gets a value indicating whether queried values should be adjusted to show how they compare to the same query with no evidence, or base evidence.Using comparisons is useful when you want to measure the difference or lift of a prediction value, for example when spotting unusual patterns during data exploration, or making recommendations.
The comparison can be calculated based on no evidence, or against base evidence which can be set on
Inference.getBaseEvidence()
.
-
setComparison
public void setComparison(QueryComparison value)
Sets a value indicating whether queried values should be adjusted to show how they compare to the same query with no evidence, or base evidence.Using comparisons is useful when you want to measure the difference or lift of a prediction value, for example when spotting unusual patterns during data exploration, or making recommendations.
The comparison can be calculated based on no evidence, or against base evidence which can be set on
Inference.getBaseEvidence()
.
-
getQueryLogLikelihood
public boolean getQueryLogLikelihood()
Determines whether or not to calculate thegetLogLikelihood()
specific to the evidence used to calculate this query. For more information seegetLogLikelihood()
.
-
setQueryLogLikelihood
public void setQueryLogLikelihood(boolean value)
Determines whether or not to calculate thegetLogLikelihood()
specific to the evidence used to calculate this query. For more information seegetLogLikelihood()
.
-
getLogLikelihood
public Double getLogLikelihood()
The log-likelihood specific to the evidence used to calculate this query. Only calculated whengetQueryLogLikelihood()
istrue
. The log-likelihood value will equal the overallQueryOutput.getLogLikelihood()
unlessQueryOptions.getQueryEvidenceMode()
is set toQueryEvidenceMode.RETRACT_QUERY_EVIDENCE
, and there is evidence on at least one variable in theDistribution
.When evidence is retracted for a particular query, this value contains the log likelihood of the remaining evidence.
-
setLogLikelihood
public void setLogLikelihood(Double value)
The log-likelihood specific to the evidence used to calculate this query. Only calculated whengetQueryLogLikelihood()
istrue
. The log-likelihood value will equal the overallQueryOutput.getLogLikelihood()
unlessQueryOptions.getQueryEvidenceMode()
is set toQueryEvidenceMode.RETRACT_QUERY_EVIDENCE
, and there is evidence on at least one variable in theDistribution
.When evidence is retracted for a particular query, this value contains the log likelihood of the remaining evidence.
-
getDistance
public Double getDistance()
The distance between this query calculated with base evidence or no evidence, and when calculated with evidence. Only calculated whengetQueryDistance()
is not None. This value can be null when the QueryDistance is set to None or the distance is undefined for the given queries.
-
setDistance
public void setDistance(Double value)
The distance between this query calculated with base evidence or no evidence, and when calculated with evidence. Only calculated whengetQueryDistance()
is not None. This value can be null when the QueryDistance is set to None or the distance is undefined for the given queries.
-
getIsEnabled
public boolean getIsEnabled()
Gets a value indicating whether the distribution should be queried.- Returns:
true
if the distribution should be queried; otherwise,false
.
-
setIsEnabled
public void setIsEnabled(boolean value)
Sets a value indicating whether the distribution should be queried.- Parameters:
value
-true
if the distribution should be queried; otherwise,false
.
-
getDistribution
public Distribution getDistribution()
Gets the distribution to query.- Returns:
- The distribution.
-
-