Coverage for /Users/sebastiana/Documents/Sugarpills/confidence/spotify_confidence/analysis/abstract_base_classes/confidence_grapher_abc.py: 89%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

18 statements  

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 

15from abc import ABC, abstractmethod 

16from typing import Union, Iterable 

17 

18from pandas import DataFrame 

19 

20from spotify_confidence.chartgrid import ChartGrid 

21from ..constants import NIM_TYPE 

22 

23 

24class ConfidenceGrapherABC(ABC): 

25 @abstractmethod 

26 def __init__( 

27 self, 

28 data_frame: DataFrame, 

29 numerator_column: str, 

30 denominator_column: str, 

31 categorical_group_columns: str, 

32 ordinal_group_column: str, 

33 ): 

34 pass 

35 

36 @abstractmethod 

37 def plot_summary(self, summary_df: DataFrame, groupby: Union[str, Iterable]) -> ChartGrid: 

38 """Plot for each group in the data_frame: 

39 

40 if ordinal level exists: 

41 line graph with area to represent confidence interval 

42 if categorical levels: 

43 Interval plots of confidence intervals by group 

44 

45 Args: 

46 summary_df (DataFrame): A data frame produced by a 

47 ConfidenceComputer's summary method 

48 

49 Returns: 

50 ChartGrid object. 

51 """ 

52 pass 

53 

54 @abstractmethod 

55 def plot_difference( 

56 self, 

57 difference_df: DataFrame, 

58 absolute: bool, 

59 groupby: Union[str, Iterable], 

60 nims: NIM_TYPE, 

61 use_adjusted_intervals: bool, 

62 ) -> ChartGrid: 

63 """Plot representing the difference between group 1 and 2 with 

64 confidence intervals. 

65 

66 Args: 

67 difference_df (DataFrame): A dataframe produced by a 

68 ConfidenceComputer's difference method 

69 

70 Returns: 

71 Chartify Chart object. 

72 :param groupby: 

73 """ 

74 

75 @abstractmethod 

76 def plot_differences( 

77 self, 

78 difference_df: DataFrame, 

79 absolute: bool, 

80 groupby: Union[str, Iterable], 

81 nims: NIM_TYPE, 

82 use_adjusted_intervals: bool, 

83 ) -> ChartGrid: 

84 """Plot representing the difference between group 1 and 2 with 

85 confidence intervals. 

86 

87 Args: 

88 difference_df (DataFrame): A dataframe produced by a 

89 ConfidenceComputer's difference method 

90 

91 Returns: 

92 Chartify Chart object. 

93 :param groupby: 

94 """ 

95 

96 @abstractmethod 

97 def plot_multiple_difference( 

98 self, 

99 difference_df: DataFrame, 

100 absolute: bool, 

101 groupby: Union[str, Iterable], 

102 level_as_reference: bool, 

103 nims: NIM_TYPE, 

104 use_adjusted_intervals: bool, 

105 ) -> ChartGrid: 

106 """Compare level to all other groups or, if level_as_reference = True, 

107 all other groups to level. 

108 

109 Args: 

110 difference_df (DataFrame): A dataframe produced by a 

111 ConfidenceComputer's multiple_difference method 

112 

113 Returns: 

114 ChartGrid object. 

115 """