def test_calc_all_weat_defaults(w2v_small): weat_5_results_default = (calc_all_weat(w2v_small, (5, )).iloc[0].to_dict()) weat_5_results = (calc_all_weat(w2v_small, (5, ), filter_by='model', with_pvalue=True, pvalue_kwargs={ 'method': 'exact' }).iloc[0].to_dict()) assert_deep_almost_equal(weat_5_results_default, weat_5_results)
def calc_benchmark_scores(model, f_name): with open('benchmark_weat.json') as data: dict = json.load(data) result = calc_all_weat(model, weat_data=dict, with_original_finding=True, with_pvalue=True) result.to_csv(f_name)
def test_calc_all_weat_index(w2v_small): all_weat = calc_all_weat(w2v_small, filter_by='model', with_original_finding=True, with_pvalue=True, pvalue_kwargs={'method': 'approximate'}) for index in range(len(WEAT_DATA)): single_weat = calc_all_weat(w2v_small, weat_data=index, filter_by='model', with_original_finding=True, with_pvalue=True, pvalue_kwargs={'method': 'approximate'}) assert_deep_almost_equal(single_weat.iloc[0].to_dict(), all_weat.iloc[index].to_dict(), atol=0.01)
def test_calc_weat_pleasant_attribute(w2v_small): # pylint: disable=line-too-long pvalue_kwargs = {'method': 'approximate'} result_v1 = calc_weat_pleasant_unpleasant_attribute( w2v_small, WEAT_DATA[1]['first_target'], WEAT_DATA[1]['second_target'], pvalue_kwargs=pvalue_kwargs) result_v1['p'] = round(result_v1['p'], 4) result_v1['d'] = round(result_v1['d'], 4) result_v1['s'] = round(result_v1['s'], 4) result_v2 = (calc_all_weat(w2v_small, (1, ), pvalue_kwargs=pvalue_kwargs).iloc[0].to_dict()) assert_deep_almost_equal(result_v1, result_v2, atol=0.01)
def test_calc_all_weat(w2v_small): calc_all_weat(w2v_small, filter_by='model', with_original_finding=True, with_pvalue=True, pvalue_kwargs={'method': 'approximate'})