To install and run the program, follow these steps:
- Clone this repository to your local machine.
- Install the required dependencies by running the command
pip install -r requirements.txt
. - Run the program using the following command
python relational_pattern_lookout.py --data_dir <DATA_DIRECTORY> --data_name <DATASET_NAME> --file_name <FILE_NAME> --save_pattern_dir <DIRECTORY_NAME_FOR_SAVING_PATTERNS>
The program takes a dataset and a knowledge graph as inputs, and outputs the locations of specific patterns within the dataset. To use the program, follow these steps:
- Prepare your dataset and knowledge graph files in the appropriate format normally in a text set where we have {h,r,t}.
- Run the program using the following command
python relational_pattern_lookout.py --data_dir <DATA_DIRECTORY> --data_name <DATASET_NAME> --file_name <FILE_NAME> --save_pattern_dir <DIRECTORY_NAME_FOR_SAVING_PATTERNS>
DATA_DIRECTORY is the directory containing the dataset
DATASET_NAME is the name of the dataset file (including the extension)
FILE_NAME is the name of the file to save the identified patterns in (including the extension)
DIRECTORY_NAME_FOR_SAVING_PATTERNS is the directory name for saving the identified patterns. The program will output the detected patterns in the given location
.
├── data/
│ └── dataset1/
│ │ ├── saved_patterns/
│ │ │ ├── implication_patterns.txt
│ │ │ ├── inverse_patterns.txt
│ │ │ ├── reflection_patterns.txt
│ │ │ ├── symmetric_patterns.txt
│ │ │ ├── transitive_patterns.txt
│ │ │ └── composition_patterns.txt
│ │ └── train.txt
│ └── dataset2/
│ │ └── ...
├── utils/
│ ├── utility_functions.py
│ └── ...
├── temporal_pattern/
│ ├── evaluation.py
│ ├── run.py
│ ├── temporal_pattern_lookout.py
│ ├── tpl.py
│ ├── utilities.py
│ └── ...
├── README.md
├── requirements.txt
├── .gitignore
├── relational_pattern_lookout.py
└── ...
- relational_pattern_lookout.py: This is the main file for the statistical pattern lookout. It contains the main function that calls the other functions in the program.
- utility_functions.py: This file contains the utility functions (including the codes to find statistical patterns) used in the program.
- This script is to find pattern in (Temporal) Knowledge Graph. The file format is in quaternion (subject, predicate, object, time) or triples ((subject, predicate, object).
- Unzip the data.zip in the same folder as folder 'temporal_pattern_lookout'
How to run:
two hyperparameters needed to be determined, i.e. dataset and threshold for pattern lookup table.
example:
- python run.py --dataset icews15 --threshold 0.5
If you want to contribute to this repository, please fork the repository, create a new branch, make your changes, and submit a pull request with a detailed description of your changes.
This repository is licensed under the MIT License.