本文整理汇总了Python中skillmodels.SkillModel类的典型用法代码示例。如果您正苦于以下问题:Python SkillModel类的具体用法?Python SkillModel怎么用?Python SkillModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkillModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)
示例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)
示例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)])
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)