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 Weka
    private 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 attributes
    private weka.core.Instances testSet
    Test set
    private 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 nodes
    weka.core.Instances getTestSet()
    Obtains the test set instances
    weka.core.Instances getTrainSet()
    Obtains the training set instances
    boolean 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • features

      weka.core.FastVector features
      Attribute information for Weka
    • types

      java.util.List<FeatureType> types
      Types of the attribute (Nominal, Continuous or Numerical, Class...)
    • names

      java.util.List<java.lang.String> names
      Names of the attributes
    • classIndex

      int classIndex
      Class index
    • trainSet

      private weka.core.Instances trainSet
      Training set
    • testSet

      private weka.core.Instances testSet
      Test set
    • instanceIndexer

      private java.util.Map<Pair<U>,​java.lang.Integer> instanceIndexer
      Relation between test set nodes and the instances
  • Constructor Details

  • 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 interface PatternReader<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 interface PatternReader<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

      public boolean readTest​(java.lang.String testFile, org.ranksys.formats.parsing.Parser<U> parser)
      Description copied from interface: PatternReader
      Reads the test set.
      Specified by:
      readTest in interface PatternReader<U,​weka.core.Instances,​weka.core.Instance>
      Parameters:
      testFile - file which contains the test instances
      parser - 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 interface PatternReader<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 interface PatternReader<U,​weka.core.Instances,​weka.core.Instance>
      Returns:
      the test set instances
    • getInstanceIndexer

      public java.util.Map<Pair<U>,​java.lang.Integer> 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

      public weka.core.Instance getTestInstance​(U u, U v)
      Description copied from interface: PatternReader
      Obtains a test instance for a pair of nodes
      Specified by:
      getTestInstance in interface PatternReader<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

      public Features getFeatures()
      Description copied from interface: PatternReader
      Gets the features.
      Specified by:
      getFeatures in interface PatternReader<U,​weka.core.Instances,​weka.core.Instance>
      Returns:
      the features.