Kaggle competition: Predict Future Sales
imgs = train_df['image_id'].to_numpy()<choose_model_class>
ssub=pd.read_csv("/kaggle/input/competitive-data-science-predict-future-sales/sample_submission.csv" )
tst_preds = []
skf = StratifiedKFold(n_splits=10, shuffle=True)
 for _, val_idx in skf.split(imgs, np.array(train_lbls)) :
dls = get_data(val_idx, 128, 64)
 learn = cnn_learner(dls, resnet152, metrics=metrics)
 lr = 1e-3
learn.fine_tune(1, lr)
 learn.save('initial')
 del learn
torch.cuda.empty_cache()
gc.collect()
dls = get_data(val_idx, 256, 16)
 learn = cnn_learner(dls, resnet152, metrics=metrics)
 learn.load('initial');
learn.freeze()
learn.fine_tune(4, 1e-3)
 learn.save('v2')
 del learn
torch.cuda.empty_cache()
gc.collect()
dls = get_data(val_idx, 448, 8)
 learn = cnn_learner(dls, resnet152, metrics=metrics)
 learn.load('v2');
learn.unfreeze()
learn.fit_one_cycle(3, slice(1e-5, 1e-4))
tst_dl = learn.dls.test_dl(test_df)
 y, _ = learn.tta(dl=tst_dl)
 tst_preds.append(y)
 del learn
torch.cuda.empty_cache()
gc.collect()<define_variables>
xgboost_lagged_features = pd.read_csv(".. /input/xgboost/xgboost_lagged_features.csv" )
tot = tst_preds[0]
for i in tst_preds[1:]:
tot += i<define_variables>
linear_regression_lagged_features_6 = pd.read_csv(".. /input/linearregression/linear_regression_lagged_features_6.csv" )
tot = tot / 10<load_from_csv>
random_forest_lagged_features = pd.read_csv(".. /input/randfor/random_forest_lagged_features.csv" )
subm = pd.read_csv(path/"sample_submission.csv" )<feature_engineering>
ssub["item_cnt_month"]=(xgboost_lagged_features["item_cnt_month"]+random_forest_lagged_features["item_cnt_month"])/2
subm.iloc[:, 1:] = tot<save_to_csv>
ssub.to_csv("weighted_averaging.csv",index=False )