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>classesPossible classes.private java.util.Map<U,java.util.Map<U,Instance<U>>>destInstancesInstances identified by the destination node of the edge.private FeatureInformationfeaturesInfoInformation about the different features in the dataset.private java.util.Map<U,java.util.Map<U,Instance<U>>>originInstancesInstances identified by the origin node of the edge.private intsizeSize 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 voidaddInstance(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.FeatureInformationgetFeatInfo()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).intgetNumInstances()Obtains the number of instances in the set.java.util.Set<U>getOriginUsers()Obtains the users with adjacent links in the set.
-
Field Details
-
featuresInfo
Information about the different features in the dataset. -
originInstances
Instances identified by the origin node of the edge. -
destInstances
Instances identified by the destination node of the edge. -
classes
private final java.util.Set<java.lang.Integer> classesPossible classes. -
size
private int sizeSize of the instance set.
-
-
Constructor Details
-
InstanceSet
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
Obtain the whole set of instances.- Returns:
- a stream with all the instances.
-
getAllInstancesWithOrigin
Obtain the set of instances for a user (as edge origin).- Parameters:
u- the user.- Returns:
- the set of instances for the user.
-
getAllInstancesWithDest
Obtain the set of instances for a user (as edge destination).- Parameters:
v- the user.- Returns:
- the set of instances for the user.
-
getInstance
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
Adds an instance to the set.- Parameters:
instance- the instance.
-
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
Obtains the users with adjacent links in the set.- Returns:
- the users with adjacent links in the set.
-
getDestUsers
Obtains the users with incident links in the set.- Returns:
- the users with incident links in the set.
-