Skip to main content

Gym environments to learn biclustering and triclustering tasks using reinforcement learning.

Project description

NclustEnv

NclustEnv is a python toolkit that implements several environments for n-clustering and other functionalities, along with some default datasets and configurations.

The motivation behind NclustEnv is providing quality general environments for training and benchmarking RL-based solutions to n-clustering.

NclustEnv was implemented using NclustGen as the generator for online training, and Gym.

NclustEnv's architecture focuses on an abstract class (base) that contains the core logic and API and is, consequently, the only part that cannot be customized.

  • The state abstraction: NclustEnv separates all environment logic into a separate class State; this class can be inherited for minor modification or re-implemented for significant changes. It receives actions from the main class and actuates them in the graph. It is also is responsible for sampling the space and requesting a new episode upon a reset command. Currently, there are two implemented states, the State and the Offline State classes. Intuitively the State class handles all online environments, while the Offline State class is used in offline environments.
  • The space abstraction: NclustEnv also implements its observation space DGLHeteroGraphSpace, which can sample graph configurations from a distribution used with NclustGen for dataset creation.
  • The metric abstraction: The base class implements the linear assignment function and all other core logic necessary to estimate the reward and send it to the agent. However, it takes a function as a parameter so that other reward functions might be used. This function should return the distance between all permutations of hidden and found clusters. The only assumption made about the metric is that it is a distance metric; hence, the objective is to minimize it. NclustEnv currently implements Jaccard Distance.
  • The action abstraction: This abstraction implements a simple action container. When an action reaches the environment is parsed through the Action class. This class should implement two properties: action that contains the discrete action to take and parameters containing the vector of parameters for that action index. The base class takes a pointer to this action class as a parameter. Nonetheless, it is not advised that this action is re-implemented. Instead, to modify its behaviour, it should be inherited.

Diagram exemplifying NclustEnv's architecture

Installation

This tool can be installed from PyPI:

pip install nclustenv

Getting started

Here are the basics, for more information check the docstrings in each class.

## Use Biclustering Environment

import nclustenv

# Initialize Environment

configs = {}

env = nclustenv.make('BiclusterEnv-v0', **configs)

# Get obs space
env.observation_space

# Get action space
env.action_space

# Get state class
state = env.state

# Step in environment

obs, reward, done, info = env.step(env.action_space.sample())

# Render environment

env.render()

Currently four environments are implemented:

  • 'BiclusterEnv-v0';
  • 'TriclusterEnv-v0';
  • 'OfflineBiclusterEnv-v0';
  • 'OfflineTriclusterEnv-v0;

License

GPLv3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nclustenv-0.1.0.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

nclustenv-0.1.0-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file nclustenv-0.1.0.tar.gz.

File metadata

  • Download URL: nclustenv-0.1.0.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for nclustenv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fef2e7c6d4f3975572fbac20364774b829f8e23f058e5b0a7f4f911150801454
MD5 4c08c37ca29929a67f5ce09b59f30905
BLAKE2b-256 91e4a5c5f730e22072d2a664331ab6122611a0ddb13696f4b938c5020141f5d4

See more details on using hashes here.

File details

Details for the file nclustenv-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nclustenv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for nclustenv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 520a079e296c4855f4b90ce1dbfa216018773db07843acc3016ef71577058d37
MD5 25b947a57692fb6acf59c103e305191a
BLAKE2b-256 6b9f8c12c21669ad9946ad8eb96210ccc7dcf872f0ffbb9b6e6bf17febbebad9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page