Package moss
Class Predictor
java.lang.Object
moss.Predictor
- All Implemented Interfaces:
Runnable
Class for the graph edges predictor.
- Since:
- 2020.10.09
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected moss.PredEdge[]
the repository of predicted edges (hash table)static final int
flag for predicting edges with destination node in rule bodyprotected double
the minimum confidence of an association rule as a fractionstatic final String
the copyright information for this programstatic final int
default prediction mode flags: nonestatic final String
the program descriptionstatic final int
flag for directed graphs/fragmentsprotected double
the minimum support of a rule as a fractionprotected 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 applicationprotected PrintStream
stream to write progress messages toprotected 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 flagsstatic final int
flag for predicting edges with "new" destination nodeprotected double
the (relative) weight of a predicted edges to a "new" nodestatic final int
flag for no prediction statistics outputprotected int
the number of patterns underlying the graph rulesprotected HashMap<String,
NamedGraph> the map from names to graph patternsprotected GraphReader
the graph pattern file readerprotected NamedGraph
the list of patterns underlying the graph rulesprotected int
the size of the repository (number of predicted edges)protected moss.PredEdge
the list of predicted edgesprotected int
the number of graph rulesprotected TableReader
the graph rule file readerprotected moss.GraphRule
the list of graph rules with which to predict the edgesprotected int
the minimum support of a rule as an absolute valueprotected int
the numbers of target graphs in databaseprotected GraphReader
the target graph file readerstatic final int
flag for verbose reportingstatic final String
the version of this programprotected Writer
the file to write the predicted edges toprotected double
the (relative) weight of a predicted edges to existing nodes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
Abort the edge predictor (if running as a thread).getError()
Get the error status of the edge prediction process.void
Initialize the edge predictor from command line arguments.static void
Command line invocation of the edge predictor.protected void
predict()
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
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
Set the output writer.void
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
stats()
Print statistics about the prediction.protected void
term()
Clean up after the edge prediction finished or was aborted.
-
Field Details
-
DESCRIPTION
the program description- See Also:
-
VERSION
the version of this program- See Also:
-
COPYRIGHT
the copyright information for this program- See Also:
-
DIRECTED
public static final int DIRECTEDflag for directed graphs/fragments- See Also:
-
BODYNODE
public static final int BODYNODEflag for predicting edges with destination node in rule body- See Also:
-
NEWNODE
public static final int NEWNODEflag for predicting edges with "new" destination node- See Also:
-
VERBOSE
public static final int VERBOSEflag for verbose reporting- See Also:
-
NOSTATS
public static final int NOSTATSflag for no prediction statistics output- See Also:
-
DEFAULT
public static final int DEFAULTdefault prediction mode flags: none- See Also:
-
ISINBODY
public static final int ISINBODYflag for nodes that are in the body of a rule application- See Also:
-
mode
protected int modethe prediction mode flags -
fsupp
protected double fsuppthe minimum support of a rule as a fraction -
supp
protected int suppthe minimum support of a rule as an absolute value -
conf
protected double confthe minimum confidence of an association rule as a fraction -
min
protected int minthe minimum size of substructures to use (number of nodes) -
max
protected int maxthe maximum size of substructures to use (number of nodes) -
newwgt
protected double newwgtthe (relative) weight of a predicted edges to a "new" node -
xstwgt
protected double xstwgtthe (relative) weight of a predicted edges to existing nodes -
patrdr
the graph pattern file reader -
rulerdr
the graph rule file reader -
trgrdr
the target graph file reader -
pats
the list of patterns underlying the graph rules -
patcnt
protected int patcntthe number of patterns underlying the graph rules -
patmap
the map from names to graph patterns -
rules
protected moss.GraphRule rulesthe list of graph rules with which to predict the edges -
rulcnt
protected int rulcntthe number of graph rules -
graphs
the list of graphs for which to predict edges (database) -
trgcnt
protected int trgcntthe numbers of target graphs in database -
bins
protected moss.PredEdge[] binsthe repository of predicted edges (hash table) -
preds
protected moss.PredEdge predsthe list of predicted edges -
pecnt
protected int pecntthe size of the repository (number of predicted edges) -
writer
the file to write the predicted edges to -
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
orNOSTATS
.- 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 nodesnewwgt
- 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 filefn_rules
- the name of the graph rules filefn_trgs
- the name of the target graphs fileformat
- 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 patternsrulerdr
- the reader from which to read the rulestrgrdr
- the reader from which to read the target graphs- Throws:
IOException
- if some file operation failed- Since:
- 2020.10.19 (Christian Borgelt)
-
setOutput
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
Set the output writer.- Parameters:
writer
- the writer to write the predicted edges to- Since:
- 2020.10.19 (Christian Borgelt)
-
init
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
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
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. -
abort
public void abort()Abort the edge predictor (if running as a thread).- Since:
- 2020.10.19 (Christian Borgelt)
-
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 functionabort()
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
Command line invocation of the edge predictor.- Parameters:
args
- the command line arguments- Since:
- 2020.10.19 (Christian Borgelt)
-