本文整理汇总了Python中statsmodels.tools.decorators.resettable_cache函数的典型用法代码示例。如果您正苦于以下问题:Python resettable_cache函数的具体用法?Python resettable_cache怎么用?Python resettable_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resettable_cache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, tables, shift_zeros=False):
if isinstance(tables, np.ndarray):
sp = tables.shape
if (len(sp) != 3) or (sp[0] != 2) or (sp[1] != 2):
raise ValueError("If an ndarray, argument must be 2x2xn")
table = tables
else:
# Create a data cube
table = np.dstack(tables).astype(np.float64)
if shift_zeros:
zx = (table == 0).sum(0).sum(0)
ix = np.flatnonzero(zx > 0)
if len(ix) > 0:
table = table.copy()
table[:, :, ix] += 0.5
self.table = table
self._cache = resettable_cache()
# Quantities to precompute. Table entries are [[a, b], [c,
# d]], 'ad' is 'a * d', 'apb' is 'a + b', 'dma' is 'd - a',
# etc.
self._apb = table[0, 0, :] + table[0, 1, :]
self._apc = table[0, 0, :] + table[1, 0, :]
self._bpd = table[0, 1, :] + table[1, 1, :]
self._cpd = table[1, 0, :] + table[1, 1, :]
self._ad = table[0, 0, :] * table[1, 1, :]
self._bc = table[0, 1, :] * table[1, 0, :]
self._apd = table[0, 0, :] + table[1, 1, :]
self._dma = table[1, 1, :] - table[0, 0, :]
self._n = table.sum(0).sum(0)
示例2: __init__
def __init__(self, data, dist=stats.norm, fit=False,
distargs=(), a=0, loc=0, scale=1):
self.data = data
self.a = a
self.nobs = data.shape[0]
self.distargs = distargs
self.fit = fit
if isinstance(dist, basestring):
dist = getattr(stats, dist)
self.fit_params = dist.fit(data)
if fit:
self.loc = self.fit_params[-2]
self.scale = self.fit_params[-1]
if len(self.fit_params) > 2:
self.dist = dist(*self.fit_params[:-2],
**dict(loc = 0, scale = 1))
else:
self.dist = dist(loc=0, scale=1)
elif distargs or loc == 0 or scale == 1:
self.dist = dist(*distargs, **dict(loc=loc, scale=scale))
self.loc = loc
self.scale = scale
else:
self.dist = dist
self.loc = loc
self.scale = scale
# propertes
self._cache = resettable_cache()
示例3: __init__
def __init__(self, endog, exog=None, missing='none', hasconst=None,
**kwargs):
if 'design_info' in kwargs:
self.design_info = kwargs.pop('design_info')
if 'formula' in kwargs:
self.formula = kwargs.pop('formula')
if missing != 'none':
arrays, nan_idx = self.handle_missing(endog, exog, missing,
**kwargs)
self.missing_row_idx = nan_idx
self.__dict__.update(arrays) # attach all the data arrays
self.orig_endog = self.endog
self.orig_exog = self.exog
self.endog, self.exog = self._convert_endog_exog(self.endog,
self.exog)
else:
self.__dict__.update(kwargs) # attach the extra arrays anyway
self.orig_endog = endog
self.orig_exog = exog
self.endog, self.exog = self._convert_endog_exog(endog, exog)
# this has side-effects, attaches k_constant and const_idx
self._handle_constant(hasconst)
self._check_integrity()
self._cache = resettable_cache()
示例4: __init__
def __init__(self, model, cov_type='opg', cov_kwds=None):
self.data = model.data
# Save the model output
self._endog_names = model.endog_names
self._exog_names = model.endog_names
self._params = model.params.copy()
self._param_names = model.data.param_names
self._model_names = model.model_names
self._model_latex_names = model.model_latex_names
# Associate the names with the true parameters
params = pd.Series(self._params, index=self._param_names)
# Initialize the Statsmodels model base
# TODO does not pass cov_type to parent right now, instead sets it
# separately, see below.
tsbase.TimeSeriesModelResults.__init__(self, model, params,
normalized_cov_params=None,
scale=1.)
# Initialize the statespace representation
super(MLEResults, self).__init__(model)
# Setup the cache
self._cache = resettable_cache()
# Handle covariance matrix calculation
if cov_kwds is None:
cov_kwds = {}
self._get_robustcov_results(cov_type=cov_type, use_self=True,
**cov_kwds)
示例5: __init__
def __init__(self, results, get_margeff, derivative, dist=None,
margeff_args=()):
self._cache = resettable_cache()
self.results = results
self.dist = dist
self._get_margeff = get_margeff
self.get_margeff(margeff_args)
示例6: __init__
def __init__(self, model, params, filter_results, cov_type='opg',
cov_kwds=None, **kwargs):
self.data = model.data
tsbase.TimeSeriesModelResults.__init__(self, model, params,
normalized_cov_params=None,
scale=1.)
# Save the state space representation output
self.filter_results = filter_results
# Dimensions
self.nobs = model.nobs
# Setup covariance matrix notes dictionary
if not hasattr(self, 'cov_kwds'):
self.cov_kwds = {}
self.cov_type = cov_type
# Setup the cache
self._cache = resettable_cache()
# Handle covariance matrix calculation
if cov_kwds is None:
cov_kwds = {}
self._get_robustcov_results(cov_type=cov_type, use_self=True,
**cov_kwds)
示例7: __init__
def __init__(self, model, params, normalized_cov_params, scale):
super(RLMResults, self).__init__(model, params, normalized_cov_params, scale)
self.model = model
self.df_model = model.df_model
self.df_resid = model.df_resid
self.nobs = model.nobs
self._cache = resettable_cache()
示例8: __init__
def __init__(self, model, params, normalized_cov_params, scale):
super(RLMResults, self).__init__(model, params, normalized_cov_params, scale)
self.model = model
self.df_model = model.df_model
self.df_resid = model.df_resid
self.nobs = model.nobs
self._cache = resettable_cache()
# for remove_data
self.data_in_cache = ["sresid"]
self.cov_params_default = self.bcov_scaled
示例9: __init__
def __init__(self, model, mlefit, optimize_dict=None):
self.model = model
self.estimator = model.estimator
self.optimize_dict = optimize_dict
self.nobs = model.nobs
self.df_model = model.df_model
self.df_resid = model.df_resid
self._cache = resettable_cache()
self.__dict__.update(mlefit.__dict__)
self.param_names = model.param_names(params_type='long')
self.nperiods = self.model.nperiods
示例10: __init__
def __init__(self, model):
self.model = model
self.mlefit = model.fit()
self.nobs_bychoice = model.nobs
self.nobs = model.endog.shape[0]
self.alt = model.V.keys()
self.freq_alt = model.endog_bychoices[:, ].sum(0).tolist()
self.perc_alt = (model.endog_bychoices[:, ].sum(0) / model.nobs)\
.tolist()
self.__dict__.update(self.mlefit.__dict__)
self._cache = resettable_cache()
示例11: __init__
def __init__(self, model, params, normalized_cov_params, scale):
super(GLMResults, self).__init__(model, params,
normalized_cov_params=normalized_cov_params, scale=scale)
self.family = model.family
self._endog = model.endog
self.nobs = model.endog.shape[0]
self.mu = model.mu
self._data_weights = model.data_weights
self.df_resid = model.df_resid
self.df_model = model.df_model
self.pinv_wexog = model.pinv_wexog
self._cache = resettable_cache()
示例12: __init__
def __init__(self, params, resid, volatility, dep_var, names, loglikelihood, is_pandas, model):
self._params = params
self._resid = resid
self._is_pandas = is_pandas
self.model = model
self._datetime = dt.datetime.now()
self._cache = resettable_cache()
self._dep_var = dep_var
self._dep_name = dep_var.name
self._names = names
self._loglikelihood = loglikelihood
self._nobs = model.nobs
self._index = dep_var.index
self._volatility = volatility
示例13: __init__
def __init__(self, datasets, paramgroup, basepath, figpath,
showprogress=False, applyfilters=False,
filtercount=5, filtercolumn='bmp'):
self._cache = resettable_cache()
self._applyfilters = applyfilters
self.filtercount = filtercount
self.filtercolumn = filtercolumn
self._raw_datasets = [ds for ds in filter(
lambda x: x.effluent.include,
datasets
)]
self.basepath = basepath
self.figpath = figpath
self.showprogress = showprogress
self.parameters = [ds.definition['parameter'] for ds in self.datasets]
self.bmps = [ds.definition['category'] for ds in self.datasets]
self.paramgroup = paramgroup
示例14: __init__
def __init__(self, model, params, normalized_cov_params=None, scale=1.0):
super(ARMAResults, self).__init__(model, params, normalized_cov_params, scale)
self.sigma2 = model.sigma2
nobs = model.nobs
self.nobs = nobs
k_exog = model.k_exog
self.k_exog = k_exog
k_trend = model.k_trend
self.k_trend = k_trend
k_ar = model.k_ar
self.k_ar = k_ar
self.n_totobs = len(model.endog)
k_ma = model.k_ma
self.k_ma = k_ma
df_model = k_exog + k_trend + k_ar + k_ma
self.df_model = df_model
self.df_resid = self.nobs - df_model
self._cache = resettable_cache()
示例15: __init__
def __init__(self, model, params, normalized_cov_params=None, scale=1.0):
super(ARResults, self).__init__(model, params, normalized_cov_params, scale)
self._cache = resettable_cache()
self.nobs = model.nobs
n_totobs = len(model.endog)
self.n_totobs = n_totobs
self.X = model.X # copy?
self.Y = model.Y
k_ar = model.k_ar
self.k_ar = k_ar
k_trend = model.k_trend
self.k_trend = k_trend
trendorder = None
if k_trend > 0:
trendorder = k_trend - 1
self.trendorder = 1
# TODO: cmle vs mle?
self.df_resid = self.model.df_resid = n_totobs - k_ar - k_trend