Coverage for /Users/sebastiana/Documents/Sugarpills/confidence/spotify_confidence/analysis/constants.py: 100%

1# Copyright 2017-2020 Spotify AB

2#

3# Licensed under the Apache License, Version 2.0 (the "License");

4# you may not use this file except in compliance with the License.

5# You may obtain a copy of the License at

6#

7# http://www.apache.org/licenses/LICENSE-2.0

8#

9# Unless required by applicable law or agreed to in writing, software

10# distributed under the License is distributed on an "AS IS" BASIS,

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

12# See the License for the specific language governing permissions and

13# limitations under the License.

14

15 from typing import Tuple, Dict, Union

16

17 NUMERATOR = "numerator"

18 NUMERATOR_SUM_OF_SQUARES = "numerator_sum_of_squares"

19 DENOMINATOR = "denominator"

20 BOOTSTRAPS = "bootstraps"

21 INTERVAL_SIZE = "interval_size"

22 ALPHA = "alpha"

23 FINAL_EXPECTED_SAMPLE_SIZE = "final_expected_sample_size"

24 ORDINAL_GROUP_COLUMN = "ordinal_group_column"

25 MDE = "mde"

26 METHOD = "method_column"

27 CORRECTION_METHOD = "correction_method"

28 ABSOLUTE = "absolute"

29 NUMBER_OF_COMPARISONS = "number_of_comparisons"

30 TREATMENT_WEIGHTS = "treatment_weights"

31 IS_BINARY = "is_binary"

32 FEATURE = "feature"

33 FEATURE_SUMSQ = "feature_sumsq"

34 FEATURE_CROSS = "feature_cross"

35

36 POINT_ESTIMATE = "point_estimate"

37 VARIANCE = "variance"

38 CI_LOWER, CI_UPPER = "ci_lower", "ci_upper"

39 ADJUSTED_LOWER, ADJUSTED_UPPER = "adjusted ci_lower", "adjusted ci_upper"

40 CI_WIDTH = "ci_width"

41 DIFFERENCE = "difference"

42 P_VALUE = "p-value"

43 ADJUSTED_P = "adjusted p-value"

44 SFX1, SFX2 = "_1", "_2"

45 STD_ERR = "std_err"

46 Z_CRIT = "z_crit"

47 ALPHA = "alpha"

48 ADJUSTED_ALPHA = "adjusted_alpha"

49 ADJUSTED_ALPHA_POWER_SAMPLE_SIZE = "adjusted_alpha_power_sample_size"

50 POWER = "power"

51 POWERED_EFFECT = "powered_effect"

52 ADJUSTED_POWER = "adjusted_power"

53 IS_SIGNIFICANT = "is_significant"

54 REQUIRED_SAMPLE_SIZE = "required_sample_size"

55 REQUIRED_SAMPLE_SIZE_METRIC = "required_sample_size_for_metric"

56 OPTIMAL_KAPPA = "optimal_kappa"

57 OPTIMAL_WEIGHTS = "optimal_weigghts"

58 ORIGINAL_POINT_ESTIMATE = "original_point_estimate"

59 ORIGINAL_VARIANCE = "original_variance"

60 VARIANCE_REDUCTION = "variance_reduction_rate"

61

62 BONFERRONI = "bonferroni"

63 HOLM = "holm"

64 HOMMEL = "hommel"

65 SIMES_HOCHBERG = "simes-hochberg"

66 SIDAK = "sidak"

67 HOLM_SIDAK = "holm-sidak"

68 FDR_BH = "fdr_bh"

69 FDR_BY = "fdr_by"

70 FDR_TSBH = "fdr_tsbh"

71 FDR_TSBKY = "fdr_tsbky"

72

73 BONFERRONI_ONLY_COUNT_TWOSIDED = "bonferroni-only-count-twosided"

74 BONFERRONI_DO_NOT_COUNT_NON_INFERIORITY = "bonferroni-do-not-count-non-inferiority"

75 SPOT_1 = "spot-1-bonferroni"

76

77 SPOT_1_HOLM = "spot-1-holm"

78 SPOT_1_HOMMEL = "spot-1-hommel"

79 SPOT_1_SIMES_HOCHBERG = "spot-1-simes-hochberg"

80 SPOT_1_SIDAK = "spot-1-sidak"

81 SPOT_1_HOLM_SIDAK = "spot-1-holm-sidak"

82 SPOT_1_FDR_BH = "spot-1-fdr_bh"

83 SPOT_1_FDR_BY = "spot-1-fdr_by"

84 SPOT_1_FDR_TSBH = "spot-1-fdr_tsbh"

85 SPOT_1_FDR_TSBKY = "spot-1-fdr_tsbky"

86

87 CORRECTION_METHODS = [

88 BONFERRONI,

89 HOLM,

90 HOMMEL,

91 SIMES_HOCHBERG,

92 SIDAK,

93 HOLM_SIDAK,

94 FDR_BH,

95 FDR_BY,

96 FDR_TSBH,

97 FDR_TSBKY,

98 BONFERRONI_ONLY_COUNT_TWOSIDED,

99 BONFERRONI_DO_NOT_COUNT_NON_INFERIORITY,

100 SPOT_1,

101 SPOT_1_HOLM,

102 SPOT_1_HOMMEL,

103 SPOT_1_SIMES_HOCHBERG,

104 SPOT_1_SIDAK,

105 SPOT_1_HOLM_SIDAK,

106 SPOT_1_FDR_BH,

107 SPOT_1_FDR_BY,

108 SPOT_1_FDR_TSBH,

109 SPOT_1_FDR_TSBKY,

110]

111

112 CORRECTION_METHODS_THAT_SUPPORT_CI = [

113 BONFERRONI,

114 HOLM,

115 HOMMEL,

116 SIMES_HOCHBERG,

117 BONFERRONI_ONLY_COUNT_TWOSIDED,

118 BONFERRONI_DO_NOT_COUNT_NON_INFERIORITY,

119 SPOT_1,

120 SPOT_1_HOLM,

121 SPOT_1_HOMMEL,

122 SPOT_1_SIMES_HOCHBERG,

123 SPOT_1_SIDAK,

124 SPOT_1_HOLM_SIDAK,

125 SPOT_1_FDR_BH,

126 SPOT_1_FDR_BY,

127 SPOT_1_FDR_TSBH,

128 SPOT_1_FDR_TSBKY,

129]

130

131 CORRECTION_METHODS_THAT_REQUIRE_METRIC_INFO = [

132 BONFERRONI_DO_NOT_COUNT_NON_INFERIORITY,

133 SPOT_1,

134 SPOT_1_HOLM,

135 SPOT_1_HOMMEL,

136 SPOT_1_SIMES_HOCHBERG,

137 SPOT_1_SIDAK,

138 SPOT_1_HOLM_SIDAK,

139 SPOT_1_FDR_BH,

140 SPOT_1_FDR_BY,

141 SPOT_1_FDR_TSBH,

142 SPOT_1_FDR_TSBKY,

143]

144

145 CORRECTION_METHODS_THAT_DONT_REQUIRE_METRIC_INFO = list(

146 set(CORRECTION_METHODS) - set(CORRECTION_METHODS_THAT_REQUIRE_METRIC_INFO)

147)

148

149 NULL_HYPOTHESIS = "null_hypothesis"

150 ALTERNATIVE_HYPOTHESIS = "alternative_hypothesis"

151 NIM = "non-inferiority margin"

152 NIM_COLUMN_DEFAULT = "non_inferiority_margin"

153 PREFERRED_DIRECTION_COLUMN_DEFAULT = "preferred_direction"

154 INCREASE_PREFFERED = "increase"

155 DECREASE_PREFFERED = "decrease"

156 TWO_SIDED = "two-sided"

157 PREFERENCE = "preference"

158 PREFERENCE_TEST = "preference_used_in_test"

159 PREFERENCE_DICT = {"smaller": DECREASE_PREFFERED, "larger": INCREASE_PREFFERED, TWO_SIDED: TWO_SIDED}

160 NIM_TYPE = Union[Tuple[float, str], Dict[str, Tuple[float, str]], bool]

161 METHOD_COLUMN_NAME = "_method"

162 CHI2 = "chi-squared"

163 TTEST = "t-test"

164 ZTEST = "z-test"

165 ZTESTLINREG = "z-test-linreg"

166 BOOTSTRAP = "bootstrap"

167 METHODS = [CHI2, TTEST, ZTEST, BOOTSTRAP, ZTESTLINREG]

168 REGRESSION_PARAM = "regression_parameters"