Class WekaInstanceReader<U>
java.lang.Object
es.uam.eps.ir.relison.links.data.ml.weka.WekaInstanceReader<U>
- Type Parameters:
U- type of the users.
- All Implemented Interfaces:
PatternReader<U,weka.core.Instances,weka.core.Instance>
public class WekaInstanceReader<U> extends java.lang.Object implements PatternReader<U,weka.core.Instances,weka.core.Instance>
Reads link prediction instances from Weka.
-
Field Summary
Fields Modifier and Type Field Description (package private) intclassIndexClass index(package private) weka.core.FastVectorfeaturesAttribute information for Wekaprivate java.util.Map<Pair<U>,java.lang.Integer>instanceIndexerRelation between test set nodes and the instances(package private) java.util.List<java.lang.String>namesNames of the attributesprivate weka.core.InstancestestSetTest setprivate weka.core.InstancestrainSetTraining set(package private) java.util.List<FeatureType>typesTypes of the attribute (Nominal, Continuous or Numerical, Class...) -
Constructor Summary
Constructors Constructor Description WekaInstanceReader()Constructor. -
Method Summary
Modifier and Type Method Description FeaturesgetFeatures()Gets the features.weka.core.FastVectorgetFVAttributes()Get the weka version of the attributes (the FastVector)java.util.Map<Pair<U>,java.lang.Integer>getInstanceIndexer()Obtains the relation between the test set instances and the nodes of the network.weka.core.InstancegetTestInstance(U u, U v)Obtains a test instance for a pair of nodesweka.core.InstancesgetTestSet()Obtains the test set instancesweka.core.InstancesgetTrainSet()Obtains the training set instancesbooleanreadFeatures(java.lang.String featureFile)Configures the features of the dataset.booleanreadTest(java.lang.String testFile, org.ranksys.formats.parsing.Parser<U> parser)Reads the test set.booleanreadTrain(java.lang.String trainFile)Reads the training set.
-
Field Details
-
features
weka.core.FastVector featuresAttribute information for Weka -
types
java.util.List<FeatureType> typesTypes of the attribute (Nominal, Continuous or Numerical, Class...) -
names
java.util.List<java.lang.String> namesNames of the attributes -
classIndex
int classIndexClass index -
trainSet
private weka.core.Instances trainSetTraining set -
testSet
private weka.core.Instances testSetTest set -
instanceIndexer
Relation between test set nodes and the instances
-
-
Constructor Details
-
WekaInstanceReader
public WekaInstanceReader()Constructor.
-
-
Method Details
-
readFeatures
public boolean readFeatures(java.lang.String featureFile)Description copied from interface:PatternReaderConfigures the features of the dataset.- Specified by:
readFeaturesin interfacePatternReader<U,weka.core.Instances,weka.core.Instance>- Parameters:
featureFile- the file containing the description for the dataset features.- Returns:
- true if everything went OK, false if not.
-
readTrain
public boolean readTrain(java.lang.String trainFile)Description copied from interface:PatternReaderReads the training set.- Specified by:
readTrainin interfacePatternReader<U,weka.core.Instances,weka.core.Instance>- Parameters:
trainFile- file which contains the training instances.- Returns:
- true if everything went ok, false if not.
-
readTest
Description copied from interface:PatternReaderReads the test set.- Specified by:
readTestin interfacePatternReader<U,weka.core.Instances,weka.core.Instance>- Parameters:
testFile- file which contains the test instancesparser- parser for the user identifiers.- Returns:
- true if everything went OK, false if not.
-
getTrainSet
public weka.core.Instances getTrainSet()Description copied from interface:PatternReaderObtains the training set instances- Specified by:
getTrainSetin interfacePatternReader<U,weka.core.Instances,weka.core.Instance>- Returns:
- the training set instances
-
getTestSet
public weka.core.Instances getTestSet()Description copied from interface:PatternReaderObtains the test set instances- Specified by:
getTestSetin interfacePatternReader<U,weka.core.Instances,weka.core.Instance>- Returns:
- the test set instances
-
getInstanceIndexer
Obtains the relation between the test set instances and the nodes of the network.- Returns:
- the relation between the test set instances and the nodes of the network.
-
getTestInstance
Description copied from interface:PatternReaderObtains a test instance for a pair of nodes- Specified by:
getTestInstancein interfacePatternReader<U,weka.core.Instances,weka.core.Instance>- Parameters:
u- the first node.v- the second node.- Returns:
- null if the instance does not exist, a instance if it does.
-
getFVAttributes
public weka.core.FastVector getFVAttributes()Get the weka version of the attributes (the FastVector)- Returns:
- the FastVector containing the weka attributes.
-
getFeatures
Description copied from interface:PatternReaderGets the features.- Specified by:
getFeaturesin interfacePatternReader<U,weka.core.Instances,weka.core.Instance>- Returns:
- the features.
-