<jupyter_start><jupyter_text>Validation VGG<jupyter_code>model = resnet50
model = vgg16
tfms = tfms_from_model(model, 64, aug_tfms=transforms_side_on, max_zoom=1.05)

data = ImageClassifierData.from_csv(
    path='../data',
    folder='train',
    csv_fname='../data/train/train.csv',
    bs=32,
    test_name='test',
    skip_header=True,
    suffix='.jpg',
    val_idxs=get_cv_idxs(n, val_pct=0.2),
    tfms=tfms
)
learn = ConvLearner.pretrained(model, data)
learn.load('80k_unfrozen_vgg_l062_03.h5')
y_pred_tta, y = learn.TTA()
y_pred_mean_tta = np.mean(y_pred_tta, axis=0)
f1_score(data.val_y, (y_pred_mean_tta > 0.25).astype('int'), average='micro')
f1_score(data.val_y, (y_pred_mean_tta > 0.25).astype('int'), average='micro')<jupyter_output><empty_output><jupyter_text>Resnet<jupyter_code>model = resnet50
tfms = tfms_from_model(model, 64, aug_tfms=transforms_side_on, max_zoom=1.05)

data = ImageClassifierData.from_csv(
    path='../data',
    folder='train',
    csv_fname='../data/train/train.csv',
    bs=32,
    test_name='test',
    skip_header=True,
    suffix='.jpg',
    val_idxs=get_cv_idxs(n, val_pct=0.2),
    tfms=tfms
)
learn = ConvLearner.pretrained(model, data)
learn.load('80k_unfrozen_res50_l064_07.h5')
y_res_pred_tta.shape
model = resnet50
tfms = tfms_from_model(model, 64, aug_tfms=transforms_side_on, max_zoom=1.05)

data = ImageClassifierData.from_csv(
    path='../data',
    folder='train',
    csv_fname='../data/train/train.csv',
    bs=32,
    test_name='test',
    skip_header=True,
    suffix='.jpg',
    val_idxs=get_cv_idxs(n, val_pct=0.2),
    tfms=tfms
)

learn = ConvLearner.pretrained(model, data)
learn.load('80k_unfrozen_res50_l064_07.h5')

y_test_res_pred_tta, y = learn.TTA(is_test=True)
y_test_res_pred_mean_tta = np.mean(y_test_res_pred_tta, axis=0)
f1_score(y, (y_res_pred_mean_tta > 0.25).astype('int'), average='micro')
y_ens = np.array([y_pred_mean_tta, y_res_pred_mean_tta])
y_ens_pred = np.mean(y_ens, axis=0)
f1_score(y, (y_ens_pred > 0.25).astype('int'), average='micro')
for p in np.arange(0.2, 0.3, 0.01):
    print(p, f1_score(y, (y_ens_pred > p).astype('int'), average='micro'))<jupyter_output>0.2 0.555426111932
0.21 0.558119169008
0.22 0.560070217123
0.23 0.561795515736
0.24 0.56306628572
0.25 0.563529157302
0.26 0.563864926709
0.27 0.56390548972
0.28 0.563173214003
0.29 0.562687963308<jupyter_text>Test Set  Resnet<jupyter_code>model = resnet50
tfms = tfms_from_model(model, 64, aug_tfms=transforms_side_on, max_zoom=1.05)

data = ImageClassifierData.from_csv(
    path='../data',
    folder='train',
    csv_fname='../data/train/train.csv',
    bs=32,
    test_name='test',
    skip_header=True,
    suffix='.jpg',
    val_idxs=get_cv_idxs(n, val_pct=0.2),
    tfms=tfms
)

learn = ConvLearner.pretrained(model, data)
learn.load('80k_unfrozen_res50_l064_07.h5')

y_test_res_pred_tta, y = learn.TTA(is_test=True)
y_test_res_pred_mean_tta = np.mean(y_test_res_pred_tta, axis=0)<jupyter_output><jupyter_text>VGG<jupyter_code>model = vgg16
tfms = tfms_from_model(model, 64, aug_tfms=transforms_side_on, max_zoom=1.05)

data = ImageClassifierData.from_csv(
    path='../data',
    folder='train',
    csv_fname='../data/train/train.csv',
    bs=32,
    test_name='test',
    skip_header=True,
    suffix='.jpg',
    val_idxs=get_cv_idxs(n, val_pct=0.2),
    tfms=tfms
)

learn = ConvLearner.pretrained(model, data)
learn.load('80k_unfrozen_vgg_l062_03.h5')

y_test_vgg_pred_tta, y = learn.TTA(is_test=True)
y_test_vgg_pred_mean_tta = np.mean(y_test_vgg_pred_tta, axis=0)<jupyter_output><jupyter_text>Mean<jupyter_code>y_test_ens = np.array([y_test_res_pred_mean_tta, y_test_vgg_pred_mean_tta])
y_test_pred = np.mean(y_test_ens, axis=0)
y_pred = (y_test_pred > 0.27).astype('int')<jupyter_output><empty_output><jupyter_text>Upload<jupyter_code>indexes = y_pred * np.array([np.arange(len(y_pred[0])) for _ in np.arange(len(y_pred))])
indexes = indexes.tolist()
test_files = [f.split('/')[1].split('.')[0] for f in data.test_ds.fnames]
test_labels = [" ".join([data.classes[index] for index in row if index > 0]) for row in indexes]
test_df = pd.DataFrame({'image_id': test_files, 'label_id': test_labels})
test_df['image_id'] = test_df['image_id'].astype('int')
test_df = test_df.sort_values('image_id').reset_index(drop=True)
test_df.to_csv('submission_07_jc.csv', index=False)
y_pred<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1553575508339045, 'fraction_numerical': 0.06831162896961389, 'mean_word_length': 5.840625, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '390526', 'license': 'MIT', 'n_tokens_mistral': 2120, 'n_tokens_neox': 1951, 'n_words': 240, 'path': 'notebooks/02-JC-Testing and Submission.ipynb', 'repo_name': 'joshcarty/imaterialist-challenge-fashion-2018', 'size': '4377'}