Class AbstractFeatureGlobalKLDivergence<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.AbstractFeatureGlobalKLDivergence<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>
Direct Known Subclasses:
FeatureGlobalKLDivergence, FeatureGlobalKLDivergenceInverse

public abstract class AbstractFeatureGlobalKLDivergence<U extends java.io.Serializable,​I extends java.io.Serializable,​F>
extends AbstractFeatureGlobalSimulationMetric<U,​I,​F>
This global metric computes the KL divergence of the priori distribution of the feature values over the whole set of information pieces, and the frequency of receival of these parameters for the set of users. Depending on the nature of the parameter, we differ two cases:
  • User parameters:
    • Priori distribution: The priori value for an individual user feature is computed as the sum over the set of users of the product of the number of pieces published by the user and the value of the user feature 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: In this case, for each received and seen information piece (by any user), we sum the value of each feature for the creator of the piece.
  • Information piece parameters:
    • Priori distribution:The priori value for an individual information piece feature is computed as the sum over the set of information pieces of the value of the feature for each feature. 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 by any user, we sum the value of each feature for the information piece.
In order to prevent divisions by zero, we apply an additive or Laplace smoothing over the different distributions. Doing so, the KL Divergence is set to be a real number (never NaN or Infinity).
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.util.Map<F,​java.lang.Double> pvalues
    The distribution we are trying to approximate.
    protected java.util.Map<F,​java.lang.Double> qvalues
    Times each parameter has been received.
    protected double sumP
    The sum of the values we are trying to approximate
    protected double sumQ
    The total number of features that have reached the different users.
    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.AbstractGlobalSimulationMetric

    data, initialized
  • Constructor Summary

    Constructors 
    Constructor Description
    AbstractFeatureGlobalKLDivergence​(java.lang.String name, java.lang.String feature, boolean userFeat, boolean unique)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    void clear()
    Resets the metric.
    protected void initialize()
    Initializes all the variables needed for computing and updating the values of the metric.
    protected void updateInfoFeature​(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 void updateUserFeature​(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, usesUserFeatures

    Methods inherited from class es.uam.eps.ir.relison.diffusion.metrics.AbstractGlobalSimulationMetric

    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.SimulationMetric

    calculate, calculate, initialize
  • Field Details

    • qvalues

      protected final java.util.Map<F,​java.lang.Double> qvalues
      Times each parameter has been received.
    • pvalues

      protected final java.util.Map<F,​java.lang.Double> pvalues
      The distribution we are trying to approximate.
    • sumQ

      protected double sumQ
      The total number of features that have reached the different users.
    • sumP

      protected double sumP
      The sum of the values we are trying to approximate
    • unique

      private final boolean unique
      Indicates if a piece of information is considered once (or each time it appears if false).
  • Constructor Details

    • AbstractFeatureGlobalKLDivergence

      public AbstractFeatureGlobalKLDivergence​(java.lang.String name, java.lang.String feature, boolean userFeat, boolean unique)
      Constructor.
      Parameters:
      name - the name of the metric.
      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