当前位置: 首页>>代码示例>>Python>>正文


Python pymc3.summary方法代码示例

本文整理汇总了Python中pymc3.summary方法的典型用法代码示例。如果您正苦于以下问题:Python pymc3.summary方法的具体用法?Python pymc3.summary怎么用?Python pymc3.summary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymc3的用法示例。


在下文中一共展示了pymc3.summary方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: divergence_plot

# 需要导入模块: import pymc3 [as 别名]
# 或者: from pymc3 import summary [as 别名]
def divergence_plot(nm, ylim=None):
    
    if nm.hbr.configs['n_chains'] > 1 and nm.hbr.model_type != 'nn':
        a = pm.summary(nm.hbr.trace).round(2)
        plt.figure()
        plt.hist(a['r_hat'],10)
        plt.title('Gelman-Rubin diagnostic for divergence')

    divergent = nm.hbr.trace['diverging']
        
    tracedf = pm.trace_to_dataframe(nm.hbr.trace)
    
    _, ax = plt.subplots(2, 1, figsize=(15, 4), sharex=True, sharey=True)
    ax[0].plot(tracedf.values[divergent == 0].T, color='k', alpha=.05)
    ax[0].set_title('No Divergences', fontsize=10)
    ax[1].plot(tracedf.values[divergent == 1].T, color='C2', lw=.5, alpha=.5)
    ax[1].set_title('Divergences', fontsize=10)
    plt.ylim(ylim)
    plt.xticks(range(tracedf.shape[1]), list(tracedf.columns))
    plt.xticks(rotation=90, fontsize=7)
    plt.tight_layout()
    plt.show() 
开发者ID:amarquand,项目名称:nispat,代码行数:24,代码来源:utils.py

示例2: _predict_scores_fixed

# 需要导入模块: import pymc3 [as 别名]
# 或者: from pymc3 import summary [as 别名]
def _predict_scores_fixed(self, X, **kwargs):
        mean_trace = dict(pm.summary(self.trace)["mean"])
        weights = np.array(
            [
                mean_trace["weights[{}]".format(i)]
                for i in range(self.n_object_features_fit_)
            ]
        )
        lambda_k = np.array(
            [mean_trace["lambda_k[{}]".format(i)] for i in range(self.n_nests)]
        )
        weights_ik = np.zeros((self.n_object_features_fit_, self.n_nests))
        for i, k in product(range(self.n_object_features_fit_), range(self.n_nests)):
            weights_ik[i][k] = mean_trace["weights_ik[{},{}]".format(i, k)]
        alpha_ik = np.dot(X, weights_ik)
        alpha_ik = npu.softmax(alpha_ik, axis=2)
        utility = np.dot(X, weights)
        p = self._get_probabilities_np(utility, lambda_k, alpha_ik)
        return p 
开发者ID:kiudee,项目名称:cs-ranking,代码行数:21,代码来源:generalized_nested_logit.py

示例3: _predict_scores_fixed

# 需要导入模块: import pymc3 [as 别名]
# 或者: from pymc3 import summary [as 别名]
def _predict_scores_fixed(self, X, **kwargs):
        y_nests = self.create_nests(X)
        mean_trace = dict(pm.summary(self.trace)["mean"])
        weights = np.array(
            [
                mean_trace["weights[{}]".format(i)]
                for i in range(self.n_object_features_fit_)
            ]
        )
        weights_k = np.array(
            [
                mean_trace["weights_k[{}]".format(i)]
                for i in range(self.n_object_features_fit_)
            ]
        )
        lambda_k = np.array(
            [mean_trace["lambda_k[{}]".format(i)] for i in range(self.n_nests)]
        )
        weights = weights / lambda_k[:, None]
        utility_k = np.dot(self.features_nests, weights_k)
        utility = self._eval_utility_np(X, y_nests, weights)
        scores = self._get_probabilities_np(y_nests, utility, lambda_k, utility_k)
        return scores 
开发者ID:kiudee,项目名称:cs-ranking,代码行数:25,代码来源:nested_logit_model.py

示例4: get_L2_estimates

# 需要导入模块: import pymc3 [as 别名]
# 或者: from pymc3 import summary [as 别名]
def get_L2_estimates(summary):
    """
    Returns digestible estimates from the L2 estimates.

    :type summary: :class:`~pandas.core.frame.DataFrame`
    :param summary: Summary statistics from Posterior distributions

    :return: 
        (tuple): tuple containing:
            * mean_te (float) : Mean value of elastic thickness from posterior (km)
            * std_te (float)  : Standard deviation of elastic thickness from posterior (km)
            * mean_F (float)  : Mean value of load ratio from posterior
            * std_F (float)   : Standard deviation of load ratio from posterior
            * mean_a (float, optional)  : Mean value of phase difference between initial loads from posterior
            * std_a (float, optional)   : Standard deviation of phase difference between initial loads from posterior
            * rchi2 (float)   : Reduced chi-squared value
    """

    mean_a = None

    # Go through all estimates
    for index, row in summary.iterrows():
        if index=='Te':
            mean_te = row['mean']
            std_te = row['std']
            rchi2 = row['chi2']
        elif index=='F':
            mean_F = row['mean']
            std_F = row['std']
        elif index=='alpha':
            mean_a = row['mean']
            std_a = row['std']

    if mean_a is not None:
        return mean_te, std_te, mean_F, std_F, mean_a, std_a, rchi2
    else:
        return mean_te, std_te, mean_F, std_F, rchi2 
开发者ID:igp-gravity,项目名称:geoist,代码行数:39,代码来源:estimate.py

示例5: _predict_scores_fixed

# 需要导入模块: import pymc3 [as 别名]
# 或者: from pymc3 import summary [as 别名]
def _predict_scores_fixed(self, X, **kwargs):
        summary = dict(pm.summary(self.trace)["mean"])
        weights = np.zeros((self.n_object_features_fit_, self.n_mixtures))
        for i, k in product(range(self.n_object_features_fit_), range(self.n_mixtures)):
            weights[i][k] = summary["weights[{},{}]".format(i, k)]
        utility = np.dot(X, weights)
        p = np.mean(npu.softmax(utility, axis=1), axis=2)
        return p 
开发者ID:kiudee,项目名称:cs-ranking,代码行数:10,代码来源:mixed_logit_model.py

示例6: _predict_scores_fixed

# 需要导入模块: import pymc3 [as 别名]
# 或者: from pymc3 import summary [as 别名]
def _predict_scores_fixed(self, X, **kwargs):
        mean_trace = dict(pm.summary(self.trace)["mean"])
        weights = np.array(
            [
                mean_trace["weights[{}]".format(i)]
                for i in range(self.n_object_features_fit_)
            ]
        )
        lambda_k = np.array(
            [mean_trace["lambda_k[{}]".format(i)] for i in range(self.n_nests)]
        )
        utility = np.dot(X, weights)
        p = self._get_probabilities_np(utility, lambda_k)
        return p 
开发者ID:kiudee,项目名称:cs-ranking,代码行数:16,代码来源:paired_combinatorial_logit.py

示例7: _predict_scores_fixed

# 需要导入模块: import pymc3 [as 别名]
# 或者: from pymc3 import summary [as 别名]
def _predict_scores_fixed(self, X, **kwargs):
        d = dict(pm.summary(self.trace)["mean"])
        intercept = 0.0
        weights = np.array(
            [d["weights[{}]".format(i)] for i in range(self.n_object_features_fit_)]
        )
        if "intercept" in d:
            intercept = intercept + d["intercept"]
        return np.dot(X, weights) + intercept 
开发者ID:kiudee,项目名称:cs-ranking,代码行数:11,代码来源:multinomial_logit_model.py

示例8: get_bayes_estimates

# 需要导入模块: import pymc3 [as 别名]
# 或者: from pymc3 import summary [as 别名]
def get_bayes_estimates(summary, map_estimate):
    """
    Returns digestible estimates from the Posterior distributions.

    :type summary: :class:`~pandas.core.frame.DataFrame`
    :param summary: Summary statistics from Posterior distributions
    :type map_estimate: dict
    :param map_estimate: Container for Maximum a Posteriori (MAP) estimates

    :return: 
        (tuple): tuple containing:
            * mean_te (float) : Mean value of elastic thickness ``Te`` from posterior (km)
            * std_te (float)  : Standard deviation of elastic thickness ``Te`` from posterior (km)
            * C2_5_te (float) : Lower limit of 95% confidence interval on ``Te`` (km)
            * C97_5_te (float) : Upper limit of 95% confidence interval on ``Te`` (km)
            * MAP_te (float) : Maximum a Posteriori ``Te`` (km)
            * mean_F (float)  : Mean value of load ratio ``F`` from posterior
            * std_F (float)   : Standard deviation of load ratio ``F`` from posterior
            * C2_5_F (float) : Lower limit of 95% confidence interval on ``F``
            * C97_5_F (float) : Upper limit of 95% confidence interval on ``F``
            * MAP_F (float)  : Maximum a Posteriori load ratio ``F``
            * mean_a (float, optional)  : Mean value of initial phase difference ``alpha`` from posterior
            * std_a (float, optional)   : Standard deviation of initial phase difference `alpha`` from posterior
            * C2_5_a (float, optional) : Lower limit of 95% confidence interval on ``alpha``
            * C97_5_a (float, optional) : Upper limit of 95% confidence interval on ``alpha``
            * MAP_a (float, optional)  : Maximum a Posteriori initial phase difference ``alpha``

    """

    mean_a = None

    # Go through all estimates
    for index, row in summary.iterrows():
        if index=='Te':
            mean_te = row['mean']
            std_te = row['sd']
            C2_5_te = row['hpd_2.5']
            C97_5_te = row['hpd_97.5']
            MAP_te = np.float(map_estimate['Te'])
        elif index=='F':
            mean_F = row['mean']
            std_F = row['sd']
            C2_5_F = row['hpd_2.5']
            C97_5_F = row['hpd_97.5']
            MAP_F = np.float(map_estimate['F'])
        elif index=='alpha':
            mean_a = row['mean']
            std_a = row['sd']
            C2_5_a = row['hpd_2.5']
            C97_5_a = row['hpd_97.5']
            MAP_a = np.float(map_estimate['alpha'])

    if mean_a is not None:
        return mean_te, std_te, C2_5_te, C97_5_te, MAP_te, \
            mean_F, std_F, C2_5_F, C97_5_F, MAP_F, \
            mean_a, std_a, C2_5_a, C97_5_a, MAP_a
    else:
        return mean_te, std_te, C2_5_te, C97_5_te, MAP_te, \
            mean_F, std_F, C2_5_F, C97_5_F, MAP_F 
开发者ID:igp-gravity,项目名称:geoist,代码行数:61,代码来源:estimate.py


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