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.FastVectorattributesAttributes of the patterns.private weka.classifiers.ClassifierclassifierWeka classifier.private java.util.Map<Pair<U>,java.lang.Integer>relationRelation between pairs of users and the test patternsprivate weka.core.InstancestestInstancesTest instances.private weka.core.InstancestrainInstancesTraining 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:LinkPredictorGiven 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:
getPredictionin interfaceLinkPredictor<U>- Specified by:
getPredictionin 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).
-