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 theQueryDistributionclass.QueryDistribution(Distribution distribution, boolean isEnabled)Initializes a new instance of theQueryDistributionclass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryDistributioncopy()Copies this instance, creating a copy of the distribution as well.QueryComparisongetComparison()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.DoublegetDistance()The distance between this query calculated with base evidence or no evidence, and when calculated with evidence.DistributiongetDistribution()Gets the distribution to query.booleangetIsEnabled()Gets a value indicating whether the distribution should be queried.DoublegetLogLikelihood()The log-likelihood specific to the evidence used to calculate this query.QueryDistancegetQueryDistance()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.booleangetQueryLogLikelihood()Determines whether or not to calculate thegetLogLikelihood()specific to the evidence used to calculate this query.voidsetComparison(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.voidsetDistance(Double value)The distance between this query calculated with base evidence or no evidence, and when calculated with evidence.voidsetIsEnabled(boolean value)Sets a value indicating whether the distribution should be queried.voidsetLogLikelihood(Double value)The log-likelihood specific to the evidence used to calculate this query.voidsetQueryDistance(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.voidsetQueryLogLikelihood(boolean value)Determines whether or not to calculate thegetLogLikelihood()specific to the evidence used to calculate this query.StringtoString()Returns aStringthat represents this instance.
-
-
-
Constructor Detail
-
QueryDistribution
public QueryDistribution(Distribution distribution)
Initializes a new instance of theQueryDistributionclass. The enabled property defaults to true.- Parameters:
distribution- The distribution to query.
-
QueryDistribution
public QueryDistribution(Distribution distribution, boolean isEnabled)
Initializes a new instance of theQueryDistributionclass.- 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:
trueif 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-trueif the distribution should be queried; otherwise,false.
-
getDistribution
public Distribution getDistribution()
Gets the distribution to query.- Returns:
- The distribution.
-
-