# MatPool: Matrix-pattern-oriented Pooling for Graph Property Prediction

## Overview

This work explores an approach using a matrix pattern and introduce an algorithm called Matrix-pattern-oriented Pooling (MatPool). MatPool multiplies the transposed feature matrix by the feature matrix itself and performs a linear transformation to create a Matrix Representation (MR) that highlights row-column correlations. This method maintains complete graph information and respects permutation invariance for graphs with unfixed node features, as well as permutation sensitivity for those with fixed node features. Additionally, MatPool uses a novel Matrix Neural Network (MNN) with two-sided weight matrices to further extract the features of MR. We provide theoretical analyses to reveal the properties of MatPool and explain why it preserves complete graph information.

##
The document 'MatPool' contains the code of the proposed MatPool and the comparison pooling algorithms.

The documents mainly include eight pooling methods categorized into global and hierarchical pooling as comparison methods. The global pooling methods include Global Attention (GA), Set2Set, Memory-based Pooling (MEN), and Second-Order Pooling (SOPool). Hierarchical pooling methods include TopK Pooling, Self-Attention Pooling (SAG),  Path Integral Based Pooling (PAN) and Adaptive Structure Aware Pooling (ASAP).


## Results

We have provided all classification results in the uploaded codes. Please check the files named 'log' to get the classification results.

All results can be reproduced by running main.py. In main.py, you can select the dataset and adjust the parameters. The main.py will use model.py which contains the fit function and predict function. We have used the grid search to conduct the experiment and record the results on validation and test data. The parameters combination that achieves the highest results on the validation data is selected to predict the test data. 


## Dependencies

* python >= 3.9
* pytorch >= 1.11.0
* torch_geometric >= 2.0.4
* numpy >= 1.21.5
* scikit-learn >= 1.0.2
* scipy >= 1.7.3

## Run Program

* main.py calls the main function to run the program
* model.py represents the model and contains training and testing
* net.py is the structure of the used neural network
* utils.py provides some tools to assist program execution 

Run main.py directly to get the results on validation and test data. You can change the parameters and choose different data set in argparse.ArgumentParser() to see different results. 

## Datasets

All datasets used in this work can be downloaded from OGBG datasets downloaded from "https://ogb.stanford.edu/docs/nodeprop/", and TUDataset downloaded from "https://chrsmrrs.github.io/datasets/docs/datasets/".

## Customization

### How to Prepare Your Own Dataset?

You can prepare the graph data like provided in pytorch_geometric



