def test_full_data_check(self): print("Boost model folder: ", self.boost_model_folder) decision_maker = BoostingDecisionMaker(self.boost_model_folder) boost_model_results = self.get_fixture(self.boost_model_results) tests = [ { "elastic_results": [(self.get_fixture(self.log_message), self.get_fixture(self.one_hit_search_rs_explained))], "config": TestBoostingModel.get_default_config(), }, { "elastic_results": [(self.get_fixture(self.log_message), self.get_fixture(self.two_hits_search_rs_explained))], "config": TestBoostingModel.get_default_config(), }, { "elastic_results": [(self.get_fixture(self.log_message), self.get_fixture(self.two_hits_search_rs_explained)), (self.get_fixture(self.log_message), self.get_fixture(self.one_hit_search_rs_explained))], "config": TestBoostingModel.get_default_config(), }, { "elastic_results": [(self.get_fixture(self.log_message_only_small_logs), self.get_fixture(self.two_hits_search_rs_small_logs))], "config": TestBoostingModel.get_default_config(), }, ] for idx, test in enumerate(tests): _boosting_featurizer = BoostingFeaturizer( test["elastic_results"], test["config"], decision_maker.get_feature_ids()) with sure.ensure('Error in the test case number: {0}', idx): gathered_data, issue_type_names = _boosting_featurizer.gather_features_info( ) gathered_data.should.equal(boost_model_results[str(idx)][0], epsilon=self.epsilon) predict_label, predict_probability = decision_maker.predict( gathered_data) predict_label.tolist().should.equal( boost_model_results[str(idx)][1], epsilon=self.epsilon) predict_probability.tolist().should.equal( boost_model_results[str(idx)][2], epsilon=self.epsilon)
def test_full_data_check(self): print("Boost model folder : ", self.boost_model_folder) print("Weights model folder : ", self.weights_folder) print("Global defect type model folder : ", self.global_defect_type_model_folder) decision_maker = BoostingDecisionMaker(folder=self.boost_model_folder) boost_model_results = utils.get_fixture(self.boost_model_results, to_json=True) tests = [] for log_lines, filter_fields, _decision_maker in [ (-1, ["detected_message", "stacktrace"], decision_maker), (2, ["message"], decision_maker) ]: tests.extend([ { "elastic_results": [(utils.get_fixture(self.log_message, to_json=True), utils.get_fixture(self.one_hit_search_rs_explained, to_json=True))], "config": self.get_default_config(number_of_log_lines=log_lines, filter_fields=filter_fields), "decision_maker": _decision_maker }, { "elastic_results": [(utils.get_fixture(self.log_message, to_json=True), utils.get_fixture(self.two_hits_search_rs_explained, to_json=True))], "config": self.get_default_config(number_of_log_lines=log_lines, filter_fields=filter_fields), "decision_maker": _decision_maker }, { "elastic_results": [(utils.get_fixture(self.log_message, to_json=True), utils.get_fixture(self.two_hits_search_rs_explained, to_json=True)), (utils.get_fixture(self.log_message, to_json=True), utils.get_fixture(self.one_hit_search_rs_explained, to_json=True))], "config": self.get_default_config(number_of_log_lines=log_lines, filter_fields=filter_fields), "decision_maker": _decision_maker }, { "elastic_results": [(utils.get_fixture(self.log_message_only_small_logs, to_json=True), utils.get_fixture(self.two_hits_search_rs_small_logs, to_json=True))], "config": self.get_default_config(number_of_log_lines=log_lines, filter_fields=filter_fields), "decision_maker": _decision_maker }, ]) for idx, test in enumerate(tests): feature_ids = test["decision_maker"].get_feature_ids() weight_log_sim = None if self.weights_folder.strip(): weight_log_sim = weighted_similarity_calculator.\ WeightedSimilarityCalculator(folder=self.weights_folder) _boosting_featurizer = BoostingFeaturizer( test["elastic_results"], test["config"], feature_ids, weighted_log_similarity_calculator=weight_log_sim) if self.global_defect_type_model_folder.strip(): _boosting_featurizer.set_defect_type_model( defect_type_model.DefectTypeModel( folder=self.global_defect_type_model_folder)) with sure.ensure('Error in the test case number: {0}', idx): gathered_data, issue_type_names = _boosting_featurizer.gather_features_info( ) gathered_data.should.equal(boost_model_results[str(idx)][0], epsilon=self.epsilon) predict_label, predict_probability = test[ "decision_maker"].predict(gathered_data) predict_label.tolist().should.equal( boost_model_results[str(idx)][1], epsilon=self.epsilon) predict_probability.tolist().should.equal( boost_model_results[str(idx)][2], epsilon=self.epsilon)