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) int
classIndex
Class index(package private) weka.core.FastVector
features
Attribute information for Wekaprivate java.util.Map<Pair<U>,java.lang.Integer>
instanceIndexer
Relation between test set nodes and the instances(package private) java.util.List<java.lang.String>
names
Names of the attributesprivate weka.core.Instances
testSet
Test setprivate weka.core.Instances
trainSet
Training set(package private) java.util.List<FeatureType>
types
Types of the attribute (Nominal, Continuous or Numerical, Class...) -
Constructor Summary
Constructors Constructor Description WekaInstanceReader()
Constructor. -
Method Summary
Modifier and Type Method Description Features
getFeatures()
Gets the features.weka.core.FastVector
getFVAttributes()
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.Instance
getTestInstance(U u, U v)
Obtains a test instance for a pair of nodesweka.core.Instances
getTestSet()
Obtains the test set instancesweka.core.Instances
getTrainSet()
Obtains the training set instancesboolean
readFeatures(java.lang.String featureFile)
Configures the features of the dataset.boolean
readTest(java.lang.String testFile, org.ranksys.formats.parsing.Parser<U> parser)
Reads the test set.boolean
readTrain(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:PatternReader
Configures the features of the dataset.- Specified by:
readFeatures
in 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:PatternReader
Reads the training set.- Specified by:
readTrain
in 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:PatternReader
Reads the test set.- Specified by:
readTest
in 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:PatternReader
Obtains the training set instances- Specified by:
getTrainSet
in interfacePatternReader<U,weka.core.Instances,weka.core.Instance>
- Returns:
- the training set instances
-
getTestSet
public weka.core.Instances getTestSet()Description copied from interface:PatternReader
Obtains the test set instances- Specified by:
getTestSet
in 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:PatternReader
Obtains a test instance for a pair of nodes- Specified by:
getTestInstance
in 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:PatternReader
Gets the features.- Specified by:
getFeatures
in interfacePatternReader<U,weka.core.Instances,weka.core.Instance>
- Returns:
- the features.
-