Kaggle competition: Microsoft Malware Prediction
<SOS> metric: AUC Kaggle data source: microsoft-malware-prediction<import_modules>
import pandas as pd, numpy as np, os, gc
import matplotlib.pyplot as plt
from datetime import datetime
from datetime import timedelta
import torch
import torch.nn as nn
from torchvision import transforms
from torch.utils.data import Dataset, DataLoader
from torch.utils.data.sampler import SubsetRandomSampler
import torchvision.transforms as transforms<import_modules>
AdjustPublicScore = True
AdjustPrivateScore = 2
dtypes = {}
dtypes['MachineIdentifier'] = 'str'
dtypes['AvSigVersion'] = 'category'
dtypes['HasDetections'] = 'int8'
df_train = pd.read_csv('.. /input/microsoft-malware-prediction/train.csv', usecols=list(dtypes.keys()), dtype=dtypes)
 print('Loaded',len(df_train),'rows of train.CSV!')
 df_test = pd.read_csv('.. /input/microsoft-malware-prediction/test.csv', usecols=list(dtypes.keys())[0:-1], dtype=dtypes)
 print('Loaded',len(df_test),'rows of test.CSV!')
 df_test2 = pd.read_csv('.. /input/kagglebest/super_blend.csv')
 print('Loaded',len(df_test),'rows of super_blend.csv!')
 datedictAS = np.load('.. /input/malware-timestamps/AvSigVersionTimestamps.npy')[() ]
df_test['Date'] = df_test['AvSigVersion'].map(datedictAS)
 df_train['Date'] = df_train['AvSigVersion'].map(datedictAS)
 df_test2 = pd.merge(df_test2, df_test, on='MachineIdentifier', how='left')
 df_test2['AvSigVersion2'] = df_test2['AvSigVersion'].map(lambda x: np.int(x.split('.')[1]))
import pandas as pd
import numpy as np
from matplotlib.pyplot import imshow
import matplotlib.pylab as plt
from PIL import Image<train_model>
if AdjustPublicScore: df_test2.loc[(df_test2['AvSigVersion2']==275)|(df_test2['AvSigVersion2']==273),'HasDetections'] *= 0.6
train_on_gpu = torch.cuda.is_available()
if not train_on_gpu:
print('Training on CPU...')
 else:
print('Training on GPU...' )<load_from_csv>
if AdjustPrivateScore==1:
df_test2.loc[ df_test2['Date']>datetime(2018,11,20,4,0),'HasDetections'] = 0
elif AdjustPrivateScore==2:
df_test2['X'] = df_test2['Date'] - datetime(2018,11,20,4,0)
 df_test2['X'] = df_test2['X'].map(lambda x: x.total_seconds() /86400)
 df_test2['X'].fillna(0,inplace=True)
 s = 5.813888
df_test2['F'] = 1.0
df_test2['F'] = 1 - df_test2['X']/s
df_test2.loc[df_test2['X']<=0,'F'] = 1.0
df_test2.loc[df_test2['X']>s,'F'] = 0
df_test2['HasDetections'] *= df_test2['F']
dataset = pd.read_csv('/kaggle/input/digit-recognizer/train.csv')
 dataset.head(5 )<data_type_conversions>
df_test2[['MachineIdentifier','HasDetections']].to_csv('PrivateLeaderboard.csv', index=False )