Kaggle competition: Cassava Leaf Disease Classification
<SOS> metric: CategorizationAccuracy Kaggle data source: cassava-leaf-disease-classification<save_to_csv>
print("Tensorflow version " + tf.__version__)
model = ensemble.GradientBoostingRegressor(random_state=4, loss='ls', learning_rate=0.02, n_estimators=1000, max_depth=7)
 model.fit(x1, y1)
 print(np.sqrt(metrics.mean_squared_error(y2, model.predict(x2))))
model.fit(train[col].fillna(-1), np.log1p(train['revenue']))
pred2 = model.predict(test[col].fillna(-1))
test['revenue'] = np.expm1(( pred1 * 0.9)+(pred2 * 0.1))
test[['id', 'revenue']].to_csv('submission.csv', index=False )<set_options>
dense201 = tf.keras.models.load_model('.. /input/train-model-cassava/densenet201.h5')
 inception = tf.keras.models.load_model('.. /input/train-model-cassava/inceptionv3.h5')
 efficient_net = tf.keras.models.load_model(
 '.. /input/train-model-cassava/efficient_netb3.h5',
compile=False,
custom_objects={'FixedDropout':FixedDropout}
)
pd.set_option('max_columns', None)
 %matplotlib inline
plt.style.use('ggplot')
 stop = set(stopwords.words('english'))
warnings.filterwarnings("ignore" )<load_from_csv>
JPEG_PATH = ".. /input/cassava-leaf-disease-classification/test_images"
def load_image(jpeg_path, image_id):
img = cv2.imread(os.path.join(jpeg_path, image_id)) /255.0
img = cv2.resize(img,(512, 512)) [:, :, ::-1]
return img
def generator(filepath, paths, batch_size=32):
i=0
print(len(paths))
while i <= len(paths):
batch = []
for cpt in range(batch_size):
if i + cpt >= len(paths):
i += batch_size
break
batch.append(load_image(filepath, paths[i+cpt]))
i += batch_size
yield np.stack(batch )
train=pd.read_csv('.. /input/train.csv',index_col=0)
 test=pd.read_csv('.. /input/test.csv',index_col=0 )<feature_engineering>
submission = pd.read_csv('.. /input/cassava-leaf-disease-classification/sample_submission.csv' )
test['revenue']=-99<drop_column>
def vote_in_ensemble(v1, v2, v3):
if v1 == v2:
return v1
if v2 == v3:
return v2
if v1 == v3:
return v3
return v1
train=train.drop('belongs_to_collection',axis=1)
 test=test.drop('belongs_to_collection',axis=1 )<feature_engineering>
def predict_for_pretrained(model):
ds_test = generator(JPEG_PATH,np.sort(submission.image_id.values))
preds = np.argmax(model.predict(ds_test, verbose=True), axis=-1)
 return preds
dense_preds = predict_for_pretrained(dense201)
 inception_preds = predict_for_pretrained(inception)
 efficient_net_preds = predict_for_pretrained(efficient_net)
 result = []
for idx, val in enumerate(dense_preds):
result.append(
 vote_in_ensemble(
 dense_preds[idx],
inception_preds[idx],
efficient_net_preds[idx] 
)
 )
<feature_engineering><EOS> 
submission["label"] = result
submission.to_csv("submission.csv", index=False )