Class UserFeatureGiniComplement<U extends java.io.Serializable,I extends java.io.Serializable,F>
java.lang.Object
es.uam.eps.ir.relison.diffusion.metrics.AbstractGlobalSimulationMetric<U,I,F>
es.uam.eps.ir.relison.diffusion.metrics.features.AbstractFeatureGlobalSimulationMetric<U,I,F>
es.uam.eps.ir.relison.diffusion.metrics.features.global.UserFeatureGiniComplement<U,I,F>
- Type Parameters:
U- type of the users.I- type of the information pieces.F- type of the user / information pieces features.
- All Implemented Interfaces:
GlobalSimulationMetric<U,I,F>,SimulationMetric<U,I,F>
public class UserFeatureGiniComplement<U extends java.io.Serializable,I extends java.io.Serializable,F> extends AbstractFeatureGlobalSimulationMetric<U,I,F>
Metric that computes the complement of the Gini coefficient over the (user, feature) pairs.
If we use information pieces features (i.e. hashtags) the (user, feature) value counts the number of times
that the user has received information pieces using that feature. In case we use user features, it is just
how many times the user has received information from users with that feature.
-
Field Summary
Fields Modifier and Type Field Description private doublefreqsumSum of the frequencies.private java.util.Map<U,java.util.Map<F,java.lang.Double>>frequenciesMap for storing the frequency of the user/feature pairs.private static java.lang.StringGINIMetric name.private doublemainsumMain sum for the Gini coefficient.private java.util.Map<java.lang.Double,java.lang.Long>maximumPosAuxiliar map for computing Gini coefficient (contains the maximum position for each frequency).private java.util.Map<java.lang.Double,java.lang.Long>minimumPosAuxiliar map for computing Gini coefficient (contains the minimum position for each frequency).private longsizeTotal number of pairs.private booleanuniqueIndicates if a piece of information is considered once (or each time it appears if false).private java.util.TreeSet<java.lang.Double>valuesAuxiliar set containing the possible valuesFields inherited from class es.uam.eps.ir.relison.diffusion.metrics.AbstractGlobalSimulationMetric
data, initialized -
Constructor Summary
Constructors Constructor Description UserFeatureGiniComplement(java.lang.String feature, boolean userFeat, boolean unique)Constructor. -
Method Summary
Modifier and Type Method Description doublecalculate()Calculates the metric for the current state of the simulation.voidclear()Resets the metric.private doubleincreaseIntermediate(double freq)Computes the increment for frequencies between old and new.private doubleincreaseNew(double newfreq)Computes the increment for new frequencies.private doubleincreaseOld(double oldfreq)Computes the increment for old frequencies.protected voidinitialize()Initializes all the variables needed for computing and updating the values of the metric.protected voidupdateInfoFeature(Iteration<U,I,F> 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 voidupdateUserFeature(Iteration<U,I,F> 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.AbstractFeatureGlobalSimulationMetric
getFeature, update, usesUserFeaturesMethods inherited from class es.uam.eps.ir.relison.diffusion.metrics.AbstractGlobalSimulationMetric
getName, initialize, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface es.uam.eps.ir.relison.diffusion.metrics.SimulationMetric
calculate, initialize
-
Field Details
-
GINI
private static final java.lang.String GINIMetric name.- See Also:
- Constant Field Values
-
freqsum
private double freqsumSum of the frequencies. -
mainsum
private double mainsumMain sum for the Gini coefficient. -
size
private long sizeTotal number of pairs. -
frequencies
private final java.util.Map<U extends java.io.Serializable,java.util.Map<F,java.lang.Double>> frequenciesMap for storing the frequency of the user/feature pairs. -
minimumPos
private final java.util.Map<java.lang.Double,java.lang.Long> minimumPosAuxiliar map for computing Gini coefficient (contains the minimum position for each frequency). -
maximumPos
private final java.util.Map<java.lang.Double,java.lang.Long> maximumPosAuxiliar map for computing Gini coefficient (contains the maximum position for each frequency). -
values
private final java.util.TreeSet<java.lang.Double> valuesAuxiliar set containing the possible values -
unique
private final boolean uniqueIndicates if a piece of information is considered once (or each time it appears if false).
-
-
Constructor Details
-
UserFeatureGiniComplement
public UserFeatureGiniComplement(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
-
updateUserFeature
Description copied from class:AbstractFeatureGlobalSimulationMetricUpdates 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:
updateUserFeaturein classAbstractFeatureGlobalSimulationMetric<U extends java.io.Serializable,I extends java.io.Serializable,F>- Parameters:
iteration- the new iteration.
-
updateInfoFeature
Description copied from class:AbstractFeatureGlobalSimulationMetricUpdates 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:
updateInfoFeaturein classAbstractFeatureGlobalSimulationMetric<U extends java.io.Serializable,I extends java.io.Serializable,F>- Parameters:
iteration- the new iteration.
-
initialize
protected void initialize()Description copied from class:AbstractGlobalSimulationMetricInitializes all the variables needed for computing and updating the values of the metric.- Specified by:
initializein classAbstractGlobalSimulationMetric<U extends java.io.Serializable,I extends java.io.Serializable,F>
-
calculate
public double calculate()Description copied from interface:SimulationMetricCalculates the metric for the current state of the simulation.- Returns:
- the value of the metric for the current state of the simulation
-
clear
public void clear()Description copied from interface:SimulationMetricResets the metric. -
increaseOld
private double increaseOld(double oldfreq)Computes the increment for old frequencies.- Parameters:
oldfreq- old frequency.- Returns:
- the variation for the old frequency.
-
increaseNew
private double increaseNew(double newfreq)Computes the increment for new frequencies.- Parameters:
newfreq- new frequency.- Returns:
- the variation for the new frequency.
-
increaseIntermediate
private double increaseIntermediate(double freq)Computes the increment for frequencies between old and new.- Parameters:
freq- new frequency.- Returns:
- the variation for the new frequency.
-