def generateAlertsCsvFile(self, directory): detection_threshold = self.alerts_conf.detection_threshold with open(directory + 'alerts.csv', 'w') as f: alerts = matrix_tools.extractRowsWithThresholds( self.predictions_monitoring.predictions, detection_threshold, None, 'predicted_proba') alerts = matrix_tools.sortDataFrame(alerts, 'predicted_proba', False, False) alerts.to_csv(f, index_label='instance_id') return list(alerts.index.values)
def getPredictions(experiment_id, train_test, index): experiment = updateCurrentExperiment(experiment_id) filename = experiment.getOutputDirectory() filename += train_test + '/predictions.csv' index = int(index) min_value = index * 0.1 max_value = (index + 1) * 0.1 with open(filename, 'r') as f: data = pd.read_csv(f, header=0, index_col=0) data = matrix_tools.extractRowsWithThresholds(data, min_value, max_value, 'predicted_proba') selected_instances = list(data.index.values) proba = list(data['predicted_proba']) return jsonify({'instances': selected_instances, 'proba': proba})
def runModels(self, already_queried = None): df = matrix_tools.extractRowsWithThresholds(self.predictions, self.proba_min, self.proba_max, 'predicted_proba') if already_queried is not None: self.predicted_ids = list(set(df.index).difference(set(already_queried))) else: self.predicted_ids = list(df.index) datasets = self.iteration.datasets self.annotated_instances = datasets.getAnnotatedInstances(label = self.label) self.families_analysis = self.familiesAnalysis() if self.families_analysis: self.annotations_type = 'families' start_time = time.time() self.buildCategories() self.analysis_time = time.time() - start_time self.categories.setLikelihood(self.iteration.iteration_number) else: self.annotations_type = 'individual' self.categories = None self.analysis_time = 0