diff --git a/pymetalog/a_vector.py b/pymetalog/a_vector.py index d316d71..7915361 100644 --- a/pymetalog/a_vector.py +++ b/pymetalog/a_vector.py @@ -153,8 +153,9 @@ def a_vector_OLS_and_LP(m_dict, try: temp = np.dot(np.dot(np.linalg.inv(np.dot(Y.T, Y) + alpha*eye), Y.T), z) except: - temp = a_vector_LP(m_dict, term_limit=i, term_lower_bound=i, diff_error=diff_error, diff_step=diff_step) # use LP solver if OLS breaks + temp = a_vector_LP(m_dict, term_limit=i, term_lower_bound=i, diff_error=diff_error, diff_step=diff_step) + methodFit = 'Linear Program' if fit_method == 'OLS': try: temp = np.dot(np.dot(np.linalg.inv(np.dot(Y.T, Y) + alpha*eye), Y.T), z) @@ -164,10 +165,11 @@ def a_vector_OLS_and_LP(m_dict, temp = a_vector_LP(m_dict, term_limit=i, term_lower_bound=i, diff_error=diff_error, diff_step=diff_step) methodFit = 'Linear Program' - temp = np.append(temp, np.zeros(term_limit-i)) if fit_method == 'MLE': temp = a_vector_MLE(temp, y, i, m_dict, bounds, boundedness) + temp = np.append(temp, np.zeros(term_limit-i)) + # build a y vector for smaller data sets if len(z) < 100: y2 = np.linspace(step_len, 1 - step_len, int((1 - step_len) / step_len)) diff --git a/pymetalog/metalog.py b/pymetalog/metalog.py index 5326188..b677a4f 100644 --- a/pymetalog/metalog.py +++ b/pymetalog/metalog.py @@ -36,7 +36,6 @@ class metalog(): fit_method (:obj: `str`): String type of metalog fit method ('any' | 'OLS' | 'LP' | 'MLE'). penalty (:obj:`str`): Used to specify the norm used in the regularization. alpha (:obj:`float`): Regularization term to add to OLS fit. - save_data (:obj:`bool`, optional): T/F to save copy of input data `x` with metalog object. output_dict (:obj:`dict` with keys ['params', 'dataValues', 'Y', 'A', 'M', 'Validation']). - output_dict['params'] (:obj:`dict`): @@ -92,7 +91,7 @@ class metalog(): append_zvector(`bounds`, `boundedness`) -> df_x: (:obj:`pandas.DataFrame` with columns ['x','probs','z'] of type numeric) """ - def __init__(self, x, bounds=[0,1], boundedness='u', term_limit=13, term_lower_bound=2, step_len=.01, probs=None, fit_method='any', penalty=None, alpha=0., save_data = False): + def __init__(self, x, bounds=[0,1], boundedness='u', term_limit=13, term_lower_bound=2, step_len=.01, probs=None, fit_method='any', penalty=None, alpha=0.): """Fits a metalog distribution using the input array `x`. Args: @@ -150,12 +149,6 @@ def __init__(self, x, bounds=[0,1], boundedness='u', term_limit=13, term_lower_b - should be set in conjunction with `penalty` parameter - Default: 0. (no regularization, OLS) - save_data (:obj:`bool`, optional): Saves copy of input data `x` with metalog object. - - strictly boolean (True, False) - - saves a copy of data used to fit metalog object - * Used for Bayesian updating - - Default: False - Raises: TypeError: 'Input x must be an array or pandas Series' TypeError: 'Input x must be an array of allowable types: int, float, numpy.int64, or numpy.float64' @@ -185,7 +178,6 @@ def __init__(self, x, bounds=[0,1], boundedness='u', term_limit=13, term_lower_b ValueError: 'fit_method can only be values OLS, LP, any, or MLE' ValueError: 'penalty can only be values l2 or None' ValueError: 'alpha must only be a float >= 0.' - ValueError: 'save_data must only be boolean.' Example: @@ -215,7 +207,6 @@ def __init__(self, x, bounds=[0,1], boundedness='u', term_limit=13, term_lower_b self.fit_method = fit_method self.penalty = penalty self.nobs = len(x) - self.save_data = save_data if penalty == None: alpha = 0. @@ -436,18 +427,6 @@ def alpha(self, a): raise ValueError('alpha must only be a float >= 0.') self._alpha = a - @property - def save_data(self): - """save_data (:obj:`bool`, optional): Saves copy of input data `x` with metalog object.""" - - return self._save_data - - @save_data.setter - def save_data(self, sd): - if not type(sd) is bool: - raise ValueError('save_data must only be boolean.') - self._save_data = sd - def get_params(self): """Sets the `params` key (dict) of `output_dict` object prior to input to `a_vector_OLS_and_LP` method. - Uses metalog attributes to set keys @@ -465,7 +444,6 @@ def get_params(self): params['step_len'] = self.step_len params['fit_method'] = self.fit_method params['nobs'] = self.nobs - params['save_data'] = self.save_data return params