Kaggle competition: APTOS 2019 Blindness Detection
<SOS> metric: QuadraticWeightedKappa Kaggle data source: aptos-2019-blindness-detection<create_dataframe>

 !pip install.. /input/efficientnet/efficientnet-master/efficientnet-master
set_random_seed(2)
 np.random.seed(0)
first_level = pd.DataFrame(xgb_val_pred, columns=["xgb"])
 first_level["rf"] = rf_val_pred
first_level.info()
first_level_test = pd.DataFrame(xgb_test_pred, columns=["xgb"])
 first_level_test["rf"] = rf_test_pred
first_level_test.info()<train_model>

 IMG_SIZE = 300
BATCH_SIZE = 16
meta_model = LinearRegression(n_jobs=-1)
 meta_model.fit(first_level, y_val )<predict_on_test>

 def output_relu(x):
return K.relu(x, max_value=4)
 base_model = EfficientNetB3(weights=None, include_top=False, input_shape=(IMG_SIZE,IMG_SIZE,3))
x = base_model.output
x = GlobalAveragePooling2D()(x)
 x = Dropout(0.4 )(x)
 x = Dense(1, activation=output_relu, kernel_initializer='he_normal' )(x)
 model = Model(inputs=base_model.input, outputs=x )
test_prediction = meta_model.predict(first_level_test )<create_dataframe>

 train_csv = pd.read_csv('.. /input/aptos2019-blindness-detection/train.csv')
 train_id_codes = train_csv['id_code']
train_labels = train_csv['diagnosis']
for i in range(len(train_id_codes)) :
train_id_codes[i] = '.. /input/aptos2019-blindness-detection/train_images/{}.png'.format(train_id_codes[i])
 test_csv = pd.read_csv('.. /input/aptos2019-blindness-detection/sample_submission.csv')
 test_id_codes = test_csv['id_code']
test_pseudo_labels = np.empty(len(test_id_codes), dtype='float32')
 for i in range(len(test_id_codes)) :
test_id_codes[i] = '.. /input/aptos2019-blindness-detection/test_images/{}.png'.format(test_id_codes[i])
 img = cv2.imread(test_id_codes[i])
 img = load_ben_color(img)
 X = np.array([img])
 pred = model.predict(X)
 test_pseudo_labels[i] = pred
submission = pd.DataFrame(test_prediction, columns=["item_cnt_month"] ).clip(0, 20 ).reset_index()
submission.columns = ["ID", "item_cnt_month"]
print(submission )<save_to_csv>

 d = {}
d['id_code'] = np.concatenate(( train_id_codes, test_id_codes), axis=0)
 d['diagnosis'] = np.concatenate(( train_labels, test_pseudo_labels), axis=0 ).astype('str')
 df = pd.DataFrame(data=d )
submission.to_csv("submission.csv", index=False )<save_to_csv>

 fig, ax = plt.subplots(nrows=1, ncols=4, figsize=(20,4))
it = 0
for x, y in pseudo_datagen:
ax[it].imshow(( x[0]*255.).astype('uint8'))
ax[it].axis('off')
 it += 1
if it == 4:
break
<define_variables><EOS> 

 prediction = predict(test_prediction ).astype('uint8')
 test_csv['diagnosis'] = prediction
test_csv.to_csv("submission.csv", index=False)
 unique, counts = np.unique(prediction, return_counts=True)
 tmp = dict(zip(unique, counts))
print(tmp)
 print('Done!' )