Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph model classes #173

Merged
merged 146 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from 139 commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
d238bef
trying heatmap color norm, intersect bug
bdpedigo Feb 26, 2019
60f8c0e
line tweak
bdpedigo Mar 4, 2019
71802eb
working but ugly plot code
bdpedigo Mar 6, 2019
11ce072
fixing hier plot
bdpedigo Mar 7, 2019
3deafb8
tweaks
bdpedigo Mar 11, 2019
0ebd9f3
stash
bdpedigo Mar 18, 2019
8fdcd16
test for sorting inds
bdpedigo Mar 28, 2019
8bbc446
test for recursive case
bdpedigo Mar 28, 2019
71ca2b2
trying heatmap color norm, intersect bug
bdpedigo Feb 26, 2019
03e22b7
line tweak
bdpedigo Mar 4, 2019
0380bdb
working but ugly plot code
bdpedigo Mar 6, 2019
c8f927f
fixing hier plot
bdpedigo Mar 7, 2019
ae03190
tweaks
bdpedigo Mar 11, 2019
568b14f
stash
bdpedigo Mar 18, 2019
20d63cf
test for sorting inds
bdpedigo Mar 28, 2019
f4ab57e
test for recursive case
bdpedigo Mar 28, 2019
4ab8992
Merge branch 'bped-bugz' of https://github.com/neurodata/graspy into …
bdpedigo Mar 28, 2019
9a38a9d
comments
bdpedigo Mar 28, 2019
482c706
demo and classes
bdpedigo Apr 2, 2019
1522236
models with bic
bdpedigo Apr 3, 2019
50a981f
update
bdpedigo Apr 3, 2019
1f2a0e7
remove some unnecessary stuff
bdpedigo Apr 3, 2019
7f3dada
data upload
bdpedigo Apr 3, 2019
27626e8
sims
bdpedigo Apr 3, 2019
044a201
bug fix and berlin figure
bdpedigo Apr 8, 2019
d239178
right adj and demo
bdpedigo Apr 11, 2019
4f24edf
gridplot bug
bdpedigo Apr 11, 2019
67435d1
convert to numpy array always
bdpedigo Apr 11, 2019
a6b9ae5
convert to numpy for heatmap
bdpedigo Apr 11, 2019
6fa4d7b
berlin
bdpedigo Apr 12, 2019
40c973f
Docstring updates (#130)
j1c Mar 25, 2019
eed310a
Add Degree-Corrected functionality into the sbm method (#123)
rflperry Mar 25, 2019
912781c
Changelog (#139)
j1c Mar 27, 2019
56ee3d5
Increment version to 0.0.2
j1c Mar 27, 2019
fd5a78c
demo and classes
bdpedigo Apr 2, 2019
0beadca
models with bic
bdpedigo Apr 3, 2019
c2a911b
update
bdpedigo Apr 3, 2019
c3abb2e
remove some unnecessary stuff
bdpedigo Apr 3, 2019
6a999c0
data upload
bdpedigo Apr 3, 2019
090ae14
sims
bdpedigo Apr 3, 2019
fa198bc
right adj and demo
bdpedigo Apr 11, 2019
3b87fe8
berlin
bdpedigo Apr 12, 2019
89420a2
working on latent
bdpedigo Apr 16, 2019
0c12f64
merge:
bdpedigo Apr 23, 2019
94654ec
add gmm
bdpedigo Apr 23, 2019
f441a49
clean up sbm
bdpedigo Apr 23, 2019
ae5b2eb
update model fitting
bdpedigo Apr 23, 2019
21fc391
saving
bdpedigo Apr 23, 2019
23db34f
notebook stuff
bdpedigo Apr 25, 2019
0b12b0a
trying heatmap color norm, intersect bug
bdpedigo Feb 26, 2019
73f3e12
line tweak
bdpedigo Mar 4, 2019
496f1e9
working but ugly plot code
bdpedigo Mar 6, 2019
e1a9617
fixing hier plot
bdpedigo Mar 7, 2019
d7bd6eb
tweaks
bdpedigo Mar 11, 2019
d6f6aa3
stash
bdpedigo Mar 18, 2019
8977dc1
test for sorting inds
bdpedigo Mar 28, 2019
be1781c
test for recursive case
bdpedigo Mar 28, 2019
5b2649a
trying heatmap color norm, intersect bug
bdpedigo Feb 26, 2019
06636df
line tweak
bdpedigo Mar 4, 2019
2f25515
working but ugly plot code
bdpedigo Mar 6, 2019
f9af066
fixing hier plot
bdpedigo Mar 7, 2019
55a6cb8
tweaks
bdpedigo Mar 11, 2019
2d1ecfb
test for recursive case
bdpedigo Mar 28, 2019
5d62785
comments
bdpedigo Mar 28, 2019
8f2f0c3
demo and classes
bdpedigo Apr 2, 2019
1262811
models with bic
bdpedigo Apr 3, 2019
fe2ffac
update
bdpedigo Apr 3, 2019
7e134e9
remove some unnecessary stuff
bdpedigo Apr 3, 2019
1257cfb
data upload
bdpedigo Apr 3, 2019
1eab6ce
sims
bdpedigo Apr 3, 2019
b044d4c
bug fix and berlin figure
bdpedigo Apr 8, 2019
ddba6a9
right adj and demo
bdpedigo Apr 11, 2019
4c5380b
gridplot bug
bdpedigo Apr 11, 2019
05b8cce
convert to numpy array always
bdpedigo Apr 11, 2019
f37593d
convert to numpy for heatmap
bdpedigo Apr 11, 2019
1a0497c
berlin
bdpedigo Apr 12, 2019
d91ccf2
Docstring updates (#130)
j1c Mar 25, 2019
c88f16c
Add Degree-Corrected functionality into the sbm method (#123)
rflperry Mar 25, 2019
3399231
demo and classes
bdpedigo Apr 2, 2019
4d44059
models with bic
bdpedigo Apr 3, 2019
0cb1e6d
update
bdpedigo Apr 3, 2019
eb4cd52
remove some unnecessary stuff
bdpedigo Apr 3, 2019
23bb218
sims
bdpedigo Apr 3, 2019
dcb89d3
right adj and demo
bdpedigo Apr 11, 2019
176a4a5
working on latent
bdpedigo Apr 16, 2019
f177c34
add gmm
bdpedigo Apr 23, 2019
aa56eed
clean up sbm
bdpedigo Apr 23, 2019
6e37bfd
update model fitting
bdpedigo Apr 23, 2019
cd08222
saving
bdpedigo Apr 23, 2019
8560922
notebook stuff
bdpedigo Apr 25, 2019
f462e5b
add community estimation
bdpedigo Apr 29, 2019
c9a0019
merge
bdpedigo Apr 29, 2019
bd15687
restructure
bdpedigo May 1, 2019
284abf0
wont break
bdpedigo May 2, 2019
1d3504c
updates
bdpedigo May 13, 2019
806fbd1
clean up sbm
bdpedigo May 14, 2019
dc5d842
starting tests
bdpedigo May 15, 2019
baddb1f
more tests
bdpedigo May 16, 2019
06acdaf
Merge branch 'master' into graphmodel
bdpedigo May 16, 2019
a148088
er doc
bdpedigo May 16, 2019
b380194
Merge branch 'graphmodel' of https://github.com/neurodata/graspy into…
bdpedigo May 16, 2019
3a5ec59
fix tests
bdpedigo May 16, 2019
183b9e6
black issues
bdpedigo May 16, 2019
b3aa41c
more black
bdpedigo May 16, 2019
04f0316
update rdpg
bdpedigo May 16, 2019
15ab46f
rmv unnecessary func
bdpedigo May 21, 2019
c65fc87
update sbm tests
bdpedigo May 21, 2019
6187f30
started rdpg tests
bdpedigo May 21, 2019
d75d9e1
more tests
bdpedigo May 23, 2019
87b5ebb
docs [skip travis]
bdpedigo May 23, 2019
f80afe5
binarize test
bdpedigo May 23, 2019
6f89774
working on imports
bdpedigo May 23, 2019
8506ea9
move cartprod
bdpedigo May 23, 2019
c085911
add docs for mushroom
bdpedigo May 23, 2019
1e989c5
update ER and SBM docs
bdpedigo May 24, 2019
f9d95a6
update docs [skip travis]
bdpedigo May 24, 2019
b58a2ad
play with docs [skip travis]
bdpedigo May 24, 2019
206cfe1
add r [skip travis]
bdpedigo May 24, 2019
805422b
sbm formatting [skip travis]
bdpedigo May 24, 2019
326a9c1
clean sbm [skip travis]
bdpedigo May 24, 2019
f8c29b7
update data description [skip travis]
bdpedigo May 24, 2019
0575dbd
more docs [skip travis]
bdpedigo May 24, 2019
32e69ff
update sample methods descrip [skip travis]
bdpedigo May 24, 2019
32777b2
check_is_fitted for likelihoods [skip travis]
bdpedigo May 24, 2019
38e56e2
add parameter desc [skip travis]
bdpedigo May 24, 2019
b21d2b5
add n_verts tests
bdpedigo May 24, 2019
8295f92
added dcer tests
bdpedigo May 24, 2019
d2bf86c
remove unnecessary [skip travis]
bdpedigo May 24, 2019
8d802bb
started notebook
bdpedigo May 27, 2019
f9927c4
shallow notebook [skip travis]
bdpedigo May 28, 2019
82132d5
fix sbm test
bdpedigo May 28, 2019
016c419
fix memory error maybe
bdpedigo May 28, 2019
550862e
fix memory error 2?
bdpedigo May 29, 2019
30d1565
fix dcer
bdpedigo May 29, 2019
dc04a26
update git [skip travis]
bdpedigo May 29, 2019
69b44bd
ignore my notebooks [skip travis]
bdpedigo May 29, 2019
585d1f0
ignore notebooks [skip travis]
bdpedigo May 29, 2019
b907848
add rdpg docs [skip travis]
bdpedigo May 29, 2019
430d0a4
tutorial notebook looking good
bdpedigo May 29, 2019
8f1b316
update n_params
bdpedigo May 31, 2019
918e6fa
update likelihoods for loops and directedness
bdpedigo Jun 10, 2019
d07baf0
rename classes
bdpedigo Jun 10, 2019
bcab847
fix notebook naming
bdpedigo Jun 10, 2019
1d1abfa
Merge branch 'master' into graphmodel
bdpedigo Jun 10, 2019
bc4315e
change base default loops
bdpedigo Jun 10, 2019
fe4c952
Merge branch 'graphmodel' of https://github.com/neurodata/graspy into…
bdpedigo Jun 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__pycache__/
*.py[cod]
*$py.class
*.csv
# *.csv

# C extensions
*.so
Expand Down Expand Up @@ -123,4 +123,4 @@ notebooks/bpedigo/diag_procrust.py
notebooks/bpedigo/new_pairs.py
*.code-workspace
*.png

notebooks/bpedigo
11 changes: 11 additions & 0 deletions docs/reference/datasets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Datasets
========

.. currentmodule:: graspy.datasets

Drosophila larval mushroom body
-------------------------------

.. autofunction:: load_drosophila_left

.. autofunction:: load_drosophila_right
5 changes: 3 additions & 2 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ Reference
:maxdepth: 2

simulations
models
embed
cluster
inference
plotting
utils

datasets
utils
23 changes: 23 additions & 0 deletions docs/reference/models.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Models
======

.. currentmodule:: graspy.models

Erdos-Reyni models
------------------

.. autoclass:: EREstimator

.. autoclass:: DCEREstimator

Stochastic block models
-----------------------

.. autoclass:: SBEstimator
bdpedigo marked this conversation as resolved.
Show resolved Hide resolved

.. autoclass:: DCSBEstimator
bdpedigo marked this conversation as resolved.
Show resolved Hide resolved

Latent position models
----------------------

.. autoclass:: RDPGEstimator
425 changes: 425 additions & 0 deletions docs/tutorials/models/models.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion graspy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import graspy.plot
import graspy.simulations
import graspy.utils

import graspy.models
import graspy.datasets

__version__ = "0.0.2"
15 changes: 8 additions & 7 deletions graspy/cluster/gclust.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ class GaussianCluster(BaseCluster):
----------
min_components : int, defaults to 1.
The minimum number of mixture components to consider (unless
max_components=None, in which case the parameter is one the highest
number of mixture components to consider and must be less than
max_components).
max_components=None, in which case this is the maximum number of
components to consider). If max_componens is not None, min_components
must be less than or equal to max_components.
max_components : int, defaults to 1.
The maximum number of mixture components to consider.
The maximum number of mixture components to consider. Must be greater
than or equal to min_components.

covariance_type : {'full' (default), 'tied', 'diag', 'spherical'}, optional
String or list/array describing the type of covariance parameters to use.
Expand Down Expand Up @@ -83,7 +84,7 @@ class GaussianCluster(BaseCluster):

def __init__(
self,
min_components,
min_components=2,
max_components=None,
covariance_type="full",
random_state=None,
Expand All @@ -102,8 +103,8 @@ def __init__(
if max_components <= 0:
msg = "max_components must be >= 1 or None."
raise ValueError(msg)
elif min_components >= max_components:
msg = "min_components must be strictly smaller than max_components."
elif min_components > max_components:
msg = "min_components must be less than or equal to max_components."
raise ValueError(msg)
elif max_components is not None:
msg = "max_components must be an integer or None, not {}.".format(
Expand Down
3 changes: 3 additions & 0 deletions graspy/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .base import load_drosophila_left, load_drosophila_right

__all__ = ["load_drosophila_left", "load_drosophila_right"]
94 changes: 94 additions & 0 deletions graspy/datasets/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
from os.path import dirname, join
import numpy as np


def load_drosophila_left(return_labels=False):
"""
Load the left Drosophila larva mushroom body connectome

The mushroom body is a learning and memory center in the fly
brain which is involved in sensory integration and processing.
This connectome was observed by electron microscopy and then
individial neurons were reconstructed; synaptic partnerships
between these neurons became the edges of the graph.

Parameters
----------
return_labels : bool, optional (default=False)
whether to have a second return value which is an array of
cell type labels for each node in the adjacency matrix

Returns
-------
graph : np.ndarray
Adjacency matrix of the connectome
labels : np.ndarray
Only returned if `return_labels` is true. Array of
string labels for each cell (vertex)

References
----------
.. [1] Eichler, K., Li, F., Litwin-Kumar, A., Park, Y., Andrade, I.,
Schneider-Mizell, C. M., ... & Fetter, R. D. (2017). The
complete connectome of a learning and memory centre in an insect
brain. Nature, 548(7666), 175.
"""

module_path = dirname(__file__)
folder = "drosophila"
filename = "left_adjacency.csv"
with open(join(module_path, folder, filename)) as csv_file:
graph = np.loadtxt(csv_file, dtype=int)
if return_labels:
filename = "left_cell_labels.csv"
with open(join(module_path, folder, filename)) as csv_file:
labels = np.loadtxt(csv_file, dtype=str)
return graph, labels
else:
return graph


def load_drosophila_right(return_labels=False):
"""
Load the right Drosophila larva mushroom body connectome

The mushroom body is a learning and memory center in the fly
brain which is involved in sensory integration and processing.
This connectome was observed by electron microscopy and then
individial neurons were reconstructed; synaptic partnerships
between these neurons became the edges of the graph.

Parameters
----------
return_labels : bool, optional (default=False)
whether to have a second return value which is an array of
cell type labels for each node in the adjacency matrix

Returns
-------
graph : np.ndarray
Adjacency matrix of the connectome
labels : np.ndarray
Only returned if `return_labels` is true. Array of
string labels for each cell (vertex)

References
----------
.. [1] Eichler, K., Li, F., Litwin-Kumar, A., Park, Y., Andrade, I.,
Schneider-Mizell, C. M., ... & Fetter, R. D. (2017). The
complete connectome of a learning and memory centre in an insect
brain. Nature, 548(7666), 175.
"""

module_path = dirname(__file__)
folder = "drosophila"
filename = "right_adjacency.csv"
with open(join(module_path, folder, filename)) as csv_file:
graph = np.loadtxt(csv_file, dtype=int)
if return_labels:
filename = "right_cell_labels.csv"
with open(join(module_path, folder, filename)) as csv_file:
labels = np.loadtxt(csv_file, dtype=str)
return graph, labels
else:
return graph
Loading