• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python decorators.resettable_cache函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中statsmodels.tools.decorators.resettable_cache函数的典型用法代码示例。如果您正苦于以下问题:Python resettable_cache函数的具体用法?Python resettable_cache怎么用?Python resettable_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了resettable_cache函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:0ceangypsy,项目名称:statsmodels,代码行数:34,代码来源:contingency_tables.py


示例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()
开发者ID:SuperXrooT,项目名称:statsmodels,代码行数:32,代码来源:gofplots.py


示例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()
开发者ID:Bhushan1002,项目名称:statsmodels,代码行数:25,代码来源:data.py


示例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)
开发者ID:soumyadsanyal,项目名称:statsmodels,代码行数:32,代码来源:mlemodel.py


示例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)
开发者ID:Code-fish,项目名称:statsmodels,代码行数:7,代码来源:discrete_margins.py


示例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)
开发者ID:andreas-koukorinis,项目名称:statsmodels,代码行数:27,代码来源:mlemodel.py


示例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()
开发者ID:slojo404,项目名称:statsmodels,代码行数:7,代码来源:robust_linear_model.py


示例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
开发者ID:eph,项目名称:statsmodels,代码行数:11,代码来源:robust_linear_model.py


示例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
开发者ID:suri5471,项目名称:skillmodels,代码行数:11,代码来源:skill_model_results.py


示例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()
开发者ID:max1mn,项目名称:statsmodels,代码行数:12,代码来源:dcm_clogit.py


示例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()
开发者ID:gregcole,项目名称:statsmodels,代码行数:12,代码来源:generalized_linear_model.py


示例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
开发者ID:Hong-Lin,项目名称:arch,代码行数:14,代码来源:base.py


示例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
开发者ID:Geosyntec,项目名称:pybmpdb,代码行数:17,代码来源:summary.py


示例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()
开发者ID:slojo404,项目名称:statsmodels,代码行数:18,代码来源:arima_model.py


示例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
开发者ID:r0k3,项目名称:statsmodels,代码行数:18,代码来源:ar_model.py


示例16: test_resettable_cache

def test_resettable_cache():
    # This test was taken from the old __main__ section of decorators.py

    reset = dict(a=('b',), b=('c',))
    cache = resettable_cache(a=0, b=1, c=2, reset=reset)
    assert_equal(cache, dict(a=0, b=1, c=2))

    # Try resetting a
    cache['a'] = 1
    assert_equal(cache, dict(a=1, b=None, c=None))
    cache['c'] = 2
    assert_equal(cache, dict(a=1, b=None, c=2))
    cache['b'] = 0
    assert_equal(cache, dict(a=1, b=0, c=None))

    # Try deleting b
    del cache['a']
    assert_equal(cache, {})
开发者ID:ChadFulton,项目名称:statsmodels,代码行数:18,代码来源:test_decorators.py


示例17: __init__

    def __init__(self, endog, exog=None, missing='none', **kwargs):
        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)

        self._check_integrity()
        self._cache = resettable_cache()
开发者ID:r0k3,项目名称:statsmodels,代码行数:18,代码来源:data.py


示例18: __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()
        # are these intermediate results needed or can we just
        # call the model's attributes?

        # for remove data and pickle without large arrays
        self._data_attr.extend(['results_constrained'])
        self.data_in_cache = getattr(self, 'data_in_cache', [])
        self.data_in_cache.extend(['null'])
开发者ID:Cassin123,项目名称:statsmodels,代码行数:20,代码来源:generalized_linear_model.py


示例19: __init__

    def __init__(self, model, params, normalized_cov_params, scale,
                 cov_type='nonrobust', cov_kwds=None, use_t=None):
        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()
        # are these intermediate results needed or can we just
        # call the model's attributes?

        # for remove data and pickle without large arrays
        self._data_attr.extend(['results_constrained'])
        self.data_in_cache = getattr(self, 'data_in_cache', [])
        self.data_in_cache.extend(['null'])

        # robust covariance
        from statsmodels.base.covtype import get_robustcov_results
        if use_t is None:
            self.use_t = False    # TODO: class default
        else:
            self.use_t = use_t
        if cov_type == 'nonrobust':
            self.cov_type = 'nonrobust'
            self.cov_kwds = {'description' : 'Standard Errors assume that the ' +
                             'covariance matrix of the errors is correctly ' +
                             'specified.'}

        else:
            if cov_kwds is None:
                cov_kwds = {}
            get_robustcov_results(self, cov_type=cov_type, use_self=True,
                                       use_t=use_t, **cov_kwds)
开发者ID:JerWatson,项目名称:statsmodels,代码行数:39,代码来源:generalized_linear_model.py


示例20: __init__

    def __init__(self, model):
        self.data = model.data

        # Save the model output
        self._endog_names = model.endog_names
        self._exog_names = model.endog_names
        self._params = model.params
        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
        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()
开发者ID:Wombatpm,项目名称:statsmodels,代码行数:24,代码来源:mlemodel.py



注:本文中的statsmodels.tools.decorators.resettable_cache函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python numdiff.approx_fprime函数代码示例发布时间:2022-05-27
下一篇:
Python zxcvbn模块代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap