Kaggle competition: APTOS 2019 Blindness Detection
scenario_3 = train.loc[(train['H_Distance']!=0)&(train['fare_amount']==0)]<sort_values>
N = test_df.shape[0]
x_test = np.empty(( N, im_size, im_size, 3), dtype=np.uint8)
 try:
for i, image_id in enumerate(test_df['id_code']):
x_test[i, :, :, :] = preprocess_image(
 f'.. /input/aptos2019-blindness-detection/test_images/{image_id}.png',
desired_size=im_size 
)
 print('Test dataset correctly processed')
 except:
print('Test dataset NOT processed' )
scenario_3.sort_values('H_Distance', ascending=False )<feature_engineering>
print(os.listdir(".. /input/kerasefficientnetsmaster/keras-efficientnets-master/keras-efficientnets-master/keras_efficientnets"))
sys.path.append(os.path.abspath('.. /input/kerasefficientnetsmaster/keras-efficientnets-master/keras-efficientnets-master/'))
effnet = EfficientNetB5(input_shape=(im_size,im_size,3),
weights=sys.path.append(os.path.abspath('.. /input/efficientnet-keras-weights-b0b5/efficientnet-b5_imagenet_1000_notop.h5')) ,
include_top=False)
 def build_model() :
model = Sequential()
model.add(effnet)
 model.add(layers.Dropout(0.25))
model.add(layers.Dense(2048))
model.add(layers.LeakyReLU())
 model.add(layers.GlobalAveragePooling2D())
 model.add(layers.Dropout(0.5))
model.add(layers.Dense(1, activation='linear'))
return model
model = build_model()
model.load_weights('.. /input/efficientnet-keras-aptos/model.h5')
 model.summary()
<filter><EOS> 
y_test = model.predict(x_test)
 coef = [0.5, 1.5, 2.5, 3.5]
for i, pred in enumerate(y_test):
if pred < coef[0]:
y_test[i] = 0
elif pred >= coef[0] and pred < coef[1]:
y_test[i] = 1
elif pred >= coef[1] and pred < coef[2]:
y_test[i] = 2
elif pred >= coef[2] and pred < coef[3]:
y_test[i] = 3
else:
y_test[i] = 4
test_df['diagnosis'] = y_test.astype(int)
 test_df.to_csv('submission.csv',index=False)
 print(round(test_df.diagnosis.value_counts() /len(test_df)*100,4))