Coverage for /Users/sebastiana/Documents/Sugarpills/confidence/spotify_confidence/analysis/frequentist/boostrap_test.py: 0%

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

13 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 typing import Union, Iterable 

16 

17from pandas import DataFrame 

18 

19from spotify_confidence.analysis.frequentist.confidence_computers.generic_computer import GenericComputer 

20from spotify_confidence.analysis.abstract_base_classes.confidence_computer_abc import ConfidenceComputerABC 

21from spotify_confidence.analysis.abstract_base_classes.confidence_grapher_abc import ConfidenceGrapherABC 

22from spotify_confidence.analysis.frequentist.generic_test import GenericTest 

23from spotify_confidence.analysis.confidence_utils import listify 

24from spotify_confidence.analysis.constants import BONFERRONI, METHOD_COLUMN_NAME 

25 

26 

27class BootstrapTest(GenericTest): 

28 def __init__( 

29 self, 

30 data_frame: DataFrame, 

31 bootstrap_samples_column: [], 

32 categorical_group_columns: Union[str, Iterable], 

33 ordinal_group_column: Union[str, None] = None, 

34 interval_size: float = 0.95, 

35 correction_method: str = BONFERRONI, 

36 confidence_computer: ConfidenceComputerABC = None, 

37 confidence_grapher: ConfidenceGrapherABC = None, 

38 ): 

39 

40 if confidence_computer is None: 

41 confidence_computer = GenericComputer( 

42 data_frame=data_frame.assign(**{METHOD_COLUMN_NAME: "bootstrap"}), 

43 numerator_column=None, 

44 numerator_sum_squares_column=None, 

45 denominator_column=None, 

46 categorical_group_columns=listify(categorical_group_columns), 

47 ordinal_group_column=ordinal_group_column, 

48 interval_size=interval_size, 

49 correction_method=correction_method.lower(), 

50 method_column=METHOD_COLUMN_NAME, 

51 bootstrap_samples_column=bootstrap_samples_column, 

52 ) 

53 

54 super(BootstrapTest, self).__init__( 

55 data_frame.assign(**{METHOD_COLUMN_NAME: "bootstrap"}), 

56 None, 

57 None, 

58 None, 

59 categorical_group_columns, 

60 ordinal_group_column, 

61 interval_size, 

62 correction_method, 

63 confidence_computer, 

64 confidence_grapher, 

65 METHOD_COLUMN_NAME, 

66 bootstrap_samples_column, 

67 )