Kaggle competition: Cassava Leaf Disease Classification
<SOS> metric: CategorizationAccuracy Kaggle data source: cassava-leaf-disease-classification<save_to_csv>
!pip install.. /input/efficientnet-install-files/Ker*.whl
!pip install.. /input/efficientnet-install-files/eff*.whl
with ignore_warnings(category=FutureWarning):
lr2_predictions = lr2.predict_proba(test_ohe)
 lr2_submission = pd.DataFrame({'id': test_id, 'target': lr2_predictions[:, 1]})
 lr2_submission.to_csv('lr2.csv', index=False)
 lr2_submission.head()<choose_model_class>
loss = BiTemperedLogisticLoss(t1=0.6, t2=1.4 )
%%time
class MyModule(nn.Module):
def __init__(self, num_units=20):
super(MyModule, self ).__init__()
self.dense1 = nn.Linear(train.shape[1], num_units)
 self.dropout = nn.Dropout(0.5)
 self.dense2 = nn.Linear(num_units, 2)
 def forward(self, X, **kwargs):
X = self.dense1(X)
 X = torch.tanh(X)
 X = self.dropout(X)
 X = self.dense2(X)
 X = F.softmax(X, dim=-1)
 return X
net = NeuralNetClassifier(
 MyModule,
max_epochs=20,
lr=0.01,
iterator_train__shuffle=True, 
)
 pipe = Pipeline([ 
('scale', StandardScaler()), 
('net', net),
])
 print('CV:', cross_val_score(pipe,
train.values.astype('float32'),
target.values,
cv=2,
n_jobs=-1,
scoring='roc_auc' ).mean() )<data_type_conversions>
IMG_SIZE = 512
size =(IMG_SIZE,IMG_SIZE)
 best_model = keras.models.load_model('.. /input/cassava-challenge-models/Cassava_model_effnetb4_mixed_precision_bitemperedloss(29jan ).h5',compile=False)
 print(best_model)
 TEST_DIR = '.. /input/cassava-leaf-disease-classification/test_images/'
test_images = os.listdir(TEST_DIR)
 predictions = []
for image in test_images:
img = Image.open(TEST_DIR + image)
 print(img)
 img = img.resize(size)
 print(img)
 img = np.expand_dims(img, axis=0)
 print(img.shape)
 predictions.extend(best_model.predict(img ).argmax(axis = 1))
print(best_model.predict(img))
sub = pd.DataFrame({'image_id': test_images, 'label': predictions})
 sub.to_csv('submission.csv', index = False )