def test_data_normalization(self): self.t = thresher.Thresher(labels=(0, 1)) actual_classes = [0, 0, 1, 1] compute_result = self.t.optimize_threshold(self.scores, actual_classes) print(f'[ThresherVerySmallTest] Result found: {compute_result}') self.assertTrue( 0.3 <= compute_result < 0.4, msg="Checking proper result for the ThresherVerySmallTest")
def test_data_case_parallel(self): self.t = thresher.Thresher(algorithm_params={'n_jobs': 3}) actual_classes = [-1, -1, -1, -1, -1, -1, -1, 1, 1] compute_result = self.t.optimize_threshold(self.scores, actual_classes) print(f'[ThresherVerySmallTest] Result found: {compute_result}') self.assertTrue( 0.3 <= compute_result < 0.4, msg="Checking proper result for the ThresherVerySmallTest")
def setUp(self): # Preparing data for unit test self.t = thresher.Thresher(verbose=False, progress_bar=False) self.alt_t = thresher.Thresher(algorithm='linear', verbose=False, progress_bar=False) self.alt_t2 = thresher.Thresher(algorithm='sim', verbose=False, progress_bar=False) self.alt_t3 = thresher.Thresher(algorithm='grid') self.alt_t4 = thresher.Thresher(algorithm='sgrid', algorithm_params={ 'no_of_decimal_places': 2, 'stoch_ratio': 0.10 }) self.alt_t5 = thresher.Thresher(algorithm='sgrid', algorithm_params={ 'no_of_decimal_places': 3, 'stoch_ratio': 0.06, 'reshuffle': True }) print('Preparing data for ThresherMediumTest...') medium_data = get_sample_data(path='./') self.scores = list(medium_data['pred'].values) self.actual_classes = list(medium_data['actual'].values) self.left_allowed, self.right_allowed = 0.40, 0.65
def setUp(self): # Preparing data for unit test self.t = thresher.Thresher(progress_bar=False) self.scores = [0.1, 0.15, 0.2, 0.22, 0.27, 0.29, 0.3, 0.4, 0.7]
import thresher from thresher.tests.sample_data import get_sample_data t = thresher.Thresher(progress_bar=True) print('Currently supported algorithms:') print(t.get_supported_algorithms()) case_small_scores = [0.1, 0.3, 0.4, 0.7] case_small_labels = [-1, -1, 1, 1] print( f'Optimization result: {t.optimize_threshold(case_small_scores, case_small_labels)}' ) t = thresher.Thresher(progress_bar=True, verbose=True) medium_data = get_sample_data() case_medium_scores = list(medium_data['pred'].values) case_medium_labels = list(medium_data['actual'].values) print( f'Optimization result: {t.optimize_threshold(case_medium_scores, case_medium_labels)}' ) t = thresher.Thresher(algorithm='gen', progress_bar=True, verbose=True) medium_data = get_sample_data() case_medium_scores = list(medium_data['pred'].values) case_medium_labels = list(medium_data['actual'].values)
import thresher from thresher.tests.sample_data import get_sample_data t = thresher.Thresher(verbose=True, algorithm_params={'n_jobs': 3}) print('Currently supported algorithms:') print(t.get_supported_algorithms()) case_small_scores = [0.1, 0.15, 0.2, 0.22, 0.27, 0.29, 0.3, 0.4, 0.7] case_small_labels = [-1, -1, -1, -1, -1, -1, -1, 1, 1] print( f'Optimization result: {t.optimize_threshold(case_small_scores, case_small_labels)}' ) print('Done')