def _evaluate_pipeline(pipeline_name, validation_size): meta = pd.read_csv(os.path.join(params.meta_dir, 'stage1_metadata.csv')) meta_train = meta[meta['is_train'] == 1] valid_ids = eval(params.valid_category_ids) meta_train_split, meta_valid_split = train_valid_split(meta_train, validation_size, valid_category_ids=valid_ids) data = {'input': {'meta': meta_valid_split, 'meta_valid': None, 'train_mode': False, 'target_sizes': meta_valid_split[SIZE_COLUMNS].values }, } y_true = read_masks(meta_valid_split[Y_COLUMNS_SCORING].values) pipeline = PIPELINES[pipeline_name]['inference'](SOLUTION_CONFIG) pipeline.clean_cache() output = pipeline.transform(data) pipeline.clean_cache() y_pred = output['y_pred'] logger.info('Calculating IOU and IOUT Scores') iou_score = intersection_over_union(y_true, y_pred) logger.info('IOU score on validation is {}'.format(iou_score)) ctx.channel_send('IOU Score', 0, iou_score) iout_score = intersection_over_union_thresholds(y_true, y_pred) logger.info('IOUT score on validation is {}'.format(iout_score)) ctx.channel_send('IOUT Score', 0, iout_score)
def _train_pipeline(pipeline_name, validation_size): if bool(params.overwrite) and os.path.isdir(params.experiment_dir): shutil.rmtree(params.experiment_dir) meta = pd.read_csv(os.path.join(params.meta_dir, 'stage1_metadata.csv')) meta_train_split, meta_valid_split = train_valid_split(meta, validation_size) data = {'input': {'meta': meta_train_split, 'meta_valid': meta_valid_split, 'train_mode': True, 'target_sizes': meta_train_split[SIZE_COLUMNS].values }, } pipeline = PIPELINES[pipeline_name]['train'](SOLUTION_CONFIG) pipeline.fit_transform(data)