Multi-view clustering with deep ensemble structures.
Project description
Pyrea
Multi-view clustering with flexible ensemble structures.
The name Pyrea is derived from the Greek word Parea, meaning a group of friends who gather to share experiences, values, and ideas.
Installation
Install Pyrea using pip:
pip install pyrea
This will install the latest version of Pyrea from PyPI.
Usage
API
In Pyrea, your data are organised in to views. A view consists of the data in the form of a 2D matrix, and an associated clustering algorithm (a clusterer).
To create a view you must have some data, and a clusterer:
import pyrea
# Create your data, which must be a 2-dimensional array/matrix.
d = [[1,2,3],
[4,5,6],
[7,8,9]]
# Create a clusterer
c = pyrea.clusterer("ward")
v = pyrea.view(d, c)
You now have a view v, containing the data d using the clustering algorithm
c. Note that many views can share the same clusterer, or each view may have a
unique clusterer.
As this is a library for multi-view ensemble learning, you will normally have multiple views.
A fusion algorithm is therefore used to fused the clusters created from multiple views. Therefore, our next step is to create a fuser object:
f = pyrea.fuser('parea')
With you fusion algorithm f, you can create an ensemble. The ensemble is
created with your views, the fusion algorithm, and a clustering algorithm:
e = pyrea.ensemble([v1, v2, v3], f, c)
To perform this operation you execute the ensemble:
e.execute()
which returns your clustered fusion matrix.
A full example is shown below:
import pyrea
import numpy as np
# Create two datasets with random values of 1000 samples and 100 features per sample.
d1 = np.random.rand(1000,100)
d2 = np.random.rand(1000,100)
# Define the clustering algorithm(s) you want to use. In this case we used the same
# algorithm for both views
c = pyrea.clusterer('ward')
# Create the views using the data and clusterer
v1 = pyrea.view(d1, c)
v2 = pyrea.view(d1, c)
# Create a fusion object
f = pyrea.fuser('parea')
# Create your ensemble
e = pyrea.ensemble([v1, v2], f, c)
# Execute the ensemble
e.execute()
Ensemble Structures
Complex structures can be built using Pyrea.
For example, examine the two structures below:
We will demonstrate how to create deep and flexible ensemble structures using the examples a) and b) from the image above.
Example A
This ensemble consists of two sets of three views, which are clustered, fused, and then once again combined in a second layer.
Work in progress
We create two ensembles, which represent the first layer of the structure A in the image above:
import pyrea
import numpy as np
# Define our clustering algorithms(s) and fusion algorimth(s) first that we
# will use multiple times.
# Clusterers:
hc1 = pyrea.clusterer('ward')
hc2 = pyrea.clusterer('complete')
# Fusers:
parea_fuser = pyrea.fuser('parea')
# Data (random data for now)
d1 = np.random.rand(100,10)
d2 = np.random.rand(100,10)
d3 = np.random.rand(100,10)
# Views for ensemble 1
view1_e1 = pyrea.view(d1, hc1)
view2_e1 = pyrea.view(d2, hc1)
view3_e1 = pyrea.view(d3, hc1)
# Ensemble 1
e1 = pyrea.ensemble([view1_e1, view2_e1, view3_e1], f, hc1)
# Views for ensemble 2
view1_e2 = pyrea.view(d1, hc2)
view2_e2 = pyrea.view(d2, hc2)
view3_e2 = pyrea.view(d3, hc2)
e2 = pyrea.ensemble([view1_e2, view2_e2, view3_e2], f, hc1)
e3 = pyrea.ensemble([e1, e2], f, [c1, c2])
e3.execute()
As for structure b) above, this can implemented as follows:
import pyrea
import numpy as np
# Clustering algorithms
c1 = pyrea.clusterer('ward')
c2 = pyrea.clusterer('complete')
c3 = pyrea.clusterer('single')
# Fusion algorithm
fuser = pyrea.fuser('disagreement')
# Data
d1 = np.random.rand(100,10)
d2 = np.random.rand(100,10)
d3 = np.random.rand(100,10)
v1 = pyrea.view(d1, c1)
v2 = pyrea.view(d2, c2)
v3 = pyrea.view(d3, c3)
e = pyrea.ensemble([v1, v2, v3], f, [c1, c2, c3])
e.execute()
Notice how the ensemble is passed 3 clustering algorithms, and these are combined for a final clustering.
Deep Ensembles
Pyrea can be used to create deep ensembles.
Genetic Algorithm
Pyrea can select the best clustering algorithms and fusion algorithms based on a genetic algorithm optimisation technique.
Work in progress...
Clustering Methods
See scipy and sklearn for details.
Extensible
Pyrea has been designed to be extensible. It allows you to use Pyrea's data fusion techniques with custom clustering algorithms that can be loaded in to Pyrea at run-time.
By providing a View with a ClusterMethod object, it makes providing custom clustering algorithms uncomplicated. See Extending Pyrea for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyrea-1.0.2.tar.gz.
File metadata
- Download URL: pyrea-1.0.2.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4efea241eca45be90e45062be7cafacbe3ee9acc05b3ce90cbff2522564f26dd
|
|
| MD5 |
02aae6c9b0dcd8ff21c7d43ff3c7ae91
|
|
| BLAKE2b-256 |
39951404392978b15e562e9d5a96c1f920a17b312e192e3a001d69e13a067310
|
File details
Details for the file pyrea-1.0.2-py3-none-any.whl.
File metadata
- Download URL: pyrea-1.0.2-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd17c3bd3197b5103146e298a1e089f81c2c5ac50302b6533f5ba37e0eadeef0
|
|
| MD5 |
48f01e6f0d1f58facbe2c9d23f6d1fbf
|
|
| BLAKE2b-256 |
9d041675f3bf7337df87c56bdade5cbea6a54f6a552d957d6efddf1381354429
|