Kaggle competition: ClassificationOFShields
matrix['month'] = matrix['date_block_num'] % 12<categorify>

 with open(".. /input/train.json")as f:
data = json.load(f)
 X = []
Y = []
for element in data:
img = cv2.resize(np.array(Image.open(".. /input/train/train/" + element["filename"])) ,(64,64))
X.append(np.array(img/255))
Y.append(element["class"])
 y_train = np.array(to_categorical(Y))
x_train = np.array(X)
 base_model = ResNet50(weights='imagenet', include_top=False)
 x = base_model.output
x = GlobalAveragePooling2D()(x)
 x = Dense(1024, activation='relu' )(x)
 predictions = Dense(29, activation='softmax' )(x)
 model = Model(inputs=base_model.input, outputs=predictions)
 model.compile(optimizer=SGD(lr=0.0001, momentum=0.9),
loss='categorical_crossentropy',
metrics=["accuracy"])
 hist = model.fit(x_train,
y_train,
batch_size=32,
validation_split=0.2,
epochs=10)
days = pd.Series([31,28,31,30,31,30,31,31,30,31,30,31])
 matrix['days'] = matrix['month'].map(days ).astype(np.int8 )<data_type_conversions>
with open(".. /input/sandbox.csv")as f:
data = f.readlines()
content = [x.strip() for x in data]
just_names = [x.split(',')[0] for x in content[1:]]
ts = time.time()
cache = {}
matrix['item_shop_last_sale'] = -1
matrix['item_shop_last_sale'] = matrix['item_shop_last_sale'].astype(np.int8)
 for idx, row in matrix.iterrows() :
key = str(row.item_id)+' '+str(row.shop_id)
 if key not in cache:
if row.item_cnt_month!=0:
cache[key] = row.date_block_num
else:
last_date_block_num = cache[key]
matrix.at[idx, 'item_shop_last_sale'] = row.date_block_num - last_date_block_num
cache[key] = row.date_block_num
time.time() - ts<data_type_conversions>
results = []
for c in tqdm(just_names):
img = Image.open(".. /input/test/test/" + c)
 img = np.array(img,dtype=np.float32)/ 255
res = model.predict(np.array([img]))
results.append(np.argmax(res[0]))
<feature_engineering><EOS> 
with open("submission.csv","w")as f:
f.write("ID,Class"+'
')
 for ID,Class in zip(just_names,results):
f.write(ID + "," + str(Class)+ "
" )