Class AbstractFeatureKLDivergence<U extends java.io.Serializable,I extends java.io.Serializable,P>
java.lang.Object
es.uam.eps.ir.relison.diffusion.metrics.AbstractIndividualSimulationMetric<U,I,P>
es.uam.eps.ir.relison.diffusion.metrics.features.AbstractFeatureIndividualSimulationMetric<U,I,P>
es.uam.eps.ir.relison.diffusion.metrics.features.indiv.AbstractFeatureKLDivergence<U,I,P>
- Type Parameters:
U
- type of the users.I
- type of the information pieces.P
- type of the parameters.
- All Implemented Interfaces:
IndividualSimulationMetric<U,I,P>
,SimulationMetric<U,I,P>
- Direct Known Subclasses:
FeatureIndividualKLDivergence
,FeatureKLDivergenceInverse
public abstract class AbstractFeatureKLDivergence<U extends java.io.Serializable,I extends java.io.Serializable,P> extends AbstractFeatureIndividualSimulationMetric<U,I,P>
This individual metric computes the KL divergence of the priori distribution of the parameter
values over the whole set of information pieces, and the frequency of receival of
these parameters for a single user.
Depending on the nature of the parameter, we differ two cases:
- User parameters:
- Priori distribution: The priori value for an individual user parameter
is computed as the sum over the set of users as the product of the number of pieces published
by the user and the value of the user parameter for the user.
For example, let's suppose we have four different users, with two different communites:
User 1: Comm 1 (value 1), (i1,i2,i3), User 2: Comm 1 (value 2), (i4,i5), User 3: Comm 1 (value 2), (i6), User 4: Comm 2 (value 3), (i7,i8,i9,i10)
Then: Comm1 = 3*1 + 2*2 + 1*2 = 9; Comm2 = 3*4 = 12 - Simulation distribution of a user: In this case, for each received and seen information piece, we sum the value of each parameter for the creator of the piece.
- Priori distribution: The priori value for an individual user parameter
is computed as the sum over the set of users as the product of the number of pieces published
by the user and the value of the user parameter for the user.
For example, let's suppose we have four different users, with two different communites:
- Information piece parameters:
- Priori distribution:The priori value for an individual information piece
parameter is computed as the sum over the set of information pieces of the value of the parameter
for each parameter. For example, let's suppose we have four information pieces, and four different hashtags:
Piece 1: (h1,h1,h3), Piece 2:(h1,h2), Piece 3: (h3,h4), Piece 4: (h1,h2,h3,h3,h3)
Then: h1 = 2 + 1 + 0 + 1 = 4; h2 = 0 + 1 + 0 + 1 = 2; h3 = 1 + 0 + 1 + 3 = 5; h4 = 0 + 0 + 1 + 0 = 1 - Simulation distribution of a user: In this case, for each received and seen information piece, we sum the value of each parameter for the information piece.
- Priori distribution:The priori value for an individual information piece
parameter is computed as the sum over the set of information pieces of the value of the parameter
for each parameter. For example, let's suppose we have four information pieces, and four different hashtags:
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<P,java.lang.Double>
pvalues
The distribution we are trying to approximate.protected java.util.Map<P,java.util.Map<U,java.lang.Double>>
qvalues
Times each parameter has been received.protected double
sumP
The sum of the values we are trying to approximateprotected java.util.Map<U,java.lang.Double>
sumQ
The total number of external parameters that have reached each user.private boolean
unique
Indicates if a piece of information is considered once (or each time it appears if false).Fields inherited from class es.uam.eps.ir.relison.diffusion.metrics.AbstractIndividualSimulationMetric
data, initialized
-
Constructor Summary
Constructors Constructor Description AbstractFeatureKLDivergence(java.lang.String name, java.lang.String parameter, boolean userparam, boolean unique)
Constructor. -
Method Summary
Modifier and Type Method Description double
calculate()
Calculates the metric for the current state of the simulation.void
clear()
Resets the metric.protected void
initialize()
Initializes all the variables needed for computing and updating the values of the metric.protected void
updateInfoFeatures(Iteration<U,I,P> iteration)
Updates the necessary variables to compute a metric, in case the feature values we are using belong to the information pieces received by the users in the network.protected void
updateUserFeatures(Iteration<U,I,P> iteration)
Updates the necessary variables to compute a metric, in case the feature values we are using belongs to the creators of the information pieces received by the users in the network.Methods inherited from class es.uam.eps.ir.relison.diffusion.metrics.features.AbstractFeatureIndividualSimulationMetric
getParameter, update, usesUserParam
Methods inherited from class es.uam.eps.ir.relison.diffusion.metrics.AbstractIndividualSimulationMetric
calculateIndividuals, getName, initialize, isInitialized
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface es.uam.eps.ir.relison.diffusion.metrics.IndividualSimulationMetric
calculate, calculate, calculateIndividuals
Methods inherited from interface es.uam.eps.ir.relison.diffusion.metrics.SimulationMetric
calculate, initialize
-
Field Details
-
qvalues
protected final java.util.Map<P,java.util.Map<U extends java.io.Serializable,java.lang.Double>> qvaluesTimes each parameter has been received. -
pvalues
The distribution we are trying to approximate. -
sumQ
The total number of external parameters that have reached each user. -
sumP
protected double sumPThe sum of the values we are trying to approximate -
unique
private final boolean uniqueIndicates if a piece of information is considered once (or each time it appears if false).
-
-
Constructor Details
-
AbstractFeatureKLDivergence
public AbstractFeatureKLDivergence(java.lang.String name, java.lang.String parameter, boolean userparam, boolean unique)Constructor.- Parameters:
name
- the name of the metric.userparam
- true if we are using a user parameter, false if we are using an information piece parameter.parameter
- the name of the parameter.unique
- true if a piece of information is considered once, false if it is considered each time it appears.
-
-
Method Details
-
calculate
public double calculate()Description copied from interface:SimulationMetric
Calculates the metric for the current state of the simulation.- Returns:
- the value of the metric for the current state of the simulation
-
updateUserFeatures
Description copied from class:AbstractFeatureIndividualSimulationMetric
Updates the necessary variables to compute a metric, in case the feature values we are using belongs to the creators of the information pieces received by the users in the network.- Specified by:
updateUserFeatures
in classAbstractFeatureIndividualSimulationMetric<U extends java.io.Serializable,I extends java.io.Serializable,P>
- Parameters:
iteration
- the new iteration.
-
updateInfoFeatures
Description copied from class:AbstractFeatureIndividualSimulationMetric
Updates the necessary variables to compute a metric, in case the feature values we are using belong to the information pieces received by the users in the network.- Specified by:
updateInfoFeatures
in classAbstractFeatureIndividualSimulationMetric<U extends java.io.Serializable,I extends java.io.Serializable,P>
- Parameters:
iteration
- the new iteration.
-
clear
public void clear()Description copied from interface:SimulationMetric
Resets the metric. -
initialize
protected void initialize()Description copied from class:AbstractIndividualSimulationMetric
Initializes all the variables needed for computing and updating the values of the metric.- Specified by:
initialize
in classAbstractIndividualSimulationMetric<U extends java.io.Serializable,I extends java.io.Serializable,P>
-