Class SupervisedLinkPredictor<U>
java.lang.Object
es.uam.eps.ir.relison.links.linkprediction.AbstractLinkPredictor<U>
es.uam.eps.ir.relison.links.linkprediction.SupervisedLinkPredictor<U>
- Type Parameters:
U
- type of the users.
- All Implemented Interfaces:
LinkPredictor<U>
public class SupervisedLinkPredictor<U> extends AbstractLinkPredictor<U>
A supervised link prediction method, based on Weka classifiers.
-
Field Summary
Fields Modifier and Type Field Description private weka.core.FastVector
attributes
Attributes of the patterns.private weka.classifiers.Classifier
classifier
Weka classifier.private java.util.Map<Pair<U>,java.lang.Integer>
relation
Relation between pairs of users and the test patternsprivate weka.core.Instances
testInstances
Test instances.private weka.core.Instances
trainInstances
Training instances. -
Constructor Summary
Constructors Constructor Description SupervisedLinkPredictor(Graph<U> graph, java.util.Comparator<org.ranksys.core.util.tuples.Tuple2od<Pair<U>>> comparator, weka.classifiers.Classifier classifier, weka.core.Instances trainInstances, weka.core.Instances testInstances, java.util.Map<Pair<U>,java.lang.Integer> relation, weka.core.FastVector attributes)
Constructor.SupervisedLinkPredictor(Graph<U> graph, weka.classifiers.Classifier classifier, weka.core.Instances trainInstances, weka.core.Instances testInstances, java.util.Map<Pair<U>,java.lang.Integer> relation, weka.core.FastVector attributes)
Constructor. -
Method Summary
Modifier and Type Method Description Prediction<U>
getPrediction(int maxLength, java.util.function.Predicate<Pair<U>> filter)
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm.Methods inherited from class es.uam.eps.ir.relison.links.linkprediction.AbstractLinkPredictor
getComparator, getGraph, getPrediction, getPrediction, getPrediction, getPrediction, getPredictionScore
-
Field Details
-
classifier
private final weka.classifiers.Classifier classifierWeka classifier. It provides the scores for each element. -
trainInstances
private final weka.core.Instances trainInstancesTraining instances. They are used for building the model -
testInstances
private final weka.core.Instances testInstancesTest instances. Represent the edges we want to predict. -
relation
Relation between pairs of users and the test patterns -
attributes
private final weka.core.FastVector attributesAttributes of the patterns.
-
-
Constructor Details
-
SupervisedLinkPredictor
public SupervisedLinkPredictor(Graph<U> graph, java.util.Comparator<org.ranksys.core.util.tuples.Tuple2od<Pair<U>>> comparator, weka.classifiers.Classifier classifier, weka.core.Instances trainInstances, weka.core.Instances testInstances, java.util.Map<Pair<U>,java.lang.Integer> relation, weka.core.FastVector attributes)Constructor.- Parameters:
graph
- the social network graph.comparator
- comparator for ordering the different pairs.classifier
- a classifier that performs the prediction.trainInstances
- instances for building the model.testInstances
- instances for applying the model.relation
- relation between pairs of users and test instances.attributes
- the list of attributes.
-
SupervisedLinkPredictor
public SupervisedLinkPredictor(Graph<U> graph, weka.classifiers.Classifier classifier, weka.core.Instances trainInstances, weka.core.Instances testInstances, java.util.Map<Pair<U>,java.lang.Integer> relation, weka.core.FastVector attributes)Constructor.- Parameters:
graph
- the social network graph.classifier
- a classifier that performs the prediction.trainInstances
- instances for building the model.testInstances
- instances for applying the model.relation
- relation between pairs of users and test instances.attributes
- the list of attributes.
-
-
Method Details
-
getPrediction
Description copied from interface:LinkPredictor
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm. It only ranks those user pairs which pass a given filter. It returns a limited number of such pairs.- Specified by:
getPrediction
in interfaceLinkPredictor<U>
- Specified by:
getPrediction
in classAbstractLinkPredictor<U>
- Parameters:
maxLength
- the maximum size of the link prediction list.filter
- a filter to indicate which user pairs shall be ranked.- Returns:
- a sorted list containing the user-user pairs and the link prediction score (in descending score order).
-