Kaggle competition: [DM&PR WS19/20] Machine learning competition
test_transform = transforms.Compose([
transforms.RandomHorizontalFlip() ,
transforms.RandomRotation(( -120, 120)) ,
transforms.ToTensor() ,
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])
 testset = MyDataset(pd.read_csv('.. /input/aptos2019-blindness-detection/sample_submission.csv'),
transform=test_transform)
 test_loader = torch.utils.data.DataLoader(testset, batch_size=16, shuffle=False )<load_pretrained>
import pandas as pd
import numpy as np
from sklearn.tree import DecisionTreeClassifier
model = EfficientNet.from_name('efficientnet-b0')
 in_features = model._fc.in_features
model._fc = nn.Linear(in_features, num_classes)
 model.load_state_dict(torch.load('.. /input/enet0802/weight_best_0802.pt'))
model.cuda()<find_best_params>
PATH = '.. /input/dm-and-pr-ws1920-machine-learning-competition/'
df_train = pd.read_csv(PATH+'train.csv')
 df_test = pd.read_csv(PATH+'test.csv')
 sample_sub = pd.read_csv(PATH+'sampleSubmission.csv' )
for param in model.parameters() :
param.requires_grad = False<load_from_csv>
X = df_train.profession.values
y = df_train.target.values
X_test = df_test.profession.values
sample = pd.read_csv('.. /input/aptos2019-blindness-detection/sample_submission.csv' )<predict_on_test>
model = DecisionTreeClassifier(max_depth=4)
 model.fit(X.reshape(-1,1),y)
 y_hat = model.predict_proba(X_test.reshape(-1,1)) [:,1]
%%time
test_pred = np.zeros(( len(sample), 1))
model.eval()
for _ in range(TTA):
with torch.no_grad() :
for i, data in tqdm(enumerate(test_loader)) :
images, _ = data
images = images.cuda()
pred = model(images)
 test_pred[i * 16:(i + 1)* 16] += pred.detach().cpu().squeeze().numpy().reshape(-1, 1)
 output = test_pred / TTA<categorify>
sample_sub['target'] = y_hat
sample_sub.head()
<import_modules><EOS> 
sample_sub.to_csv('estimation_01.csv', index=False )