Package moss

Class Predictor

java.lang.Object
moss.Predictor
All Implemented Interfaces:
Runnable

public class Predictor extends Object implements Runnable
Class for the graph edges predictor.
Since:
2020.10.09
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected moss.PredEdge[]
    the repository of predicted edges (hash table)
    static final int
    flag for predicting edges with destination node in rule body
    protected double
    the minimum confidence of an association rule as a fraction
    static final String
    the copyright information for this program
    static final int
    default prediction mode flags: none
    static final String
    the program description
    static final int
    flag for directed graphs/fragments
    protected double
    the minimum support of a rule as a fraction
    protected NamedGraph
    the list of graphs for which to predict edges (database)
    static final int
    flag for nodes that are in the body of a rule application
    protected PrintStream
    stream to write progress messages to
    protected int
    the maximum size of substructures to use (number of nodes)
    protected int
    the minimum size of substructures to use (number of nodes)
    protected int
    the prediction mode flags
    static final int
    flag for predicting edges with "new" destination node
    protected double
    the (relative) weight of a predicted edges to a "new" node
    static final int
    flag for no prediction statistics output
    protected int
    the number of patterns underlying the graph rules
    the map from names to graph patterns
    protected GraphReader
    the graph pattern file reader
    protected NamedGraph
    the list of patterns underlying the graph rules
    protected int
    the size of the repository (number of predicted edges)
    protected moss.PredEdge
    the list of predicted edges
    protected int
    the number of graph rules
    protected TableReader
    the graph rule file reader
    protected moss.GraphRule
    the list of graph rules with which to predict the edges
    protected int
    the minimum support of a rule as an absolute value
    protected int
    the numbers of target graphs in database
    protected GraphReader
    the target graph file reader
    static final int
    flag for verbose reporting
    static final String
    the version of this program
    protected Writer
    the file to write the predicted edges to
    protected double
    the (relative) weight of a predicted edges to existing nodes
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an empty edge predictor with default parameter settings.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Abort the edge predictor (if running as a thread).
    Get the error status of the edge prediction process.
    void
    init(String[] args)
    Initialize the edge predictor from command line arguments.
    static void
    main(String[] args)
    Command line invocation of the edge predictor.
    protected void
    Load substructures, graph rules and prediction graph and start the search.
    void
    run()
    Run the edge prediction and clean up after it is finished.
    void
    setConf(double conf)
    Set the minimum rule confidence.
    void
    setInput(String fn_pats, String fn_rules, String fn_trgs, String format)
    Set the input readers.
    void
    setInput(GraphReader patrdr, TableReader rulerdr, GraphReader trgrdr)
    Set the input readers.
    void
    setMode(int mode)
    Set the prediction mode.
    void
    setOutput(Writer writer)
    Set the output writer.
    void
    setOutput(String fn_edge)
    Set the output writer.
    void
    setSizes(int min, int max)
    Set the minimum and maximum antecedent/body pattern size.
    void
    setSupp(double supp)
    Set the minimum rule support.
    void
    setWeights(double xstwgt, double newwgt)
    Set the weight of edges to new and existing nodes (not in body).
    void
    Print statistics about the prediction.
    protected void
    Clean up after the edge prediction finished or was aborted.

    Methods inherited from class java.lang.Object

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

    • DESCRIPTION

      public static final String DESCRIPTION
      the program description
      See Also:
    • VERSION

      public static final String VERSION
      the version of this program
      See Also:
    • DIRECTED

      public static final int DIRECTED
      flag for directed graphs/fragments
      See Also:
    • BODYNODE

      public static final int BODYNODE
      flag for predicting edges with destination node in rule body
      See Also:
    • NEWNODE

      public static final int NEWNODE
      flag for predicting edges with "new" destination node
      See Also:
    • VERBOSE

      public static final int VERBOSE
      flag for verbose reporting
      See Also:
    • NOSTATS

      public static final int NOSTATS
      flag for no prediction statistics output
      See Also:
    • DEFAULT

      public static final int DEFAULT
      default prediction mode flags: none
      See Also:
    • ISINBODY

      public static final int ISINBODY
      flag for nodes that are in the body of a rule application
      See Also:
    • mode

      protected int mode
      the prediction mode flags
    • fsupp

      protected double fsupp
      the minimum support of a rule as a fraction
    • supp

      protected int supp
      the minimum support of a rule as an absolute value
    • conf

      protected double conf
      the minimum confidence of an association rule as a fraction
    • min

      protected int min
      the minimum size of substructures to use (number of nodes)
    • max

      protected int max
      the maximum size of substructures to use (number of nodes)
    • newwgt

      protected double newwgt
      the (relative) weight of a predicted edges to a "new" node
    • xstwgt

      protected double xstwgt
      the (relative) weight of a predicted edges to existing nodes
    • patrdr

      protected GraphReader patrdr
      the graph pattern file reader
    • rulerdr

      protected TableReader rulerdr
      the graph rule file reader
    • trgrdr

      protected GraphReader trgrdr
      the target graph file reader
    • pats

      protected NamedGraph pats
      the list of patterns underlying the graph rules
    • patcnt

      protected int patcnt
      the number of patterns underlying the graph rules
    • patmap

      protected HashMap<String,NamedGraph> patmap
      the map from names to graph patterns
    • rules

      protected moss.GraphRule rules
      the list of graph rules with which to predict the edges
    • rulcnt

      protected int rulcnt
      the number of graph rules
    • graphs

      protected NamedGraph graphs
      the list of graphs for which to predict edges (database)
    • trgcnt

      protected int trgcnt
      the numbers of target graphs in database
    • bins

      protected moss.PredEdge[] bins
      the repository of predicted edges (hash table)
    • preds

      protected moss.PredEdge preds
      the list of predicted edges
    • pecnt

      protected int pecnt
      the size of the repository (number of predicted edges)
    • writer

      protected Writer writer
      the file to write the predicted edges to
    • log

      protected PrintStream log
      stream to write progress messages to
  • Constructor Details

    • Predictor

      public Predictor()
      Create an empty edge predictor with default parameter settings.
      Since:
      2020.10.09 (Christian Borgelt)
  • Method Details

    • setMode

      public void setMode(int mode)
      Set the prediction mode.

      The prediction mode is a combination of the prediction mode flags, e.g. VERBOSE or NOSTATS.

      Parameters:
      mode - the prediction mode
      Since:
      2020.10.19 (Christian Borgelt)
    • setSizes

      public void setSizes(int min, int max)
      Set the minimum and maximum antecedent/body pattern size.
      Parameters:
      min - the minimum pattern size (number of nodes)
      max - the maximum pattern size (number of nodes)
      Since:
      2020.10.19 (Christian Borgelt)
    • setSupp

      public void setSupp(double supp)
      Set the minimum rule support.
      Parameters:
      supp - the minimum support of association rules
      Since:
      2020.10.04 (Christian Borgelt)
    • setConf

      public void setConf(double conf)
      Set the minimum rule confidence.
      Parameters:
      conf - the minimum confidence of association rules
      Since:
      2020.10.04 (Christian Borgelt)
    • setWeights

      public void setWeights(double xstwgt, double newwgt)
      Set the weight of edges to new and existing nodes (not in body).
      Parameters:
      xstwgt - the (relative) weight of edges to existing nodes
      newwgt - the (relative) weight of edges to new nodes
      Since:
      2020.11.15 (Christian Borgelt)
    • setInput

      public void setInput(String fn_pats, String fn_rules, String fn_trgs, String format) throws IOException
      Set the input readers.
      Parameters:
      fn_pats - the name of the graph patterns file
      fn_rules - the name of the graph rules file
      fn_trgs - the name of the target graphs file
      format - the format of the patterns / graphs file
      Throws:
      IOException - if some file operation failed
      Since:
      2020.10.19 (Christian Borgelt)
    • setInput

      public void setInput(GraphReader patrdr, TableReader rulerdr, GraphReader trgrdr) throws IOException
      Set the input readers.
      Parameters:
      patrdr - the reader from which to read the patterns
      rulerdr - the reader from which to read the rules
      trgrdr - the reader from which to read the target graphs
      Throws:
      IOException - if some file operation failed
      Since:
      2020.10.19 (Christian Borgelt)
    • setOutput

      public void setOutput(String fn_edge) throws IOException
      Set the output writer.
      Parameters:
      fn_edge - the name of the file for the predicted edges
      Throws:
      IOException - if some file operation failed
      Since:
      2020.10.19 (Christian Borgelt)
    • setOutput

      public void setOutput(Writer writer)
      Set the output writer.
      Parameters:
      writer - the writer to write the predicted edges to
      Since:
      2020.10.19 (Christian Borgelt)
    • init

      public void init(String[] args) throws IOException
      Initialize the edge predictor from command line arguments.
      Parameters:
      args - the command line arguments
      Throws:
      IOException - if some file operation failed
      Since:
      2020.10.19 (Christian Borgelt)
    • predict

      protected void predict() throws IOException
      Load substructures, graph rules and prediction graph and start the search.
      Throws:
      IOException - if some file operation failed
      Since:
      2020.10.19 (Christian Borgelt)
    • term

      protected void term() throws IOException
      Clean up after the edge prediction finished or was aborted.
      Throws:
      IOException - if some file operation failed
      Since:
      2020.10.19 (Christian Borgelt)
    • run

      public void run()
      Run the edge prediction and clean up after it is finished.
      Specified by:
      run in interface Runnable
      Since:
      2020.10.19 (Christian Borgelt)
    • abort

      public void abort()
      Abort the edge predictor (if running as a thread).
      Since:
      2020.10.19 (Christian Borgelt)
    • getError

      public Throwable getError()
      Get the error status of the edge prediction process.

      With this function it can be checked, after the prediction with the run() method has terminated, whether an error occurred in the prediction. Note that an external abort with the function abort() does not trigger an exception to be thrown.

      Returns:
      the exception that occurred in the edge prediction or null if the prediction was successful
      Since:
      2020.10.19 (Christian Borgelt)
    • stats

      public void stats()
      Print statistics about the prediction.
      Since:
      2020.10.19 (Christian Borgelt)
    • main

      public static void main(String[] args)
      Command line invocation of the edge predictor.
      Parameters:
      args - the command line arguments
      Since:
      2020.10.19 (Christian Borgelt)