本文整理汇总了Python中skillmodels.SkillModel._calculate_wa_quantities方法的典型用法代码示例。如果您正苦于以下问题:Python SkillModel._calculate_wa_quantities方法的具体用法?Python SkillModel._calculate_wa_quantities怎么用?Python SkillModel._calculate_wa_quantities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skillmodels.SkillModel
的用法示例。
在下文中一共展示了SkillModel._calculate_wa_quantities方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_loadings_intercepts_transparams_anchparams_and_xzeros
# 需要导入模块: from skillmodels import SkillModel [as 别名]
# 或者: from skillmodels.SkillModel import _calculate_wa_quantities [as 别名]
def test_loadings_intercepts_transparams_anchparams_and_xzeros(self):
self.nobs = 5000
self.base_meas_sd = 0.00001
self.base_trans_sd = 0.00001
self.anch_sd = 0.1
self.true_meas_sd = self.true_loadings * self.base_meas_sd
self.true_meas_var = self.true_meas_sd ** 2
self.true_trans_sd = self.base_trans_sd * np.arange(
start=0.2, step=0.1, stop=0.75).reshape(self.nperiods - 1, 2)
self.true_trans_var = self.true_trans_sd ** 2
self.true_cov_matrix = np.array([[1.44, 0.05, 0.1],
[0.05, 2.25, 0.0],
[0.1, 0.0, 4.0]])
self.true_P_zero = self.true_cov_matrix[np.triu_indices(self.nfac)]
self.y_data = generate_test_data(
nobs=self.nobs, factors=self.factor_names, periods=self.periods,
included_positions=self.included_positions,
meas_names=self.meas_names,
initial_mean=self.true_X_zero, initial_cov=self.true_cov_matrix,
intercepts=self.true_intercepts, loadings=self.true_loadings,
meas_sd=self.true_meas_sd, gammas=self.true_gammas,
trans_sd=self.true_trans_sd,
anch_intercept=self.anch_intercept,
anch_loadings=self.anch_loadings, anch_sd=self.anch_sd)
wa_model = SkillModel(
model_name='no_squares_translog', dataset_name='test_data',
model_dict=model_dict, dataset=self.y_data, estimator='wa')
calc_storage_df, calc_X_zero, calc_P_zero, calc_gammas, trans_vars, \
anch_intercept, anch_loadings, anch_variance = \
wa_model._calculate_wa_quantities()
calc_loadings = calc_storage_df['loadings']
calc_intercepts = calc_storage_df['intercepts']
aaae(calc_loadings.values, self.true_loadings, decimal=3)
aaae(calc_intercepts.values, self.true_intercepts, decimal=3)
aaae(calc_X_zero, self.true_X_zero, decimal=1)
for arr1, arr2 in zip(calc_gammas, self.true_gammas):
aaae(arr1, arr2, decimal=3)
assert_almost_equal(anch_intercept, 3.0, places=1)
aaae(anch_loadings, self.anch_loadings, decimal=2)
示例2: test_pzero_and_measurement_variances
# 需要导入模块: from skillmodels import SkillModel [as 别名]
# 或者: from skillmodels.SkillModel import _calculate_wa_quantities [as 别名]
def test_pzero_and_measurement_variances(self):
self.nobs = 20000
self.true_gammas = [
[[1.1, 0.01, 0.02, 0.0, 0.0, 0.0, 0.5],
[1.2, 0.03, 0.03, 0.0, 0.0, 0.0, 0.6],
[1.3, 0.05, 0.04, 0.0, 0.0, 0.0, 0.7]],
[[1.05, 0.01, 0.0, 0.25],
[1.15, 0.04, 0.0, 0.75],
[1.25, 0.07, 0.0, 1.25]],
np.zeros((3, 0))]
self.base_meas_sd = 0.15
self.base_trans_sd = 1e-50
self.anch_sd = 0.4
self.true_meas_sd = self.true_loadings * self.base_meas_sd
self.true_meas_var = self.true_meas_sd ** 2
self.true_trans_sd = self.base_trans_sd * np.arange(
start=0.2, step=0.1, stop=0.75).reshape(self.nperiods - 1, 2)
self.true_trans_var = self.true_trans_sd ** 2
self.true_cov_matrix = np.array([[1.0, 0.05, 0.05],
[0.05, 1.0, 0.05],
[0.05, 0.05, 1.0]])
self.true_P_zero = self.true_cov_matrix[np.triu_indices(self.nfac)]
self.y_data = generate_test_data(
nobs=self.nobs, factors=self.factor_names, periods=self.periods,
included_positions=self.included_positions,
meas_names=self.meas_names,
initial_mean=self.true_X_zero, initial_cov=self.true_cov_matrix,
intercepts=self.true_intercepts, loadings=self.true_loadings,
meas_sd=self.true_meas_sd, gammas=self.true_gammas,
trans_sd=self.true_trans_sd,
anch_intercept=self.anch_intercept,
anch_loadings=self.anch_loadings, anch_sd=self.anch_sd)
wa_model = SkillModel(
model_name='no_squares_translog', dataset_name='test_data',
model_dict=model_dict, dataset=self.y_data, estimator='wa')
calc_storage_df, calc_X_zero, calc_P_zero, calc_gammas, trans_vars, \
anch_intercept, anch_loadings, anch_variance = \
wa_model._calculate_wa_quantities()
# df = calc_storage_df.copy(deep=True)
# df['true_meas_var'] = self.true_meas_var
# df['diff'] = df['meas_error_variances'] - df['true_meas_var']
# df['perc_diff'] = df['diff'] / df['true_meas_var']
# df['true_loadings'] = self.true_loadings
# print(df[['meas_error_variances', 'true_meas_var', 'diff', 'perc_diff',
# 'loadings', 'true_loadings']])
# print(df['diff'].mean())
calc_epsilon_variances = calc_storage_df['meas_error_variances'].values
# average_epsilon_diff = \
# (calc_epsilon_variances - self.true_meas_var).mean()
aaae(calc_P_zero, self.true_P_zero, decimal=2)
aaae(calc_epsilon_variances[:9], self.true_meas_var[:9], decimal=2)
assert_almost_equal(np.sqrt(anch_variance), self.anch_sd, places=1)