Skip to content

Commit

Permalink
Merge pull request #31 from eth-cscs/release-0.4.0
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
mschoengens authored Nov 22, 2017
2 parents 4db8377 + eb8b851 commit 53dc97b
Show file tree
Hide file tree
Showing 13 changed files with 1,613 additions and 1,211 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3
0.4.0
42 changes: 21 additions & 21 deletions abcpy/approx_lhd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@

class Approx_likelihood(metaclass = ABCMeta):
"""This abstract base class defines the approximate likelihood
function. To approximate the likelihood function at a parameter value given observed dataset,
we need to pass a dataset simulated from model set at the parameter value and the observed dataset.
function. To approximate the likelihood function at a parameter value given observed data set,
we need to pass a data set simulated from model set at the parameter value and the observed data set.
"""

@abstractmethod
def __init__(self, statistics_calc):
""" The constructor of a sub-class must accept a non-optional statistics
calculator, which is stored to self.statistics_calc.
"""
The constructor of a sub-class must accept a non-optional statistics
calculator, which is stored to self.statistics_calc.
Parameters
----------
statistics_calc : abcpy.stasistics.Statistics
Statistics extractor object that conforms to the Statistics class.
Parameters
----------
statistics_calc : abcpy.stasistics.Statistics
Statistics extractor object that conforms to the Statistics class.
"""

raise NotImplemented

@abstractmethod
def likelihood(y_obs, y_sim):
"""To be overwritten by any sub-class: should compute the approximate likelihood
value given the observed dataset y_obs and dataset y_sim simulated from
value given the observed data set y_obs and the data set y_sim simulated from
model set at the parameter value.
Parameters
Expand All @@ -46,7 +47,7 @@ def likelihood(y_obs, y_sim):


class SynLiklihood(Approx_likelihood):
"""This class implements the aproximate likelihood function which computes the pproximate
"""This class implements the approximate likelihood function which computes the approximate
likelihood using the synthetic likelihood approach described in Wood [1].
For synthetic likelihood approximation, we compute the robust precision matrix using Ledoit and Wolf's [2]
method.
Expand Down Expand Up @@ -92,8 +93,8 @@ def likelihood(self, y_obs, y_sim):


class PenLogReg(Approx_likelihood):
"""This class implements the aproximate likelihood function which computes the pproximate
likelihood upto a constant using penalized logistic regression described in
"""This class implements the approximate likelihood function which computes the approximate
likelihood up to a constant using penalized logistic regression described in
Dutta et. al. [1]. It takes one additional function handler defining the
true model and two additional parameters n_folds and n_simulate correspondingly defining number
of folds used to estimate prediction error using cross-validation and the number
Expand All @@ -106,10 +107,8 @@ class PenLogReg(Approx_likelihood):
[2] Friedman, J., Hastie, T., and Tibshirani, R. (2010). Regularization
paths for generalized linear models via coordinate descent. Journal of Statistical
Software, 33(1), 1–22.
"""
def __init__(self, statistics_calc, model, n_simulate, n_folds=10, max_iter = 100000, seed = None):
"""
Software, 33(1), 1–22.
Parameters
----------
statistics_calc : abcpy.stasistics.Statistics
Expand All @@ -124,17 +123,18 @@ def __init__(self, statistics_calc, model, n_simulate, n_folds=10, max_iter = 10
Maximum passes over the data. The default is 100000.
seed: int, optional
Seed for the random number generator. The used glmnet solver is not
deterministic, this seed is used for determining the cv folds. The default value is
deterministic, this seed is used for determining the cv folds. The default value is
None.
"""

"""
def __init__(self, statistics_calc, model, n_simulate, n_folds=10, max_iter = 100000, seed = None):

self.model = model
self.statistics_calc = statistics_calc
self.n_folds = n_folds
self.n_simulate = n_simulate
self.seed = seed
self.max_iter = max_iter
# Simulate reference data and extract summary statistics from the reffernce data
# Simulate reference data and extract summary statistics from the reference data
self.ref_data_stat = self._simulate_ref_data()


Expand Down Expand Up @@ -164,7 +164,7 @@ def likelihood(self, y_obs, y_sim):

def _simulate_ref_data(self):
"""
Simulate the reference dataset. This code is run at the initializtion of
Simulate the reference data set. This code is run at the initialization of
Penlogreg
"""

Expand Down
14 changes: 7 additions & 7 deletions abcpy/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def parallelize(self, list):
A reference object that represents the parallelized list
"""

raise NotImplemented
raise NotImplementedError


@abstractmethod
Expand All @@ -49,7 +49,7 @@ def broadcast(self, object):
A reference to the broadcasted object
"""

raise NotImplemented
raise NotImplementedError


@abstractmethod
Expand All @@ -72,7 +72,7 @@ def map(self, func, pds):
a new parallel data set that contains the result of the map
"""

raise NotImplemented
raise NotImplementedError


@abstractmethod
Expand All @@ -91,7 +91,7 @@ def collect(self, pds):
all elements of pds as a list
"""

raise NotImplemented
raise NotImplementedError


class PDS:
Expand All @@ -101,7 +101,7 @@ class PDS:

@abstractmethod
def __init__(self):
raise NotImplemented
raise NotImplementedError


class BDS:
Expand All @@ -111,15 +111,15 @@ class BDS:

@abstractmethod
def __init__(self):
raise NotImplemented
raise NotImplementedError


@abstractmethod
def value(self):
"""
This method should return the actual object that the broadcast data set represents.
"""
raise NotImplemented
raise NotImplementedError


class BackendDummy(Backend):
Expand Down
Loading

0 comments on commit 53dc97b

Please sign in to comment.