本文整理汇总了Python中skillmodels.SkillModel类的典型用法代码示例。如果您正苦于以下问题:Python SkillModel类的具体用法?Python SkillModel怎么用?Python SkillModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkillModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_loadings_intercepts_transparams_anchparams_and_xzeros
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)
开发者ID:suri5471,项目名称:skillmodels,代码行数:45,代码来源:wa_with_no_squares_translog_model_test.py
示例2: test_set_bounds_for_Q_robust
def test_set_bounds_for_Q_robust(self):
self.robust_bounds = True
expected = np.zeros(100, dtype=object)
expected[:] = None
expected[10: 30] = 0.001
smo._set_bounds_for_Q(self, slice(10, 30))
aae(self.lower_bound, expected)
开发者ID:suri5471,项目名称:skillmodels,代码行数:7,代码来源:skill_model_test.py
示例3: test_set_bounds_P_zero_restricted_not_robust
def test_set_bounds_P_zero_restricted_not_robust(self):
self.robust_bounds = False
self.restrict_P_zeros = True
expected = np.zeros(100, dtype=object)
expected[:] = None
expected[self.bound_indices[:4]] = 0.0
smo._set_bounds_for_P_zero(self, slice(10, 20))
aae(self.lower_bound, expected)
开发者ID:suri5471,项目名称:skillmodels,代码行数:8,代码来源:skill_model_test.py
示例4: test_predict_ff_mocked_same_result_in_second
def test_predict_ff_mocked_same_result_in_second(self, mock_tsp, mock_pp):
# this test makes sure that y copy arrays where necessary
mock_tsp.side_effect = fake_tsp
self.likelihood_arguments_dict = Mock(return_value=self.lh_args)
calc1 = smo._predict_final_factors(self, self.change)
calc2 = smo._predict_final_factors(self, self.change)
aaae(calc1, calc2)
开发者ID:suri5471,项目名称:skillmodels,代码行数:8,代码来源:skill_model_test.py
示例5: test_params_slice_deltas
def test_params_slice_deltas(self):
arr0 = np.ones((4, 2), dtype=bool)
arr1 = np.ones((6, 3), dtype=bool)
arr1[(0, 1), :] = 0
self._deltas_bool = Mock(return_value=[arr0, arr1, arr0])
self._general_params_slice = Mock()
smo._params_slice_for_deltas(self, 'short')
self._general_params_slice.assert_has_calls(
[call(8), call(12), call(8)])
开发者ID:suri5471,项目名称:skillmodels,代码行数:9,代码来源:skill_model_test.py
示例6: test_set_bounds_for_X_zero
def test_set_bounds_for_X_zero(self):
self.lower_bound = np.empty(100, dtype=object)
self.lower_bound[:] = None
params_slice = slice(10, 22)
expected = self.lower_bound.copy()
expected[[16, 20]] = 0
smo._set_bounds_for_X_zero(self, params_slice=params_slice)
aae(self.lower_bound, expected)
开发者ID:suri5471,项目名称:skillmodels,代码行数:12,代码来源:skill_model_test.py
示例7: test_marginal_effect_outcome_anch_outcome
def test_marginal_effect_outcome_anch_outcome(self):
self.anchoring = True
self.me_anchor_on = True
self.me_on = 'anch_outcome'
exp = np.ones((10)) * 4
calc = smo._marginal_effect_outcome(self, self.change)
aaae(calc, exp)
开发者ID:suri5471,项目名称:skillmodels,代码行数:7,代码来源:skill_model_test.py
示例8: test_extended_meas_coeffs_no_constant_factor_and_intercepts_case
def test_extended_meas_coeffs_no_constant_factor_and_intercepts_case(self):
coeff_type = 'intercepts'
calc_intercepts = smo.extended_meas_coeffs(self, coeff_type, 0)
expected_intercepts = pd.Series(
data=[0.8, 1.2, 1.6, 2.0],
name='intercepts', index=['y01', 'y02', 'y03', 'y04'])
assert_series_equal(calc_intercepts, expected_intercepts)
开发者ID:suri5471,项目名称:skillmodels,代码行数:7,代码来源:skill_model_test.py
示例9: test_predict_ff_intermediate_false_mocked
def test_predict_ff_intermediate_false_mocked(self, mock_tsp, mock_pp):
mock_tsp.side_effect = fake_tsp
self.likelihood_arguments_dict = Mock(return_value=self.lh_args)
exp = np.ones((10, 2)) * 4
exp[:, 0] = 12
calc = smo._predict_final_factors(self, self.change)
aaae(calc, exp)
开发者ID:suri5471,项目名称:skillmodels,代码行数:7,代码来源:skill_model_test.py
示例10: test_expand_params
def test_expand_params(self, mock_pt):
mock_pt.transform_params_for_X_zero.return_value = np.arange(3)
mock_pt.transform_params_for_trans_coeffs.return_value = np.ones(9)
mock_pt.transform_params_for_P_zero.return_value = np.ones(3) * 17
expected = np.array([0] * 5 + [1] * 9 + [0, 1, 2] + [17] * 3)
aae(smo._transform_params(self, np.zeros(18), 'short_to_long'),
expected)
开发者ID:suri5471,项目名称:skillmodels,代码行数:7,代码来源:skill_model_test.py
示例11: test_all_variables_for_iv_equations_constant_factor
def test_all_variables_for_iv_equations_constant_factor(self):
calc_meas_list = smo.all_variables_for_iv_equations(
self, 1, 'f1', 'test')
expected_meas_list = [
['y11_test', 'y12_test'],
['y07_copied_test', 'y08_copied_test']]
assert_equal(calc_meas_list, expected_meas_list)
开发者ID:suri5471,项目名称:skillmodels,代码行数:7,代码来源:skill_model_test.py
示例12: test_all_bootstrap_params
def test_all_bootstrap_params(self):
calc_params = smo.all_bootstrap_params(self, params=np.ones(3))
expected_params = pd.DataFrame(
data=[[0.0] * 3, [1.0] * 3, [2.0] * 3],
index=['rep_0', 'rep_1', 'rep_2'],
columns=['p1', 'p2', 'p3'])
assert_frame_equal(calc_params, expected_params)
开发者ID:suri5471,项目名称:skillmodels,代码行数:7,代码来源:skill_model_test.py
示例13: test_initial_trans_coeffs
def test_initial_trans_coeffs(self, mock_tf):
mock_tf.nr_coeffs_first_func.return_value = 3
mock_tf.nr_coeffs_second_func.return_value = 10
expected = [np.zeros((2, 3)), np.zeros((2, 10))]
initials = smo._initial_trans_coeffs(self)
for i, e in zip(initials, expected):
aae(i, e)
开发者ID:suri5471,项目名称:skillmodels,代码行数:7,代码来源:skill_model_test.py
示例14: test_residual_measurements
def test_residual_measurements(self):
expected_data = np.array([
[1.5, 2],
[0.5, -2]])
expected_resid = pd.DataFrame(
expected_data, columns=['m1_resid', 'm2_resid'])
calc_resid = smo.residual_measurements(self, period=1)
assert_frame_equal(calc_resid, expected_resid)
开发者ID:suri5471,项目名称:skillmodels,代码行数:8,代码来源:skill_model_test.py
示例15: test_set_bounds_for_trans_coeffs
def test_set_bounds_for_trans_coeffs(self, mock_tf):
lb = np.array([0, None, None], dtype=object)
ub = np.array([None, None, 1], dtype=object)
mock_tf.bounds_first_func.return_value = (lb, ub)
del mock_tf.bounds_second_func
sl = [[slice(0, 3)] * 2, [slice(3, 13), slice(13, 23)]]
expected_lb = self.lower_bound.copy()
expected_lb[0] = 0
expected_ub = self.upper_bound.copy()
expected_ub[2] = 1
smo._set_bounds_for_trans_coeffs(self, sl)
aae(self.lower_bound, expected_lb)
aae(self.upper_bound, expected_ub)
开发者ID:suri5471,项目名称:skillmodels,代码行数:17,代码来源:skill_model_test.py
示例16: test_indepvar_permutations
def test_indepvar_permutations(self):
ret_val = [['y1', 'y2'], ['y3', 'y4']]
self.all_variables_for_iv_equations = Mock(return_value=ret_val)
expected_xs = [
['y1', 'y3'], ['y1', 'y4'], ['y2', 'y3'], ['y2', 'y4']]
calc_xs = smo.variable_permutations_for_iv_equations(self, 1, 1)[0]
assert_equal(calc_xs, expected_xs)
开发者ID:suri5471,项目名称:skillmodels,代码行数:8,代码来源:skill_model_test.py
示例17: test_generate_start_factors_cov_cholesky
def test_generate_start_factors_cov_cholesky(self):
self.nobs = 200000
self.me_params = np.array([5, 10, 1, 0.1, 1.99749844])
self.cholesky_of_P_zero = True
calc_factors = smo._generate_start_factors(self)
df = pd.DataFrame(calc_factors)
calc_cov = df.cov().values
aaae(calc_cov, self.exp_cov, decimal=2)
开发者ID:suri5471,项目名称:skillmodels,代码行数:8,代码来源:skill_model_test.py
示例18: test_extendend_meas_coeffs_constant_factor_and_loadings_case
def test_extendend_meas_coeffs_constant_factor_and_loadings_case(self):
coeff_type = 'loadings'
calc_loadings = smo.extended_meas_coeffs(self, coeff_type, 1)
expected_loadings = pd.Series(
data=[2.2, 2.6, 1.4, 1.8],
name='loadings',
index=['y11', 'y12', 'y03_copied', 'y04_copied'])
assert_series_equal(calc_loadings, expected_loadings)
开发者ID:suri5471,项目名称:skillmodels,代码行数:8,代码来源:skill_model_test.py
示例19: test_generate_bs_samples
def test_generate_bs_samples(self):
np.random.seed(495)
expected_samples = [
['id_1', 'id_1', 'id_1'],
['id_0', 'id_2', 'id_2'],
['id_2', 'id_2', 'id_1']]
calc_samples = smo._generate_bs_samples(self)
assert_equal(calc_samples, expected_samples)
开发者ID:suri5471,项目名称:skillmodels,代码行数:8,代码来源:skill_model_test.py
示例20: test_x_zero_names_short_params
def test_x_zero_names_short_params(self):
expected = [
'X_zero__0__f1', 'X_zero__0__f2', 'X_zero__0__f3', 'X_zero__0__f4',
'X_zero__1__f1', 'X_zero__1__f2', 'diff_X_zero__1__f3',
'X_zero__1__f4',
'X_zero__2__f1', 'X_zero__2__f2', 'diff_X_zero__2__f3',
'X_zero__2__f4']
assert_equal(smo._X_zero_names(self, params_type='short'), expected)
开发者ID:suri5471,项目名称:skillmodels,代码行数:8,代码来源:skill_model_test.py
注:本文中的skillmodels.SkillModel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论