Class FeatureIndividualEntropy<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.FeatureIndividualEntropy<U,I,P>
- Type Parameters:
U
- type of the user.I
- type of the information.P
- type of the parameters.
- All Implemented Interfaces:
IndividualSimulationMetric<U,I,P>
,SimulationMetric<U,I,P>
public class FeatureIndividualEntropy<U extends java.io.Serializable,I extends java.io.Serializable,P> extends AbstractFeatureIndividualSimulationMetric<U,I,P>
It computes the entropy of the distribution of times that the different values
of a user or information piece feature has reached the different users in the network
during a simulation.
We differ two cases:
a) User parameters: (Ex.: Communities) In this case, we take the values of the parameter
for the creators of the received information pieces.
b) Information parameters: (Ex: hashtags) In this case, we take the values of the parameters
for the different information pieces which are received and observed by each individual user.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ENTROPY
Name fixed value.private java.util.Map<U,java.util.Map<P,java.lang.Double>>
indivFeatCounter
For each user, registers the number of times each feature value has been received.private java.util.Map<U,java.lang.Double>
sum
For each user, this map register the total number of times each user it has received a feature value.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 FeatureIndividualEntropy(java.lang.String feature, boolean userFeat, boolean unique)
Constructor. -
Method Summary
Modifier and Type Method Description double
calculate()
Calculates the metric for the current state of the simulation.double
calculate(U user)
Calculates the metric value for a single user.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.private void
updateMap(U u, java.util.Map<P,java.lang.Double> aux)
Internal function for updating the individual and counter maps.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, calculateIndividuals
Methods inherited from interface es.uam.eps.ir.relison.diffusion.metrics.SimulationMetric
calculate, initialize
-
Field Details
-
ENTROPY
private static final java.lang.String ENTROPYName fixed value.- See Also:
- Constant Field Values
-
sum
For each user, this map register the total number of times each user it has received a feature value. Ex: if there are four possible feature values, A, B, C and D, and, for user u, value A has been received thrice (1 in iteration 1, 2 in iteration 3) , value B has been received once (in iteration 2), value C has not been received, and value D has been received five times (3 in iteration 2 and 2 in iteration 4), the value of this map for user u will be equal to 3+1+0+5=9. -
indivFeatCounter
private final java.util.Map<U extends java.io.Serializable,java.util.Map<P,java.lang.Double>> indivFeatCounterFor each user, registers the number of times each feature value has been received. Ex: If there are four possible feature values, A, B, C and D, and, for user u, value A has been received thrice (1 in iteration 1, 2 in iteration 3) , value B has been received once (in iteration 2), value C has not been received, and value D has been received five times (3 in iteration 2 and 2 in iteration 4), the map for user u will contain pairs (A,3),(B,1),(C,0),(D,5). -
unique
private final boolean uniqueIndicates if a piece of information is considered once (or each time it appears if false).
-
-
Constructor Details
-
FeatureIndividualEntropy
public FeatureIndividualEntropy(java.lang.String feature, boolean userFeat, boolean unique)Constructor.- Parameters:
userFeat
- true if we are using a user feature, false if we are using an information piece feature.feature
- the name of the feature.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.
-
updateMap
Internal function for updating the individual and counter maps.- Parameters:
u
- the user.aux
- an auxiliary map containing the new increments of several features for user u.
-
calculate
Description copied from interface:IndividualSimulationMetric
Calculates the metric value for a single user.- Parameters:
user
- the single user.- Returns:
- the value of the metric, NaN if something failed.
-
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>
-