Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Tutorial Command Line Interface

cristinabaciu edited this page Oct 23, 2015 · 15 revisions

#Command Line Interface

The C interface can be used to interact with the LibNet library through a terminal on either Linux or Mac OSX operating systems.

##Two ways to use the command line interface:

  1. The first way is to put the paths to both the input and output files into a configuration file, in the same format as the config/example.ini file, and then use flags to configure and to run the program. In order to learn more about the flags go to the bin folder and type ./libnet --help.
  2. The second way is to use the interactive interface by typing the command ./libnet --interactive from the bin folder. This will guide you through the analysis by prompting you for the relevant information. In interactive mode all information is entered in by the user and no information is taken from configuration files.

##Installation

In order to run the c interface you will first need to run the following commands:

make (from the project's root directory)  
cd bin  
./generateHash  <filepath to your pairwise interaction file> (for this example you can choose ../test/data1/munin4_pairwise.txt)  
cd ../net  
make
cd ..  

Once the LibNet shared library has been created (net/lib/libnet.so on linux or net/lib/libnet.dynlib on OSX) the c interface should be made.

cd cli (from the project's root directory)
make
cd ..

##Generating hash for new pathway

In order to use a new pathway for the generateHash command:

cd bin (from the project's root directory)
./generateHash <filepath to new pairwise iteration file>
cd ../net
make clean; make
cd ../cli
make clean; make
cd ..

##Command line interface

###Flag based interface

./libnet --help  (to get a list of all the parameters you can set)

The main flags to set are "file-paths", "generate-factorgraph", "inference" and "learning". The file-paths flag specifies a config file containing the file paths to both the input and output files. See the config/test-data1_0.5_0.7.ini file to see a configuration that has already been generated.

##Usage

libnet [-gil] [--interactive] [--file-paths=file-paths] [--inference-use-logical-factorgraph] [--number-of-states=<int>] [--em-max-iterations=<int>] [--training-samples=<int>] [--log-likelihood-change-limit=<double>] [--parameters-change-limit=<double>] [--logging-on] [--maximum-a-posteriori-estimation] [--help] [--version]

###Flag descriptions  
 -g, --generate-factorgraph Generate factor graph from reaction logic
 -i, --inference           Run inference given the states of visible sets
 -l, --learning            Run learning using training dataset
 --interactive             Interactive mode
 --file-paths=file-paths   Path to config file that contains paths for input and output files
 --inference-use-logical-factorgraph Set this flag if, for inference, you would like to use the logic factorgraph file (created from pairwise interaction file) instead of the learnt factorgraph file for inference
 --number-of-states=<int>  Number of states for each node (default is 2)
 --em-max-iterations=<int> Maximum number of iterations in the EM algorithm - used in learning (default is 4000)
 --training-samples=<int>  Number of training samples used in expectation mimization - used in learning step(default 400)
 --log-likelihood-change-limit=<double> Stopping criteria: change in the ML - used in learning (default 1e-5)
 --parameters-change-limit=<double> Stopping criteria: change in the parameters - used in learning (default 1e-3)
 --logging-on              Set this flag if you would like the learning step to print out the status into a log file (this file will have the same name as the estimate parameters file with .log appended to the end)
 --maximum-a-posteriori-estimation Use this flag to set the MAP flag to 0 (default 1)
 --help                    Display help and exit
 --version                 Display version information and exit

####Example Commands

#####Generate Factor Graph

./libnet --file-paths=../config/test-data1_0.9_0.9.ini --generate-factorgraph 

#####Output

Generating factorgraph with: number of states 2 Factorgragh has been printed out into the following file: ../test/data1/logical_factorgraph.txt Factorgraph generation completed

#####Generate Factor Graph

./libnet --file-paths=../config/test-data1_0.9_0.9.ini --learning 

#####Output

Running Learning with: Max iterations 4000 number of states 2 log likelilhood change limit 0.000010 parameters change limit 0.001000 logging off MAP on Estimated Parameters (learnt factorgraph) have been written to: ../test/data1/estimated_parameters_0.9.txt Learning completed

#####Generate Factor Graph

./libnet --file-paths=../config/test-data1_0.9_0.9.ini --inference 

#####Output

Running Inference with: number of states 2 Posterior probabilities have been written to the following file: ../test/data1/posterior_probabilities_0.9_0.9.txt Inference completed

####Interactive mode

To use the interactive interface use the following command

./libnet --interactive

This command will perform all three major steps of the analysis with the files specified in the example.ini file.

###Interactive

Interactive mode will guide you through the analysis. You will be prompted to input the paths to both input and output files.

####Example Session

Starting Interactive Mode
>>
Would you like to generate a factorgraph from pairwise interactions [Y/n] y

Gathering information required to generated the factorgraph file from pairwise interactions
	Enter pairwise interaction filepath (input):  ../test/data1/munin4_pairwise.txt
	Enter factorgraph filepath (output):  ../test/data1/logical_factorgraph.txt
	Enter number of states [default 2]: 

Generating a factorgraph from pairwise interactions:	../test/data1/logical_factorgraph.txt
	Factorgragh has been output into the following factorgraph file: ../test/data1/logical_factorgraph.txt
	Factorgraph generation completed

Would you like to perform learning [Y/n] 

Gathering information required to perform learning
	Enter observed data filepath (input):  ../test/data1/visibleSet_0.9.txt
	Enter estimated parameters filepath (output):  ../test/data1/estimated_parameters_0.9.txt
	Would you like to have a log be generated for monitoring progress. If yes a "file.log" will be generated. [Y/n]  
	Enter max number of iterations for EM [default 400]: 
	Enter the stop criteriion log likelihood change limit [default 1e-5]: 
	Enter the stop criteriion parameters change limit [default 1e-3]: 
	Enter map flag (1 or 0) [default 1]: 
Running Learning
	Estimated Parameters have been written to the following file: ../test/data1/estimated_parameters_0.9.txt
	Learning completed

Would you like to perform inference [Y/n] 

Select yes if you would like to use a learnt factorgraph (estimated parameters from learning) file vs a logical factorgraph file [Y/n] n

Gathering information required to perform inference
	Enter factorgraph filepath (input):  ../test/data1/logical_factorgraph.txt
	Enter observed data filepath (input):   ../test/data1/visibleSet_0.9.txt
	Enter posterior probabilities filepath (output):  ../test/data1/posterior_probabilities_0.9_0.9.txt
	Enter number of states [default 2]: 
Running Inference
	Posterior probabilities have been written to the following file: ../test/data1/posterior_probabilities_0.9_0.9.txt
	Inference completed

Analysis Complete

Clone this wiki locally