Kaggle competition: APTOS 2019 Blindness Detection
<SOS> metric: QuadraticWeightedKappa Kaggle data source: aptos-2019-blindness-detection<define_variables>
!pip install.. /input/efficientnet/efficientnet-master/efficientnet-master
for ingredient in training_data['ingredients']:
for element in ingredient:
if element not in ingredients:
ingredients.append(element )<define_variables>
set_random_seed(2)
 np.random.seed(0)
for cuisine in training_data['cuisine']:
if cuisine not in cuisines:
cuisines.append(cuisine )<prepare_x_and_y>
from efficientnet.keras import *
X_train=training_data.copy()
X_test=test_data.copy()<feature_engineering>

 def output_relu(x):
return K.relu(x, max_value=4)
 def get_model(version, IMG_SIZE):
base_model = 0
if version == 0:
base_model = EfficientNetB0(weights=None, include_top=False, input_shape=(IMG_SIZE,IMG_SIZE,3))
elif version == 1:
base_model = EfficientNetB1(weights=None, include_top=False, input_shape=(IMG_SIZE,IMG_SIZE,3))
elif version == 2:
base_model = EfficientNetB2(weights=None, include_top=False, input_shape=(IMG_SIZE,IMG_SIZE,3))
elif version == 3:
base_model = EfficientNetB3(weights=None, include_top=False, input_shape=(IMG_SIZE,IMG_SIZE,3))
elif version == 4:
base_model = EfficientNetB4(weights=None, include_top=False, input_shape=(IMG_SIZE,IMG_SIZE,3))
else:
return None
x = base_model.output
x = GlobalAveragePooling2D()(x)
 x = Dense(1, activation=output_relu, kernel_initializer='he_normal' )(x)
 model = Model(inputs=base_model.input, outputs=x)
 return model
for element in ingredients:
X_train[element]=0
X_test[element]=0<define_variables>
model_b0_256 = get_model(0, 300)
 model_b0_256.load_weights('.. /input/pretrained-weights/model_b0_finetuned_20_epochs.h5')
 model_b1_240 = get_model(1, 300)
 model_b1_240.load_weights('.. /input/pretrained-weights/model_b1.h5')
 model_b3_300 = get_model(3, 300)
 model_b3_300.load_weights('.. /input/pretrained-weights/model_b3_epochs_30_300.h5' )
index =0
for row in X_train['ingredients']:
for element in row:
X_train.at[index,element]=1
index = index + 1<feature_engineering>
test_csv = pd.read_csv('.. /input/aptos2019-blindness-detection/sample_submission.csv')
 id_code = test_csv['id_code']
prediction = np.empty(len(id_code), dtype='uint8')
 for i in range(len(id_code)) :
img = cv2.imread('.. /input/aptos2019-blindness-detection/test_images/{}.png'.format(id_code[i]))
img300 = load_ben_color(img, 300 ).astype('float32')/ 255.
 X3 = np.array([img300])
 pred1 = model_b0_256.predict(X3)
 pred2 = model_b1_240.predict(X3)
 pred3 = model_b3_300.predict(X3)
 pred1 = np.mean(pred1)
 pred2 = np.mean(pred2)
 pred3 = np.mean(pred3)
 pred =(pred1 + pred2 + pred3)/ 3
pred = np.rint(pred ).astype('uint8')
 print(pred)
 prediction[i] = pred
<drop_column><EOS> 
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 )