Git Product home page Git Product logo

link-prediction-supply-chains's Introduction

Link Prediction in Supply Chain Networks

Repo containing MPhil thesis code for link prediction in supply chain knowledge graphs using Graph Representation Learning.

Getting started

You can get started with recreating the GNN analysis by running pip install -r requirements.txt followed by running the training and testing scripts with: python3 main.py --cpu (alternatively --gpu if you are lucky enough to have one 🌝)

Supply Chain Networks as Knowledge Graphs

Modern supply chains lend themselves to a KG representation based on rich metadata regarding their certifications, location, buying and selling relationships, and capabilities. A KG representation allows for companies to interrogate their supply chains in a novel way. Examples including finding alternative suppliers, building relationships (or removing relationships in nefarious instances). The following image is an extrac of the KG built for an automotive suppply chain.

some image

The ontology of the graph is given as:

Nodes Number
company (e.g. General Motors) 119,599
product (e.g. Floor mat) 119,618
capability (e.g. Machining) 36
certification (e.g. ISO9001) 9

Edges in the ontology

Edges Number
('capability', 'capability_produces', 'product') 21,857
('company', 'buys_from', 'company') 88,997
('company', 'has_capability', 'capability') 83,787
('company', 'has_cert', 'certification') 32,654
('company', 'located_in', 'country') 40,421
('company', 'makes_product', 'product') 119,618
('product', 'complimentary_product_to', 'product') 260,658

Citing Our Work

If you find this implementation useful, please consider citing the following article.

@article{
author = {Aziz, Ajmal and Kosasih, Edward and Griffiths, Ryan-Rhys and Brintrup, Alexandra},
journal = {International Conference for Machine Learning (ICML) workshop on ML4Data},
year = {2021},
month = {07},
title = {Data Considerations in Graph Representation Learning for Supply Chain Networks}
}

Solution Filestructure - Multiclass classification Graph Neural Network (DGL)

The file structure is laid out as follows:

β”œβ”€β”€ README.md                                   # The top-level README
β”œβ”€β”€ config                                      # πŸƒπŸ» Run Project configurations
β”‚Β Β  β”œβ”€β”€ config.yml                              # For changing run parameters (e.g. number of epochs 🌝)
β”‚Β Β  └── sweep_config.yml
β”œβ”€β”€ data                                        # πŸ‘€ Ask for GDrive Access
β”‚Β Β  β”œβ”€β”€ 01_raw                                  # πŸ’Ύ Data from third party sources.
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ raw_df.pkl
β”‚Β Β  β”‚Β Β  └── supplier_product_df.parquet
β”‚Β Β  β”œβ”€β”€ 02_intermediate                         # πŸ’ͺ🏼 Intermediate data that has been transformed.
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ G.pickle
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ bG.pickle
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ cG.pickle
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ dataset
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ dataset.pickle
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ marklinesEdges.p
β”‚Β Β  β”œβ”€β”€ 03_models                               # Saved GNN models 
β”‚Β Β  └── 04_results                              # Results from the analysis πŸš€
β”œβ”€β”€ images
β”‚Β Β  └── kg_extract.png
β”œβ”€β”€ main.py
β”œβ”€β”€ notebooks                                   # πŸ‘¨πŸ»β€πŸ’» Exploratory notebooks
β”‚Β Β  β”œβ”€β”€ 1_analyse_dgl_creation.ipynb
β”‚Β Β  β”œβ”€β”€ 2_parameter_sweep-Copy1.ipynb
β”œβ”€β”€ requirements.txt
└── src
    β”œβ”€β”€ __init__.py
    β”œβ”€β”€ common
    β”‚Β Β  └── formats.py
    β”œβ”€β”€ exploration                             # 🎣 Exploring data (e.g. degree distributions)
    β”‚Β Β  β”œβ”€β”€ Marklines.py
    β”‚Β Β  β”œβ”€β”€ __init__.py
    β”‚Β Β  β”œβ”€β”€ dataset.py
    β”‚Β Β  β”œβ”€β”€ visualise_graph.py
    β”‚Β Β  └── visualise_knowledge_graph.py
    β”œβ”€β”€ ingestion                               # Data loaders and utils for torch πŸ”₯
    β”‚Β Β  β”œβ”€β”€ __init__.py
    β”‚Β Β  β”œβ”€β”€ dataloader.py
    β”‚Β Β  β”œβ”€β”€ dataset.py
    β”‚Β Β  β”œβ”€β”€ dgl_dataset.py
    β”‚Β Β  └── utils.py
    β”œβ”€β”€ managers                                # Training and testing managers in torch πŸ”₯
    β”‚Β Β  β”œβ”€β”€ evaluator.py
    β”‚Β Β  └── trainer.py
    β”œβ”€β”€ model                                   # πŸ€– DGL Models 
    β”‚Β Β  β”œβ”€β”€ __init__.py
    β”‚Β Β  └── dgl
    β”‚Β Β      β”œβ”€β”€ StochasticRGCN.py
    β”‚Β Β      β”œβ”€β”€ __init__.py
    β”‚Β Β      β”œβ”€β”€ __pycache__
    β”‚Β Β      β”‚Β Β  β”œβ”€β”€ StochasticRGCN.cpython-39.pyc
    β”‚Β Β      β”‚Β Β  β”œβ”€β”€ __init__.cpython-39.pyc
    β”‚Β Β      β”‚Β Β  └── layers.cpython-39.pyc
    β”‚Β Β      └── layers.py

link-prediction-supply-chains's People

Contributors

bangxiangyong avatar dependabot[bot] avatar grandintegrator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

link-prediction-supply-chains's Issues

Bug report

Hello, I couldn't find the 'data' folder, which caused an error during operation. Could you please add the 'data' folder or provide the link where the 'data' file is located? thanks.

data

could you provide the code in your paper?

Data!

Could you please include the data?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.