Class InstanceSet<U>

java.lang.Object
es.uam.eps.ir.relison.links.data.letor.InstanceSet<U>
Type Parameters:
U - Type of the users.

public class InstanceSet<U>
extends java.lang.Object
Class that represents a machine learning dataset for link prediction / contact recommendation.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.util.Set<java.lang.Integer> classes
    Possible classes.
    private java.util.Map<U,​java.util.Map<U,​Instance<U>>> destInstances
    Instances identified by the destination node of the edge.
    private FeatureInformation featuresInfo
    Information about the different features in the dataset.
    private java.util.Map<U,​java.util.Map<U,​Instance<U>>> originInstances
    Instances identified by the origin node of the edge.
    private int size
    Size of the instance set.
  • Constructor Summary

    Constructors 
    Constructor Description
    InstanceSet​(FeatureInformation featuresInfo)
    Constructor.
    InstanceSet​(FeatureInformation featuresInfo, java.util.stream.Stream<Instance<U>> instances)
    Constructor.
    InstanceSet​(java.util.List<java.lang.String> featureNames, java.util.List<FeatureType> featureTypes)
    Constructor.
    InstanceSet​(java.util.List<java.lang.String> featureNames, java.util.List<FeatureType> featureTypes, java.util.stream.Stream<Instance<U>> instances)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    void addInstance​(Instance<U> instance)
    Adds an instance to the set.
    java.util.stream.Stream<Instance<U>> getAllInstances()
    Obtain the whole set of instances.
    java.util.stream.Stream<Instance<U>> getAllInstancesWithDest​(U v)
    Obtain the set of instances for a user (as edge destination).
    java.util.stream.Stream<Instance<U>> getAllInstancesWithOrigin​(U u)
    Obtain the set of instances for a user (as edge origin).
    java.util.Set<java.lang.Integer> getClasses()
    Obtains the set of classes.
    java.util.Set<U> getDestUsers()
    Obtains the users with incident links in the set.
    FeatureInformation getFeatInfo()
    Returns an object containing information about the parameters.
    java.util.Optional<Instance<U>> getInstance​(U u, U v)
    Gets an individual instance (if it exists).
    int getNumInstances()
    Obtains the number of instances in the set.
    java.util.Set<U> getOriginUsers()
    Obtains the users with adjacent links in the set.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • featuresInfo

      private final FeatureInformation featuresInfo
      Information about the different features in the dataset.
    • originInstances

      private final java.util.Map<U,​java.util.Map<U,​Instance<U>>> originInstances
      Instances identified by the origin node of the edge.
    • destInstances

      private final java.util.Map<U,​java.util.Map<U,​Instance<U>>> destInstances
      Instances identified by the destination node of the edge.
    • classes

      private final java.util.Set<java.lang.Integer> classes
      Possible classes.
    • size

      private int size
      Size of the instance set.
  • Constructor Details

    • InstanceSet

      public InstanceSet​(FeatureInformation featuresInfo)
      Constructor.
      Parameters:
      featuresInfo - information about the features.
    • InstanceSet

      public InstanceSet​(java.util.List<java.lang.String> featureNames, java.util.List<FeatureType> featureTypes)
      Constructor.
      Parameters:
      featureNames - names of the features.
      featureTypes - types of the features.
    • InstanceSet

      public InstanceSet​(FeatureInformation featuresInfo, java.util.stream.Stream<Instance<U>> instances)
      Constructor.
      Parameters:
      featuresInfo - information about the features.
      instances - a list of instances.
    • InstanceSet

      public InstanceSet​(java.util.List<java.lang.String> featureNames, java.util.List<FeatureType> featureTypes, java.util.stream.Stream<Instance<U>> instances)
      Constructor.
      Parameters:
      featureNames - names of the features.
      featureTypes - types of the features.
      instances - a list of instances.
  • Method Details

    • getAllInstances

      public java.util.stream.Stream<Instance<U>> getAllInstances()
      Obtain the whole set of instances.
      Returns:
      a stream with all the instances.
    • getAllInstancesWithOrigin

      public java.util.stream.Stream<Instance<U>> getAllInstancesWithOrigin​(U u)
      Obtain the set of instances for a user (as edge origin).
      Parameters:
      u - the user.
      Returns:
      the set of instances for the user.
    • getAllInstancesWithDest

      public java.util.stream.Stream<Instance<U>> getAllInstancesWithDest​(U v)
      Obtain the set of instances for a user (as edge destination).
      Parameters:
      v - the user.
      Returns:
      the set of instances for the user.
    • getInstance

      public java.util.Optional<Instance<U>> getInstance​(U u, U v)
      Gets an individual instance (if it exists).
      Parameters:
      u - the origin user.
      v - the destination user.
      Returns:
      the instance if it exists, an empty object otherwise.
    • addInstance

      public void addInstance​(Instance<U> instance)
      Adds an instance to the set.
      Parameters:
      instance - the instance.
    • getFeatInfo

      public FeatureInformation getFeatInfo()
      Returns an object containing information about the parameters.
      Returns:
      the information about the parameters.
    • getClasses

      public java.util.Set<java.lang.Integer> getClasses()
      Obtains the set of classes.
      Returns:
      the set of classes.
    • getNumInstances

      public int getNumInstances()
      Obtains the number of instances in the set.
      Returns:
      the number of instances in the set.
    • getOriginUsers

      public java.util.Set<U> getOriginUsers()
      Obtains the users with adjacent links in the set.
      Returns:
      the users with adjacent links in the set.
    • getDestUsers

      public java.util.Set<U> getDestUsers()
      Obtains the users with incident links in the set.
      Returns:
      the users with incident links in the set.